Author: xazax
Date: Thu Feb 12 12:19:34 2015
New Revision: 228945
URL: http://llvm.org/viewvc/llvm-project?rev=228945&view=rev
Log:
[clang-tidy] Fixed a false positive case in misc-inefficient-algorithm checker.
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=228945&r1=228944&r2=228945&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Thu
Feb 12 12:19:34 2015
@@ -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))),
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=228945&r1=228944&r2=228945&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 Thu
Feb 12 12:19:34 2015
@@ -32,6 +32,9 @@ template <typename FwIt, typename K> FwI
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);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits