[clang-tidy] Fixed a false positive case in misc-inefficient-algorithm checker.

llvm-svn: 228945
This commit is contained in:
Gabor Horvath 2015-02-12 18:19:34 +00:00
parent 3c4f89d702
commit 0329519904
2 changed files with 6 additions and 2 deletions

View File

@ -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))),

View File

@ -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);