[cfe-commits] r92202 - in /cfe/trunk/lib/Lex: MacroArgs.cpp MacroArgs.h TokenLexer.cpp
Chris Lattner
sabre at nondot.org
Sun Dec 27 22:17:16 PST 2009
Author: lattner
Date: Mon Dec 28 00:17:16 2009
New Revision: 92202
URL: http://llvm.org/viewvc/llvm-project?rev=92202&view=rev
Log:
The PreExpArgTokens array is indexed with an argument #,
not a token number. Fix the reserve logic to get the right
amount of space.
Modified:
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/lib/Lex/MacroArgs.h
cfe/trunk/lib/Lex/TokenLexer.cpp
Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=92202&r1=92201&r2=92202&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Mon Dec 28 00:17:16 2009
@@ -132,13 +132,14 @@
/// 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;
Modified: cfe/trunk/lib/Lex/MacroArgs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.h?rev=92202&r1=92201&r2=92202&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/MacroArgs.h (original)
+++ cfe/trunk/lib/Lex/MacroArgs.h Mon Dec 28 00:17:16 2009
@@ -82,7 +82,7 @@
/// 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.
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=92202&r1=92201&r2=92202&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Mon Dec 28 00:17:16 2009
@@ -175,7 +175,7 @@
// 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.
More information about the cfe-commits
mailing list