aboutsummaryrefslogtreecommitdiffstats
path: root/src/checks/level2/base-class-event.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/checks/level2/base-class-event.cpp')
-rw-r--r--src/checks/level2/base-class-event.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/checks/level2/base-class-event.cpp b/src/checks/level2/base-class-event.cpp
index 868597ce..66aaa808 100644
--- a/src/checks/level2/base-class-event.cpp
+++ b/src/checks/level2/base-class-event.cpp
@@ -24,15 +24,15 @@
#include "HierarchyUtils.h"
#include "QtUtils.h"
#include "TypeUtils.h"
-#include "checkmanager.h"
#include <clang/AST/AST.h>
#include <clang/AST/DeclCXX.h>
+#include <array>
+
using namespace clang;
using namespace std;
-
BaseClassEvent::BaseClassEvent(const std::string &name, ClazyContext *context)
: CheckBase(name, context)
{
@@ -52,35 +52,33 @@ void BaseClassEvent::VisitDecl(Decl *decl)
return;
CXXRecordDecl *classDecl = method->getParent();
- if (!QtUtils::isQObject(classDecl))
+ if (!clazy::isQObject(classDecl))
return;
const string className = classDecl->getQualifiedNameAsString();
- if (clazy_std::contains(vector<string>({"QObject", "QWidget"}), className))
+ if (clazy::contains(std::array<StringRef, 2>({"QObject", "QWidget"}), className))
return;
- CXXRecordDecl *baseClass = QtUtils::getQObjectBaseClass(classDecl);
+ CXXRecordDecl *baseClass = clazy::getQObjectBaseClass(classDecl);
const string baseClassName = baseClass ? baseClass->getQualifiedNameAsString()
: string("BaseClass");
- if (isEventFilter && clazy_std::contains(vector<string>({"QObject", "QWidget"}), baseClassName)) {
+ if (isEventFilter && clazy::contains(std::array<StringRef, 2>({"QObject", "QWidget"}), baseClassName)) {
// This is fine, QObject and QWidget eventFilter() don't do anything
return;
}
Stmt *body = method->getBody();
std::vector<ReturnStmt*> returns;
- HierarchyUtils::getChilds<ReturnStmt>(body, /*by-ref*/returns);
+ clazy::getChilds<ReturnStmt>(body, /*by-ref*/returns);
for (ReturnStmt *returnStmt : returns) {
- Stmt *maybeBoolExpr = clazy_std::childAt(returnStmt, 0);
+ Stmt *maybeBoolExpr = clazy::childAt(returnStmt, 0);
if (!maybeBoolExpr)
continue;
auto boolExpr = dyn_cast<CXXBoolLiteralExpr>(maybeBoolExpr);
if (!boolExpr || boolExpr->getValue()) // if getValue() is true that's a return true, which is fine
continue;
- emitWarning(returnStmt->getLocStart(), "Return " + baseClassName + "::" + methodName + "() instead of false");
+ emitWarning(getLocStart(returnStmt), "Return " + baseClassName + "::" + methodName + "() instead of false");
}
}
-
-REGISTER_CHECK("base-class-event", BaseClassEvent, CheckLevel2)