https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/132016
Currently, the check is processing system macros. Most importantly, it tries to find .clang-tidy files associated with those files, if the option GetConfigPerFile (on by default) is active. This is problematic for a number of reasons: - System macros cannot be acted upon (renamed), so it's wasted work. - When the main .cpp file includes a system header, clang-tidy tries to find the .clang-tidy file for that system header. When that system header is a 3rd-party repository, they may have their own .clang-tidy file, which may not be compatible with the current version of clang-tidy. So, clang-tidy may fail to analyze our main.cpp file, only because it includes a 3rd-party system header whose .clang-tidy file is incompatible with our clang-tidy binary. Therefore, skip system macros in this check. >From dd010cc21df6000831af2e693805461262201546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= <carlos.gal...@zenseact.com> Date: Wed, 19 Mar 2025 12:28:49 +0000 Subject: [PATCH] [clang-tidy] Skip system macros in readability-identifier-naming check Currently, the check is processing system macros. Most importantly, it tries to find .clang-tidy files associated with those files, if the option GetConfigPerFile (on by default) is active. This is problematic for a number of reasons: - System macros cannot be acted upon (renamed), so it's wasted work. - When the main .cpp file includes a system header, clang-tidy tries to find the .clang-tidy file for that system header. When that system header is a 3rd-party repository, they may have their own .clang-tidy file, which may not be compatible with the current version of clang-tidy. So, clang-tidy may fail to analyze our main.cpp file, only because it includes a 3rd-party system header whose .clang-tidy file is incompatible with our clang-tidy binary. Therefore, skip system macros in this check. --- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp index 9104723c7f1c0..59e11ca51a0ae 100644 --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -194,6 +194,8 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks { return; if (SM.isWrittenInCommandLineFile(MacroNameTok.getLocation())) return; + if (SM.isInSystemHeader(MacroNameTok.getLocation())) + return; Check->checkMacro(MacroNameTok, Info, SM); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits