MacroExpander: bump expansionCount before peeking for "("
BUG=658555
Change-Id: I578b8aff37a116fd7b2b387388311a27bb8a2809
Reviewed-on: https://chromium-review.googlesource.com/403848
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/preprocessor/MacroExpander.cpp b/src/compiler/preprocessor/MacroExpander.cpp
index f38b396..25dc741 100644
--- a/src/compiler/preprocessor/MacroExpander.cpp
+++ b/src/compiler/preprocessor/MacroExpander.cpp
@@ -87,10 +87,15 @@
token->setExpansionDisabled(true);
break;
}
+
+ // Bump the expansion count before peeking if the next token is a '('
+ // otherwise there could be a #undef of the macro before the next token.
+ macro.expansionCount++;
if ((macro.type == Macro::kTypeFunc) && !isNextTokenLeftParen())
{
// If the token immediately after the macro name is not a '(',
// this macro should not be expanded.
+ macro.expansionCount--;
break;
}
@@ -157,8 +162,6 @@
ASSERT(identifier.type == Token::IDENTIFIER);
ASSERT(identifier.text == macro.name);
- macro.expansionCount++;
-
std::vector<Token> replacements;
if (!expandMacro(macro, identifier, &replacements))
return false;