[clang-tools-extra] r263963 - [clang-tidy] Fix check broken in rL263822.
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 21 11:00:43 PDT 2016
Author: sbenza
Date: Mon Mar 21 13:00:43 2016
New Revision: 263963
URL: http://llvm.org/viewvc/llvm-project?rev=263963&view=rev
Log:
[clang-tidy] Fix check broken in rL263822.
Add names missing from rL263822 and add tests to prevent future omissions.
Modified:
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.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=263963&r1=263962&r2=263963&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Mon Mar 21 13:00:43 2016
@@ -38,7 +38,8 @@ void InefficientAlgorithmCheck::register
"::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(
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=263963&r1=263962&r2=263963&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp Mon Mar 21 13:00:43 2016
@@ -35,7 +35,11 @@ template <typename K, typename V, typena
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 {
More information about the cfe-commits
mailing list