Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42635 | readability-identifier-naming option MacroDefinitionCase should ignore macros passed as parameters. ]]
Reviewers: aaron.ballman, alexfh, gribozavr2, hokein
Reviewed By: aaron.ballman
Subscribers: xazax.hun, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80631
/// MacroDefined calls checkMacro for macros in the main file
void MacroDefined(const Token &MacroNameTok,
const MacroDirective *MD) override {
+ if (MD->getMacroInfo()->isBuiltinMacro())
+ return;
+ if (PP->getSourceManager().isWrittenInBuiltinFile(
+ MacroNameTok.getLocation()))
+ return;
+ if (PP->getSourceManager().isWrittenInCommandLineFile(
+ MacroNameTok.getLocation()))
+ return;
Check->checkMacro(PP->getSourceManager(), MacroNameTok, MD->getMacroInfo());
}
// RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
// RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
// RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \
-// RUN: ]}' -- -fno-delayed-template-parsing \
+// RUN: ]}' -- -fno-delayed-template-parsing -Dbad_macro \
// RUN: -I%S/Inputs/readability-identifier-naming \
// RUN: -isystem %S/Inputs/readability-identifier-naming/system