summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/pp-engine.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-03-03 16:56:55 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-03-03 16:56:55 +0100
commit1d75990667489dbbe216b50f7c9eabc32db8eced (patch)
tree2057a1f886a0fb450d4be04bea1905dbcad54ecd /src/libs/cplusplus/pp-engine.cpp
parentb316939dfff4cda2adc52c7bb40f44e3b8276c80 (diff)
downloadqt-creator-1d75990667489dbbe216b50f7c9eabc32db8eced.tar.gz
Introduced processObjectLikeMacro().
Diffstat (limited to 'src/libs/cplusplus/pp-engine.cpp')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp62
1 files changed, 36 insertions, 26 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 83b0d4191c..c9295c9424 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -748,34 +748,11 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
else {
if (! m->isFunctionLike()) {
- QByteArray tmp;
- expandObjectLikeMacro(identifierToken, spell, m, &tmp);
-
- if (_dot->isNot(T_LPAREN)) {
- _result->append(tmp);
+ if (0 == (m = processObjectLikeMacro(identifierToken, spell, m)))
continue;
- } else {
- m = 0; // reset the active the macro
-
- pushState(createStateFromSource(tmp));
-
- if (_dot->is(T_IDENTIFIER)) {
- const QByteArray id = tokenSpell(*_dot);
-
- if (Macro *macro = env->resolve(id)) {
- if (macro->isFunctionLike())
- m = macro;
- }
- }
-
- popState();
-
- if (! m) {
- _result->append(tmp);
- continue;
- }
- }
+ // the macro expansion generated something that looks like
+ // a function-like macro.
}
// `m' is function-like macro.
@@ -817,6 +794,39 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
_result = previousResult;
}
+Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken,
+ const QByteArray &spell,
+ Macro *m)
+{
+ QByteArray tmp;
+ expandObjectLikeMacro(identifierToken, spell, m, &tmp);
+
+ if (_dot->is(T_LPAREN)) {
+ // check if the expension generated a function-like macro.
+
+ m = 0; // reset the active the macro
+
+ pushState(createStateFromSource(tmp));
+
+ if (_dot->is(T_IDENTIFIER)) {
+ const QByteArray id = tokenSpell(*_dot);
+
+ if (Macro *macro = env->resolve(id)) {
+ if (macro->isFunctionLike())
+ m = macro;
+ }
+ }
+
+ popState();
+
+ if (m != 0)
+ return m;
+ }
+
+ _result->append(tmp);
+ return 0;
+}
+
void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
const QByteArray &spell,
Macro *m,