From ca7cc122cb765a7596ccece38530e3aaef8b8d43 Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Tue, 3 Mar 2009 17:06:42 +0100 Subject: [PATCH] Simplified Preprocessor::preprocess() --- src/libs/cplusplus/pp-engine.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index c4b806ec2ce..cbc2659ce44 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -741,12 +741,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour continue; } - Macro *m = env->resolve(spell); - - if (! m) - _result->append(spell); - - else { + if (Macro *m = env->resolve(spell)) { if (! m->isFunctionLike()) { if (0 == (m = processObjectLikeMacro(identifierToken, spell, m))) continue; @@ -757,21 +752,18 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour // `m' is function-like macro. - // collect the actual arguments - if (_dot->isNot(T_LPAREN)) { - // ### warnng expected T_LPAREN - _result->append(m->name()); - continue; - } - - skipActualArguments(); - - if (_dot->isNot(T_RPAREN)) - _result->append(spell); + if (_dot->is(T_LPAREN)) { + skipActualArguments(); - else - expandFunctionLikeMacro(identifierToken, m); + if (_dot->is(T_RPAREN)) { + expandFunctionLikeMacro(identifierToken, m); + continue; + } + } } + + // it's not a function or object-like macro. + _result->append(spell); } } } @@ -786,6 +778,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour void Preprocessor::skipActualArguments() { int count = 0; + while (_dot->isNot(T_EOF_SYMBOL)) { if (_dot->is(T_LPAREN)) ++count; -- GitLab