[clang-tools-extra] r263822 - [clang-tidy] Use hasAnyName() instead of matchesName().
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 18 13:14:35 PDT 2016
Author: sbenza
Date: Fri Mar 18 15:14:35 2016
New Revision: 263822
URL: http://llvm.org/viewvc/llvm-project?rev=263822&view=rev
Log:
[clang-tidy] Use hasAnyName() instead of matchesName().
matchesName() uses regular expressions and it is very slow.
hasAnyName() gives the same result and it is much faster.
A benchmark (with all the checks enabled) shows a ~5% speed up of
clang-tidy.
Modified:
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp?rev=263822&r1=263821&r2=263822&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Fri Mar 18 15:14:35 2016
@@ -33,13 +33,16 @@ void InefficientAlgorithmCheck::register
if (!getLangOpts().CPlusPlus)
return;
- const std::string Algorithms =
- "^::std::(find|count|equal_range|lower_bound|upper_bound)$";
- const auto ContainerMatcher = classTemplateSpecializationDecl(
- matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
+ const auto Algorithms =
+ hasAnyName("::std::find", "::std::count", "::std::equal_range",
+ "::std::lower_bound", "::std::upper_bound");
+ const auto ContainerMatcher = classTemplateSpecializationDecl(hasAnyName(
+ "::std::set", "::std::map", "::std::multiset", "::std::multimap",
+ "::std::unordered_set", "::std::unordered_map"));
+
const auto Matcher =
callExpr(
- callee(functionDecl(matchesName(Algorithms))),
+ callee(functionDecl(Algorithms)),
hasArgument(
0, cxxConstructExpr(has(cxxMemberCallExpr(
callee(cxxMethodDecl(hasName("begin"))),
More information about the cfe-commits
mailing list