]> granicus.if.org Git - clang/commitdiff
The PreExpArgTokens array is indexed with an argument #,
authorChris Lattner <sabre@nondot.org>
Mon, 28 Dec 2009 06:17:16 +0000 (06:17 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 28 Dec 2009 06:17:16 +0000 (06:17 +0000)
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

lib/Lex/MacroArgs.cpp
lib/Lex/MacroArgs.h
lib/Lex/TokenLexer.cpp

index c2cf623317e3d7e8428dbda5e120b74fb0d204c2..4883898e3cd0826461b9aba2b36630b9f49f8281 100644 (file)
@@ -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;
 
index fa040c7a4d6f5273a5e3b85c32765c6b596ea393..6ff4856b4e1c03183f618c2945427d80440544dc 100644 (file)
@@ -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.
index 1083f6312763fce51c23fea17d78427a5e992008..5d95eb39c89e614ea187b3b326018df7a824f82e 100644 (file)
@@ -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.