[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 10:29:54 PDT 2024


================
@@ -562,9 +567,10 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
   }
 
   StringRef FileName(File->getName());
-  LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
-                               Sources.isInMainFile(Location) ||
-                               getHeaderFilter()->match(FileName);
+  LastErrorRelatesToUserCode =
+      LastErrorRelatesToUserCode || Sources.isInMainFile(Location) ||
+      (getHeaderFilter()->match(FileName) &&
+       (ExcludeHeaderFilter ? !ExcludeHeaderFilter->match(FileName) : true));
----------------
justincady wrote:

Thank you! Simplified that snippet and added the tests as suggested.

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


More information about the cfe-commits mailing list