diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/MacroArgs.cpp | 11 | ||||
-rw-r--r-- | lib/Lex/MacroArgs.h | 2 | ||||
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp index c2cf623317..4883898e3c 100644 --- a/lib/Lex/MacroArgs.cpp +++ b/lib/Lex/MacroArgs.cpp @@ -132,13 +132,14 @@ bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok, /// getPreExpArgument - Return the pre-expanded form of the specified /// argument. const std::vector<Token> & -MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) { - assert(Arg < NumUnexpArgTokens && "Invalid argument number!"); +MacroArgs::getPreExpArgument(unsigned Arg, const MacroInfo *MI, + Preprocessor &PP) { + assert(Arg < MI->getNumArgs() && "Invalid argument number!"); // If we have already computed this, return it. - if (PreExpArgTokens.empty()) - PreExpArgTokens.resize(NumUnexpArgTokens); - + if (PreExpArgTokens.size() < MI->getNumArgs()) + PreExpArgTokens.resize(MI->getNumArgs()); + std::vector<Token> &Result = PreExpArgTokens[Arg]; if (!Result.empty()) return Result; diff --git a/lib/Lex/MacroArgs.h b/lib/Lex/MacroArgs.h index fa040c7a4d..6ff4856b4e 100644 --- a/lib/Lex/MacroArgs.h +++ b/lib/Lex/MacroArgs.h @@ -82,7 +82,7 @@ public: /// getPreExpArgument - Return the pre-expanded form of the specified /// argument. const std::vector<Token> & - getPreExpArgument(unsigned Arg, Preprocessor &PP); + getPreExpArgument(unsigned Arg, const MacroInfo *MI, Preprocessor &PP); /// getStringifiedArgument - Compute, cache, and return the specified argument /// that has been 'stringified' as required by the # operator. diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 1083f63127..5d95eb39c8 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -175,7 +175,7 @@ void TokenLexer::ExpandFunctionArguments() { // avoids some work in common cases. const Token *ArgTok = ActualArgs->getUnexpArgument(ArgNo); if (ActualArgs->ArgNeedsPreexpansion(ArgTok, PP)) - ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, PP)[0]; + ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, Macro, PP)[0]; else ResultArgToks = ArgTok; // Use non-preexpanded tokens. |