[cfe-dev] Preprocessor tweak
Neil Booth
neil at daikokuya.co.uk
Wed Jul 18 15:57:15 PDT 2007
This fixes the search for opening parentheses by stopping at EOF.
Neil.
Index: Lex/Preprocessor.cpp
===================================================================
--- Lex/Preprocessor.cpp (revision 40021)
+++ Lex/Preprocessor.cpp (working copy)
@@ -552,16 +552,23 @@
Val = CurLexer->isNextPPTokenLParen();
else
Val = CurMacroExpander->isNextTokenLParen();
-
+
if (Val == 2) {
- // If we ran off the end of the lexer or macro expander, walk the include
- // stack, looking for whatever will return the next token.
- for (unsigned i = IncludeMacroStack.size(); Val == 2 && i != 0; --i) {
+ // We have run off the end. If it's a source file we don't
+ // examine enclosing ones (C99 5.1.1.2p4). Otherwise walk up the
+ // macro stack.
+ if (CurLexer)
+ return false;
+ for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
IncludeStackInfo &Entry = IncludeMacroStack[i-1];
if (Entry.TheLexer)
Val = Entry.TheLexer->isNextPPTokenLParen();
else
Val = Entry.TheMacroExpander->isNextTokenLParen();
+ if (Val != 2)
+ break;
+ if (Entry.TheLexer)
+ return false;
}
}
More information about the cfe-dev
mailing list