aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scanner
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-12-02 17:06:36 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2013-12-02 17:29:56 +0100
commit0ef833421303dcd4802412cec0a3e6b0f9d55c4c (patch)
tree9b65729b6f50bc513f40af32f9ec92419e45c763 /src/plugins/scanner
parent2f2c26f8275b8336f44e441bcfaa7c97207e644b (diff)
check for defines in C++ scanner
We must ignore Q_OBJECT, Q_PLUGIN_METADATA and friends, if there's a "define" identifier in front of them. Change-Id: Ica198e16f1ab5855db490fd67967d31d7b3b1a06 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/plugins/scanner')
-rw-r--r--src/plugins/scanner/cpp/cppscanner.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/plugins/scanner/cpp/cppscanner.cpp b/src/plugins/scanner/cpp/cppscanner.cpp
index 15fe4c9c2..c87074876 100644
--- a/src/plugins/scanner/cpp/cppscanner.cpp
+++ b/src/plugins/scanner/cpp/cppscanner.cpp
@@ -112,11 +112,13 @@ static void scanCppFile(void *opaq, Lexer &yylex, bool scanForFileTags, bool sca
{
const QLatin1Literal includeLiteral("include");
const QLatin1Literal importLiteral("import");
+ const QLatin1Literal defineLiteral("define");
const QLatin1Literal qobjectLiteral("Q_OBJECT");
const QLatin1Literal qgadgetLiteral("Q_GADGET");
const QLatin1Literal pluginMetaDataLiteral("Q_PLUGIN_METADATA");
Opaq *opaque = static_cast<Opaq *>(opaq);
Token tk;
+ Token oldTk;
ScanResult scanResult;
yylex(&tk);
@@ -148,22 +150,29 @@ static void scanCppFile(void *opaq, Lexer &yylex, bool scanForFileTags, bool sca
}
} else if (tk.is(T_IDENTIFIER)) {
if (scanForFileTags) {
- const char *identifier = opaque->fileContent + tk.begin();
- if (equals(identifier, qobjectLiteral)
- || equals(identifier, qgadgetLiteral))
- {
- opaque->hasQObjectMacro = true;
- } else if (opaque->fileType == Opaq::FT_HPP
- && equals(identifier, pluginMetaDataLiteral))
- {
- opaque->hasPluginMetaDataMacro = true;
+ if (oldTk.is(T_IDENTIFIER)
+ && equals(opaque->fileContent + oldTk.begin(), defineLiteral)) {
+ // Someone was clever and redefined Q_OBJECT or Q_PLUGIN_METADATA.
+ // Example: iplugin.h in Qt Creator.
+ } else {
+ const char *identifier = opaque->fileContent + tk.begin();
+ if (equals(identifier, qobjectLiteral)
+ || equals(identifier, qgadgetLiteral))
+ {
+ opaque->hasQObjectMacro = true;
+ } else if (opaque->fileType == Opaq::FT_HPP
+ && equals(identifier, pluginMetaDataLiteral))
+ {
+ opaque->hasPluginMetaDataMacro = true;
+ }
+ if (!scanForDependencies && opaque->hasQObjectMacro
+ && (opaque->fileType == Opaq::FT_CPP || opaque->hasPluginMetaDataMacro))
+ break;
}
- if (!scanForDependencies && opaque->hasQObjectMacro
- && (opaque->fileType == Opaq::FT_CPP || opaque->hasPluginMetaDataMacro))
- break;
}
}
+ oldTk = tk;
yylex(&tk);
}
}