aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-05-08 21:54:05 +0100
committerSergio Martins <smartins@kde.org>2019-05-08 21:54:05 +0100
commit008cdc9d14522a56d5410a7b37e4a0a2cb3c673a (patch)
tree9e9cd809b00dc40c661368d990801d5389c47944
parent23c0a5122a6e6a7b87cb9c6513f1745c511e230e (diff)
qt-keywords: Don't warn about Q_OS_WINDOWS if Qt < 5.12.4
-rw-r--r--src/checks/level0/qt-macros.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/checks/level0/qt-macros.cpp b/src/checks/level0/qt-macros.cpp
index c886602e..d3a587cb 100644
--- a/src/checks/level0/qt-macros.cpp
+++ b/src/checks/level0/qt-macros.cpp
@@ -22,6 +22,7 @@
#include "qt-macros.h"
#include "ClazyContext.h"
#include "clazy_stl.h"
+#include "PreProcessorVisitor.h"
#include <clang/Basic/IdentifierTable.h>
#include <clang/Lex/Token.h>
@@ -34,6 +35,7 @@ QtMacros::QtMacros(const std::string &name, ClazyContext *context)
: CheckBase(name, context)
{
enablePreProcessorCallbacks();
+ context->enablePreprocessorVisitor();
}
void QtMacros::VisitMacroDefined(const Token &MacroNameTok)
@@ -52,8 +54,10 @@ void QtMacros::checkIfDef(const Token &macroNameTok, SourceLocation Loc)
if (!ii)
return;
- if (ii->getName() == "Q_OS_WINDOWS") {
- emitWarning(Loc, "Q_OS_WINDOWS is wrong, use Q_OS_WIN instead");
+ PreProcessorVisitor *preProcessorVisitor = m_context->preprocessorVisitor;
+ if (preProcessorVisitor && preProcessorVisitor->qtVersion() < 51204 && ii->getName() == "Q_OS_WINDOWS") {
+ // Q_OS_WINDOWS was introduced in 5.12.4
+ emitWarning(Loc, "Q_OS_WINDOWS was only introduced in Qt 5.12.4, use Q_OS_WIN instead");
} else if (!m_OSMacroExists && clazy::startsWith(ii->getName(), "Q_OS_")) {
emitWarning(Loc, "Include qglobal.h before testing Q_OS_ macros");
}