summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2016-03-21 18:00:43 +0000
committerSamuel Benzaquen <sbenza@google.com>2016-03-21 18:00:43 +0000
commit9c31a56df691380423cfe7ecbd56970f9c41468b (patch)
treea9536c2f1e0f53b77648661fa7fb5b9f6d631433
parent40ca89572fada68ac61d628cbe8d4888e9a5e748 (diff)
downloadclang-tools-extra-9c31a56df691380423cfe7ecbd56970f9c41468b.tar.gz
[clang-tidy] Fix check broken in rL263822.
Add names missing from rL263822 and add tests to prevent future omissions. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@263963 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clang-tidy/misc/InefficientAlgorithmCheck.cpp3
-rw-r--r--test/clang-tidy/misc-inefficient-algorithm.cpp24
2 files changed, 26 insertions, 1 deletions
diff --git a/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tidy/misc/InefficientAlgorithmCheck.cpp
index d5855901..0dea909f 100644
--- a/clang-tidy/misc/InefficientAlgorithmCheck.cpp
+++ b/clang-tidy/misc/InefficientAlgorithmCheck.cpp
@@ -38,7 +38,8 @@ void InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
"::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"));
+ "::std::unordered_set", "::std::unordered_map",
+ "::std::unordered_multiset", "::std::unordered_multimap"));
const auto Matcher =
callExpr(
diff --git a/test/clang-tidy/misc-inefficient-algorithm.cpp b/test/clang-tidy/misc-inefficient-algorithm.cpp
index df962c91..75ca7d64 100644
--- a/test/clang-tidy/misc-inefficient-algorithm.cpp
+++ b/test/clang-tidy/misc-inefficient-algorithm.cpp
@@ -35,7 +35,11 @@ template <typename K, typename V, typename Cmp = less<K>> struct map {
iterator end() const;
};
+template <typename K, typename V> struct multimap : map<K, V> {};
template <typename K> struct unordered_set : set<K> {};
+template <typename K, typename V> struct unordered_map : map<K, V> {};
+template <typename K> struct unordered_multiset : set<K> {};
+template <typename K, typename V> struct unordered_multimap : map<K, V> {};
template <typename K, typename Cmp = less<K>> struct multiset : set<K, Cmp> {};
@@ -114,10 +118,30 @@ int main() {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
// CHECK-FIXES: {{^ }}us.find(10);{{$}}
+ std::unordered_multiset<int> ums;
+ find(ums.begin(), ums.end(), 10);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+ // CHECK-FIXES: {{^ }}ums.find(10);{{$}}
+
std::map<int, int> intmap;
find(intmap.begin(), intmap.end(), 46);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
// CHECK-FIXES: {{^ }}find(intmap.begin(), intmap.end(), 46);{{$}}
+
+ std::multimap<int, int> intmmap;
+ find(intmmap.begin(), intmmap.end(), 46);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+ // CHECK-FIXES: {{^ }}find(intmmap.begin(), intmmap.end(), 46);{{$}}
+
+ std::unordered_map<int, int> umap;
+ find(umap.begin(), umap.end(), 46);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+ // CHECK-FIXES: {{^ }}find(umap.begin(), umap.end(), 46);{{$}}
+
+ std::unordered_multimap<int, int> ummap;
+ find(ummap.begin(), ummap.end(), 46);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+ // CHECK-FIXES: {{^ }}find(ummap.begin(), ummap.end(), 46);{{$}}
}
struct Value {