njames93 created this revision. njames93 added reviewers: aaron.ballman, alexfh, gribozavr2, hokein. Herald added subscribers: cfe-commits, xazax.hun. Herald added a project: clang.
Fixes readability-identifier-naming option MacroDefinitionCase should ignore macros passed as parameters. <https://bugs.llvm.org/show_bug.cgi?id=42635> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80631 Files: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp @@ -80,7 +80,7 @@ // 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 Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -73,6 +73,14 @@ /// 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()); }
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp @@ -80,7 +80,7 @@ // 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 Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -73,6 +73,14 @@ /// 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()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits