aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-28 06:17:16 +0000
committerChris Lattner <sabre@nondot.org>2009-12-28 06:17:16 +0000
commitf5809a7b76fd5a86ae737d9b525a1eddb9339ee7 (patch)
tree4a2f95bce7d045733ee06759b8975b6a961c39fe /lib/Lex
parent3521d01aed2f55b66c7ce2ad47541a9974079699 (diff)
The PreExpArgTokens array is indexed with an argument #,
not a token number. Fix the reserve logic to get the right amount of space. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/MacroArgs.cpp11
-rw-r--r--lib/Lex/MacroArgs.h2
-rw-r--r--lib/Lex/TokenLexer.cpp2
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.