Index: clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h =================================================================== --- clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h +++ clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h @@ -6,9 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// + #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include namespace clang { namespace ast_matchers { @@ -28,10 +29,9 @@ /// /// Usable as: Matcher, Matcher, Matcher, /// Matcher - -AST_POLYMORPHIC_MATCHER(isInAbseilFile, - AST_POLYMORPHIC_SUPPORTED_TYPES( - Decl, Stmt, TypeLoc, NestedNameSpecifierLoc)) { +AST_POLYMORPHIC_MATCHER( + isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc, + NestedNameSpecifierLoc)) { auto &SourceManager = Finder->getASTContext().getSourceManager(); SourceLocation Loc = Node.getBeginLoc(); if (Loc.isInvalid()) @@ -41,10 +41,16 @@ if (!FileEntry) return false; StringRef Filename = FileEntry->getName(); - llvm::Regex RE( - "absl/(algorithm|base|container|debugging|memory|meta|numeric|strings|" - "synchronization|time|types|utility)"); - return RE.match(Filename); + const llvm::SmallString<5> AbslPrefix("absl/"); + if (!Filename.startswith(AbslPrefix)) + return false; + Filename = Filename.drop_front(AbslPrefix.size()); + static const char *AbseilLibraries[] = { + "algorithm", "base", "container", "debugging", + "memory", "meta", "numeric", "strings", + "synchronization", "time", "types", "utility"}; + return std::any_of(std::begin(AbseilLibraries), std::end(AbseilLibraries), + [&](const char *Library) { return Library == Filename; }); } } // namespace ast_matchers