[clang-tools-extra] Add option to exclude headers from clang-tidy analysis (PR #91400)

Justin Cady via cfe-commits cfe-commits at lists.llvm.org
Thu May 9 14:08:10 PDT 2024


================
@@ -311,7 +311,12 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
     : Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
       RemoveIncompatibleErrors(RemoveIncompatibleErrors),
       GetFixesFromNotes(GetFixesFromNotes),
-      EnableNolintBlocks(EnableNolintBlocks) {}
+      EnableNolintBlocks(EnableNolintBlocks) {
+
+  if (Context.getOptions().ExcludeHeaderFilterRegex)
+    ExcludeHeaderFilter = std::make_unique<llvm::Regex>(
+        *Context.getOptions().ExcludeHeaderFilterRegex);
----------------
justincady wrote:

What makes you suspect it doesn't work? I did some testing by placing `abort()` in an else clause and it caused many unit tests to crash. That leads me to believe it remains `std::nullopt` when the option is not specified.

I will do some more thorough testing to confirm.

https://github.com/llvm/llvm-project/pull/91400


More information about the cfe-commits mailing list