From: Samuel Benzaquen Date: Mon, 21 Mar 2016 18:00:43 +0000 (+0000) Subject: [clang-tidy] Fix check broken in rL263822. X-Git-Tag: llvmorg-3.9.0-rc1~11333 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd6a74e1facb648f2d4dd94ac0f1a62f6dc2b44b;p=platform%2Fupstream%2Fllvm.git [clang-tidy] Fix check broken in rL263822. Add names missing from rL263822 and add tests to prevent future omissions. llvm-svn: 263963 --- diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp index d585590..0dea909 100644 --- a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp +++ b/clang-tools-extra/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/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp b/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp index df962c9..75ca7d6 100644 --- a/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-inefficient-algorithm.cpp @@ -35,7 +35,11 @@ template > struct map { iterator end() const; }; +template struct multimap : map {}; template struct unordered_set : set {}; +template struct unordered_map : map {}; +template struct unordered_multiset : set {}; +template struct unordered_multimap : map {}; template > struct multiset : set {}; @@ -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 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 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 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 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 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 {