feat(lint): fixed-width-types keeps widths that a foreign API chose
The rewrite itself stays token-shaped — it edits type SPELLINGS, which an AST
discards — but what it must not touch now comes from the AST.
The old exemption was per LINE: `int main`, `argc`, `argv`, `extern "`. Being a
transform, a missed exemption here does not over-report, it emits code that no
longer matches the API being called, so this is the rule where guessing from
substrings mattered most. And being per-line, it also disabled the rule for
anything sharing a line with one of those words.
Now a declaration with C language linkage, or one whose initialiser binds to an
entity declared outside the project, contributes a protected byte range and
keeps its spelling. That answers the case directly: a function declared in
somebody else's header taking `unsigned int` keeps `unsigned int`, and a local
initialised from strtoul keeps `unsigned long`, because of where those are
declared rather than because of what the line says.
main is protected from the start of its declaration to the opening brace of its
body, not for its whole extent. Its signature is fixed by the language; its body
is ordinary code. Three findings on this repository came out of that
distinction, all correct:
for (int i = 1; i < argc; ++i) -> for (std::int32_t i = 1; ...)
skipped before only because `argc` appeared on the line, plus Crafter::Run's own
`int argc` and return type, which are ours rather than the language's.
All three AST rules now share one interop test instead of carrying a denylist
each, and it is the same test: whose header dictates this spelling.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d55657b7ce
commit
6438cb9ebb
4 changed files with 68 additions and 10 deletions
|
|
@ -1638,7 +1638,7 @@ Exit status:
|
|||
}
|
||||
|
||||
// lint-disable-next-line no-char-pointer
|
||||
int Crafter::Run(int argc, char** argv) {
|
||||
std::int32_t Crafter::Run(std::int32_t argc, char** argv) {
|
||||
try {
|
||||
std::string_view argv0 = argc > 0 ? argv[0] : "crafter-build";
|
||||
fs::path projectFile = "./project.cpp";
|
||||
|
|
@ -1654,7 +1654,7 @@ int Crafter::Run(int argc, char** argv) {
|
|||
RunLintOptions lintOpts;
|
||||
Progress::Verbosity verbosity = Progress::Verbosity::Default;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
for (std::int32_t i = 1; i < argc; ++i) {
|
||||
std::string_view arg = argv[i];
|
||||
if (arg == "-h" || arg == "--help" || (!runTests && !runLint && !runFormat && arg == "help")) {
|
||||
PrintHelp(argv0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue