I'll add some more tests for members of template classes etc., but I wanted to get some initial feedback.
Diff Detail
Event Timeline
This check (especially the fix part) would be really nice to have.
| clang-tidy/misc/UseOverride.cpp | ||
|---|---|---|
| 32 | Does it make sense to check for getLocation().isMacroID() after this? | |
| 41 | Can you adapt FindToken from google/GoogleTidyModule.cpp to be usable here (and move it to a common place)? (Or maybe convert it to ParseTokens or something similar.) | |
| test/clang-tidy/use-override.cpp | ||
| 1 | Please add tests with macros: when the whole class is defined in a macro and when a macro is used for "override" and for "virtual" (which is interesting, as the code removes "virtual"). | |
| clang-tidy/misc/UseOverride.cpp | ||
|---|---|---|
| 32 | Changed order of the first two checks. | |
| 41 | Only partially as I need to lex all the tokens of the function definition (to scan backwards for "= 0"). I guess we could pull out abstraction here, but I am not exactly sure what that should be. | |
| test/clang-tidy/use-override.cpp | ||
| 1 | Done. | |
| clang-tidy/misc/UseOverride.cpp | ||
|---|---|---|
| 41 | We could at least pull out something like this: vector<Token> ParseTokens(SourceLocation From, SourceLocation To, <SourceManager and whatever else is needed>); To be more generic "To" could be replaced by a predicate, though this may be too generic ;) | |
| 97 | Instead of special-casing this macro, you could find if the identifier is a macro, and see what it expands to using something similar to this: IdentifierInfo *II = PP.getIdentifierInfo(Token.back());
if (II.hadMacroDefinition()) {
if (const DefMacroDirective *Def = PP.getMacroDirectiveHistory(II)->findDirectiveAtLoc(...)->getDirective()) {
<compare Def->getInfo()->tokens_{begin,end}() with {'=', '0'}>
... | |
Does it make sense to check for getLocation().isMacroID() after this?