aboutsummaryrefslogtreecommitdiffstats
path: root/src/checks/level1/qdeleteall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/checks/level1/qdeleteall.cpp')
-rw-r--r--src/checks/level1/qdeleteall.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/checks/level1/qdeleteall.cpp b/src/checks/level1/qdeleteall.cpp
index 753d8667..8ce18e1e 100644
--- a/src/checks/level1/qdeleteall.cpp
+++ b/src/checks/level1/qdeleteall.cpp
@@ -24,7 +24,6 @@
#include "Utils.h"
#include "HierarchyUtils.h"
#include "QtUtils.h"
-#include "checkmanager.h"
#include <clang/AST/AST.h>
#include <vector>
@@ -33,14 +32,14 @@ using namespace clang;
using namespace std;
QDeleteAll::QDeleteAll(const std::string &name, ClazyContext *context)
- : CheckBase(name, context)
+ : CheckBase(name, context, Option_CanIgnoreIncludes)
{
}
void QDeleteAll::VisitStmt(clang::Stmt *stmt)
{
// Find a call to QMap/QSet/QHash::values/keys
- CXXMemberCallExpr *offendingCall = dyn_cast<CXXMemberCallExpr>(stmt);
+ auto offendingCall = dyn_cast<CXXMemberCallExpr>(stmt);
FunctionDecl *func = offendingCall ? offendingCall->getDirectCallee() : nullptr;
if (!func)
return;
@@ -51,15 +50,15 @@ void QDeleteAll::VisitStmt(clang::Stmt *stmt)
if (isValues || isKeys) {
const std::string offendingClassName = offendingCall->getMethodDecl()->getParent()->getNameAsString();
- if (QtUtils::isQtAssociativeContainer(offendingClassName)) {
+ if (clazy::isQtAssociativeContainer(offendingClassName)) {
// Once found see if the first parent call is qDeleteAll
int i = 1;
- Stmt *p = HierarchyUtils::parent(m_context->parentMap, stmt, i);
+ Stmt *p = clazy::parent(m_context->parentMap, stmt, i);
while (p) {
- CallExpr *pc = dyn_cast<CallExpr>(p);
+ auto pc = dyn_cast<CallExpr>(p);
FunctionDecl *f = pc ? pc->getDirectCallee() : nullptr;
if (f) {
- if (f->getNameAsString() == "qDeleteAll") {
+ if (clazy::name(f) == "qDeleteAll") {
string msg = "qDeleteAll() is being used on an unnecessary temporary container created by " + offendingClassName + "::" + funcName + "()";
if (func->getNumParams() == 0) {
if (isValues) {
@@ -69,15 +68,13 @@ void QDeleteAll::VisitStmt(clang::Stmt *stmt)
}
}
- emitWarning(p->getLocStart(), msg);
+ emitWarning(getLocStart(p), msg);
}
break;
}
++i;
- p = HierarchyUtils::parent(m_context->parentMap, stmt, i);
+ p = clazy::parent(m_context->parentMap, stmt, i);
}
}
}
}
-
-REGISTER_CHECK("qdeleteall", QDeleteAll, CheckLevel1)