forked from qt-creator/qt-creator
		
	Introduced processObjectLikeMacro().
This commit is contained in:
		| @@ -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, | ||||
|   | ||||
| @@ -128,9 +128,14 @@ private: | ||||
|     QByteArray tokenText(const CPlusPlus::Token &token) const; // does a deep copy | ||||
|  | ||||
|     void processNewline(); | ||||
|  | ||||
|     void processSkippingBlocks(bool skippingBlocks, | ||||
|                                TokenIterator dot, TokenIterator lastToken); | ||||
|  | ||||
|     Macro *processObjectLikeMacro(TokenIterator identifierToken, | ||||
|                                   const QByteArray &spell, | ||||
|                                   Macro *m); | ||||
|  | ||||
|     void processDirective(TokenIterator dot, TokenIterator lastToken); | ||||
|     void processInclude(bool skipCurrentPath, | ||||
|                         TokenIterator dot, TokenIterator lastToken, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user