[PATCH] D96140: [clang-tidy] Simplify inefficient algorithm check
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 17 02:20:22 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c2eca96a2a5: [clang-tidy] Simplify inefficient algorithm check (authored by stephenkelly).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96140/new/
https://reviews.llvm.org/D96140
Files:
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s performance-inefficient-algorithm %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t
namespace std {
template <typename T> struct less {
Index: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
===================================================================
--- clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
+++ clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -29,6 +29,9 @@
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+ llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
+ return TK_IgnoreUnlessSpelledInSource;
+ }
};
} // namespace performance
Index: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -35,27 +35,24 @@
"::std::unordered_set", "::std::unordered_map",
"::std::unordered_multiset", "::std::unordered_multimap"));
- const auto Matcher = traverse(
- TK_AsIs,
+ const auto Matcher =
callExpr(
callee(functionDecl(Algorithms)),
hasArgument(
- 0, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
+ 0, cxxMemberCallExpr(
callee(cxxMethodDecl(hasName("begin"))),
on(declRefExpr(
hasDeclaration(decl().bind("IneffContObj")),
anyOf(hasType(ContainerMatcher.bind("IneffCont")),
hasType(pointsTo(
ContainerMatcher.bind("IneffContPtr")))))
- .bind("IneffContExpr"))))))),
+ .bind("IneffContExpr")))),
hasArgument(
- 1, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
- callee(cxxMethodDecl(hasName("end"))),
- on(declRefExpr(
- hasDeclaration(equalsBoundNode("IneffContObj"))))))))),
- hasArgument(2, expr().bind("AlgParam")),
- unless(isInTemplateInstantiation()))
- .bind("IneffAlg"));
+ 1, cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))),
+ on(declRefExpr(hasDeclaration(
+ equalsBoundNode("IneffContObj")))))),
+ hasArgument(2, expr().bind("AlgParam")))
+ .bind("IneffAlg");
Finder->addMatcher(Matcher, this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96140.324244.patch
Type: text/x-patch
Size: 3199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210217/21cd7c73/attachment.bin>
More information about the cfe-commits
mailing list