[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 23 02:19:57 PST 2025
Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>,
Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/128150 at github.com>
================
@@ -449,6 +479,10 @@ ClangTidyASTConsumerFactory::createASTConsumer(
}
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
+
+ if (!Context.getOptions().SystemHeaders.value_or(false))
+ Consumers.push_back(std::make_unique<IgnoreSystemHeadersConsumer>());
+
if (!Checks.empty())
Consumers.push_back(Finder->newASTConsumer());
----------------
carlosgalvezp wrote:
Hmm, this code does not compile? `IgnoreSystemHeadersConsumer` does not have a constructor accepting a `unique_ptr<ASTConsumer>`?
There's also duplication in creating the `Finder->newASTConsumer()`, so I don't see how this solution would be preferable. I can certainly move the `IgnoreSystemHeadersConsumer` inside the `if(!Checks.empty())` though.
https://github.com/llvm/llvm-project/pull/128150
More information about the cfe-commits
mailing list