summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2010-03-12 15:24:45 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2010-03-12 15:25:48 +0100
commit37c042703f779b654227bf04623ac718b3819d7c (patch)
tree986f8c607e6d45bd731625743bf633127ae1f544 /src/libs/cplusplus
parentb5f8d7af7f20b02bc41b77e6a730d0224b03354e (diff)
downloadqt-creator-37c042703f779b654227bf04623ac718b3819d7c.tar.gz
Take the branch when evaluating #ifndef QT_NO_XXX and QT_NO_XXX has been defined in a pro file.
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 5ec09f49aa..66d7f908e7 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -137,7 +137,7 @@ using namespace CPlusPlus;
namespace {
-bool isMacroDefined(QByteArray name, unsigned offset, Environment *env, Client *client)
+Macro *macroDefinition(QByteArray name, unsigned offset, Environment *env, Client *client)
{
Macro *m = env->resolve(name);
if (client) {
@@ -146,7 +146,7 @@ bool isMacroDefined(QByteArray name, unsigned offset, Environment *env, Client *
else
client->failedMacroDefinitionCheck(offset, name);
}
- return m != 0;
+ return m;
}
class RangeLexer
@@ -265,12 +265,12 @@ protected:
} else if (isTokenDefined()) {
++(*_lex);
if ((*_lex)->is(T_IDENTIFIER)) {
- _value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
+ _value.set_long(macroDefinition(tokenSpell(), (*_lex)->offset, env, client) != 0);
++(*_lex);
} else if ((*_lex)->is(T_LPAREN)) {
++(*_lex);
if ((*_lex)->is(T_IDENTIFIER)) {
- _value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
+ _value.set_long(macroDefinition(tokenSpell(), (*_lex)->offset, env, client) != 0);
++(*_lex);
if ((*_lex)->is(T_RPAREN)) {
++(*_lex);
@@ -1277,7 +1277,24 @@ void Preprocessor::processIfdef(bool checkUndefined,
if (testIfLevel()) {
if (tk->is(T_IDENTIFIER)) {
const QByteArray macroName = tokenSpell(*tk);
- bool value = isMacroDefined(macroName, tk->offset, env, client) || env->isBuiltinMacro(macroName);
+
+ bool value = false;
+ if (Macro *macro = macroDefinition(macroName, tk->offset, env, client)) {
+ value = true;
+
+ // the macro is a feature constraint(e.g. QT_NO_XXX)
+ if (checkUndefined && macroName.startsWith("QT_NO_")) {
+ if (macro->fileName() == QLatin1String("<configuration>")) {
+ // and it' defined in a pro file (e.g. DEFINES += QT_NO_QOBJECT)
+
+ value = false; // take the branch
+ }
+ }
+
+ } else if (env->isBuiltinMacro(macroName)) {
+ value = true;
+ }
+
if (checkUndefined)
value = ! value;