[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 30 08:52:27 PDT 2025
================
@@ -571,17 +560,30 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
}
StringRef FileName(File->getName());
- LastErrorRelatesToUserCode =
- LastErrorRelatesToUserCode || Sources.isInMainFile(Location) ||
- (HeaderFilter &&
- (HeaderFilter->match(FileName) &&
- !(ExcludeHeaderFilter && ExcludeHeaderFilter->match(FileName))));
+ LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
+ Sources.isInMainFile(Location) ||
+ (getHeaderFilter()->match(FileName) &&
+ !getExcludeHeaderFilter()->match(FileName));
unsigned LineNumber = Sources.getExpansionLineNumber(Location);
LastErrorPassesLineFilter =
LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);
}
+llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {
+ if (!HeaderFilter)
+ HeaderFilter =
+ std::make_unique<llvm::Regex>(*Context.getOptions().HeaderFilterRegex);
----------------
carlosgalvezp wrote:
Thanks, good point. That was also changed in the original PR so I will revert that too. I wonder if it makes more sense to do a full revert and reland with the right changes instead. But since the PR is 1 year old it might be tricky.
https://github.com/llvm/llvm-project/pull/133582
More information about the cfe-commits
mailing list