The check should ignore the main function, the program entry point.
It is not possible to use std::array<> for the argv.
The alternative is to use char** argv.
Fixes PR40604
JonasToth | |
aaron.ballman |
The check should ignore the main function, the program entry point.
It is not possible to use std::array<> for the argv.
The alternative is to use char** argv.
Fixes PR40604
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
35 | There is FunctionDecl->castToDeclContext() which is probably a better fit here. | |
test/clang-tidy/modernize-avoid-c-arrays.cpp | ||
90 ↗ | (On Diff #185400) | main has a third optional argument for environment variables. Please add test case for that, too. |
test/clang-tidy/modernize-avoid-c-arrays.cpp | ||
---|---|---|
90 ↗ | (On Diff #185400) | char **argv form *is* ignored, that is why i have not seen this issue before. |
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
35 | I'm guessing you meant cast*From*DeclContext(). |
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
35 | I'm not too sure about this. |
Add an assert to ensure that clang::FunctionDecl::castFromDeclContext() is safe to do.
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
35 | From Doc "Represents a parameter to a function. " so i think it has always a FunctionDecl (or subclass) as DeclContext. Maybe that function is a relict? I just saw it in the docs too and thought it makes sense to use it. No opinion on that, @aaron.ballman do you know more on that? |
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
35 |
ObjCMethodDecl is not a subclass of FunctionDecl, yet it contains ParmVarDecl objects and is a DeclContext. I would use dyn_cast here instead. | |
docs/clang-tidy/checks/modernize-avoid-c-arrays.rst | ||
58 | It's -> Its |
LGTM aside from a nit.
clang-tidy/modernize/AvoidCArraysCheck.cpp | ||
---|---|---|
36–38 | return FD ? FD->isMain() : false; ? |