[clang-tools-extra] 4411962 - [clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Sat May 30 12:49:41 PDT 2020
Author: Nathan James
Date: 2020-05-30T20:49:33+01:00
New Revision: 44119626dedfebe245fe6ce26487949201299d38
URL: https://github.com/llvm/llvm-project/commit/44119626dedfebe245fe6ce26487949201299d38
DIFF: https://github.com/llvm/llvm-project/commit/44119626dedfebe245fe6ce26487949201299d38.diff
LOG: [clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros
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
Added:
Modified:
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index dd05b3a45c0d..3301ba6343c7 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -73,6 +73,14 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
/// 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());
}
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
index 7983bb30ca64..1bb435e02eb5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ b/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
More information about the cfe-commits
mailing list