aboutsummaryrefslogtreecommitdiffstats
path: root/src/checks/level0/container-anti-pattern.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/checks/level0/container-anti-pattern.cpp')
-rw-r--r--src/checks/level0/container-anti-pattern.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/checks/level0/container-anti-pattern.cpp b/src/checks/level0/container-anti-pattern.cpp
index 54927f54..855c4015 100644
--- a/src/checks/level0/container-anti-pattern.cpp
+++ b/src/checks/level0/container-anti-pattern.cpp
@@ -21,10 +21,10 @@
#include "container-anti-pattern.h"
#include "Utils.h"
-#include "checkmanager.h"
#include "StringUtils.h"
#include "MacroUtils.h"
#include "LoopUtils.h"
+#include "HierarchyUtils.h"
#include <clang/AST/AST.h>
#include <clang/Lex/Lexer.h>
@@ -34,7 +34,7 @@ using namespace std;
ContainerAntiPattern::ContainerAntiPattern(const std::string &name, ClazyContext *context)
- : CheckBase(name, context)
+ : CheckBase(name, context, Option_CanIgnoreIncludes)
{
}
@@ -48,7 +48,7 @@ static bool isInterestingCall(CallExpr *call)
"QMap::keys", "QSet::toList", "QSet::values",
"QHash::values", "QHash::keys" };
- return clazy_std::contains(methods, StringUtils::qualifiedMethodName(func));
+ return clazy::contains(methods, clazy::qualifiedMethodName(func));
}
void ContainerAntiPattern::VisitStmt(clang::Stmt *stmt)
@@ -70,7 +70,7 @@ void ContainerAntiPattern::VisitStmt(clang::Stmt *stmt)
if (!isInterestingCall(callexpr1))
return;
- emitWarning(stmt->getLocStart(), "allocating an unneeded temporary container");
+ emitWarning(getLocStart(stmt), "allocating an unneeded temporary container");
}
bool ContainerAntiPattern::VisitQSet(Stmt *stmt)
@@ -80,7 +80,7 @@ bool ContainerAntiPattern::VisitQSet(Stmt *stmt)
return false;
CXXMethodDecl *secondMethod = secondCall->getMethodDecl();
- const string secondMethodName = StringUtils::qualifiedMethodName(secondMethod);
+ const string secondMethodName = clazy::qualifiedMethodName(secondMethod);
if (secondMethodName != "QSet::isEmpty")
return false;
@@ -94,28 +94,24 @@ bool ContainerAntiPattern::VisitQSet(Stmt *stmt)
return false;
CXXMethodDecl *firstMethod = dyn_cast<CXXMethodDecl>(firstFunc);
- if (!firstMethod || StringUtils::qualifiedMethodName(firstMethod) != "QSet::intersect")
+ if (!firstMethod || clazy::qualifiedMethodName(firstMethod) != "QSet::intersect")
return false;
- emitWarning(stmt->getLocStart(), "Use QSet::intersects() instead");
+ emitWarning(getLocStart(stmt), "Use QSet::intersects() instead");
return true;
}
bool ContainerAntiPattern::handleLoop(Stmt *stm)
{
- Expr *containerExpr = LoopUtils::containerExprForLoop(stm);
+ Expr *containerExpr = clazy::containerExprForLoop(stm);
if (!containerExpr)
return false;
- auto memberExpr = HierarchyUtils::getFirstChildOfType2<CXXMemberCallExpr>(containerExpr);
+ auto memberExpr = clazy::getFirstChildOfType2<CXXMemberCallExpr>(containerExpr);
if (isInterestingCall(memberExpr)) {
- emitWarning(stm->getLocStart(), "allocating an unneeded temporary container");
+ emitWarning(getLocStart(stm), "allocating an unneeded temporary container");
return true;
}
return false;
}
-
-
-
-REGISTER_CHECK("container-anti-pattern", ContainerAntiPattern, CheckLevel0)