summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp4
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
index 763d3765e0b..906140db54e 100644
--- a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
@@ -19,9 +19,9 @@ namespace tidy {
void InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
const std::string Algorithms =
- "std::(find|count|equal_range|lower_blound|upper_bound)";
+ "^::std::(find|count|equal_range|lower_blound|upper_bound)$";
const auto ContainerMatcher = classTemplateSpecializationDecl(
- matchesName("std::(unordered_)?(multi)?(set|map)"));
+ matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
const auto Matcher =
callExpr(
callee(functionDecl(matchesName(Algorithms))),
diff --git a/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp b/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp
index 46a5b2a9456..4ed2fb25c9c 100644
--- a/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp
@@ -32,6 +32,9 @@ template <typename FwIt, typename K> FwIt find(FwIt, FwIt, const K &);
template <typename FwIt, typename K, typename Cmp>
FwIt find(FwIt, FwIt, const K &, Cmp);
+template <typename FwIt, typename Pred>
+FwIt find_if(FwIt, FwIt, Pred);
+
template <typename FwIt, typename K> FwIt count(FwIt, FwIt, const K &);
template <typename FwIt, typename K> FwIt lower_bound(FwIt, FwIt, const K &);
@@ -58,6 +61,7 @@ int main() {
auto c = count(s.begin(), s.end(), 43);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
// CHECK-FIXES: {{^ }}auto c = s.count(43);{{$}}
+ it = find_if(s.begin(), s.end(), [](int) { return false; });
std::multiset<int> ms;
find(ms.begin(), ms.end(), 46);
OpenPOWER on IntegriCloud