forked from qt-creator/qt-creator
Preprocessor: Handle variadic arguments (__VA_ARGS__).
Change-Id: I69aa6c5e01ea97a4413f77f20ebbb4d4beb971aa Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
f0b122e3d2
commit
ffd58c577a
@@ -78,7 +78,8 @@ QString Macro::decoratedName() const
|
||||
text += QLatin1String(", ");
|
||||
else
|
||||
first = false;
|
||||
text += QString::fromUtf8(formal.constData(), formal.size());
|
||||
if (formal != "__VA_ARGS__")
|
||||
text += QString::fromUtf8(formal.constData(), formal.size());
|
||||
}
|
||||
if (f._variadic)
|
||||
text += QLatin1String("...");
|
||||
|
||||
@@ -1178,18 +1178,22 @@ void Preprocessor::processDefine(TokenIterator firstToken, TokenIterator lastTok
|
||||
macro.setLength(endOfToken(lastToken[- 1]) - startOfToken(*firstToken));
|
||||
++tk; // skip T_IDENTIFIER
|
||||
|
||||
bool hasIdentifier = false;
|
||||
if (tk->is(T_LPAREN) && ! tk->f.whitespace) {
|
||||
// a function-like macro definition
|
||||
macro.setFunctionLike(true);
|
||||
|
||||
++tk; // skip T_LPAREN
|
||||
if (tk->is(T_IDENTIFIER)) {
|
||||
hasIdentifier = true;
|
||||
macro.addFormal(tokenText(*tk));
|
||||
++tk; // skip T_IDENTIFIER
|
||||
while (tk->is(T_COMMA)) {
|
||||
++tk;// skip T_COMMA
|
||||
if (tk->isNot(T_IDENTIFIER))
|
||||
if (tk->isNot(T_IDENTIFIER)) {
|
||||
hasIdentifier = false;
|
||||
break;
|
||||
}
|
||||
macro.addFormal(tokenText(*tk));
|
||||
++tk; // skip T_IDENTIFIER
|
||||
}
|
||||
@@ -1197,6 +1201,8 @@ void Preprocessor::processDefine(TokenIterator firstToken, TokenIterator lastTok
|
||||
|
||||
if (tk->is(T_DOT_DOT_DOT)) {
|
||||
macro.setVariadic(true);
|
||||
if (!hasIdentifier)
|
||||
macro.addFormal("__VA_ARGS__");
|
||||
++tk; // skip T_DOT_DOT_DOT
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user