summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2015-08-31 15:28:57 +0000
committerAaron Ballman <aaron@aaronballman.com>2015-08-31 15:28:57 +0000
commitbf89109013bc51868173de3d8c71d28989afd39e (patch)
tree434ce8b894754eef5a23ba04b53e09a7da674459 /clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
parent54f3657448fd127fd00162058c9f1f56f966fc18 (diff)
downloadbcm5719-llvm-bf89109013bc51868173de3d8c71d28989afd39e.tar.gz
bcm5719-llvm-bf89109013bc51868173de3d8c71d28989afd39e.zip
Using an early return as it is more clear; NFC.
llvm-svn: 246447
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
index 17ef560227f..a9a1a092031 100644
--- a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.cpp
@@ -30,33 +30,34 @@ static bool areTypesCompatible(QualType Left, QualType Right) {
void InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
- if (getLangOpts().CPlusPlus) {
- const std::string Algorithms =
- "^::std::(find|count|equal_range|lower_bound|upper_bound)$";
- const auto ContainerMatcher = classTemplateSpecializationDecl(
- matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
- const auto Matcher =
- callExpr(
- callee(functionDecl(matchesName(Algorithms))),
- hasArgument(
- 0, constructExpr(has(memberCallExpr(
- callee(methodDecl(hasName("begin"))),
- on(declRefExpr(
- hasDeclaration(decl().bind("IneffContObj")),
- anyOf(hasType(ContainerMatcher.bind("IneffCont")),
- hasType(pointsTo(ContainerMatcher.bind(
- "IneffContPtr")))))
- .bind("IneffContExpr")))))),
- hasArgument(1, constructExpr(has(memberCallExpr(
- callee(methodDecl(hasName("end"))),
- on(declRefExpr(hasDeclaration(
- equalsBoundNode("IneffContObj")))))))),
- hasArgument(2, expr().bind("AlgParam")),
- unless(isInTemplateInstantiation()))
- .bind("IneffAlg");
-
- Finder->addMatcher(Matcher, this);
- }
+ if (!getLangOpts().CPlusPlus)
+ return;
+
+ const std::string Algorithms =
+ "^::std::(find|count|equal_range|lower_bound|upper_bound)$";
+ const auto ContainerMatcher = classTemplateSpecializationDecl(
+ matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
+ const auto Matcher =
+ callExpr(
+ callee(functionDecl(matchesName(Algorithms))),
+ hasArgument(
+ 0, constructExpr(has(memberCallExpr(
+ callee(methodDecl(hasName("begin"))),
+ on(declRefExpr(
+ hasDeclaration(decl().bind("IneffContObj")),
+ anyOf(hasType(ContainerMatcher.bind("IneffCont")),
+ hasType(pointsTo(
+ ContainerMatcher.bind("IneffContPtr")))))
+ .bind("IneffContExpr")))))),
+ hasArgument(1, constructExpr(has(memberCallExpr(
+ callee(methodDecl(hasName("end"))),
+ on(declRefExpr(hasDeclaration(
+ equalsBoundNode("IneffContObj")))))))),
+ hasArgument(2, expr().bind("AlgParam")),
+ unless(isInTemplateInstantiation()))
+ .bind("IneffAlg");
+
+ Finder->addMatcher(Matcher, this);
}
void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
OpenPOWER on IntegriCloud