Preprocessor tweak

This fixes a minor issue where searching for the '(' to begin
a macro invocation would spill into the surrounding file.

Neil.

Index: Lex/Preprocessor.cpp

Neil Booth wrote:-

Index: Lex/Preprocessor.cpp

--- Lex/Preprocessor.cpp (revision 39996)
+++ Lex/Preprocessor.cpp (working copy)
@@ -552,14 +552,17 @@
     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.
+ // 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(); Val == 2 && i != 0; --i) {
       IncludeStackInfo &Entry = IncludeMacroStack[i-1];
       if (Entry.TheLexer)
- Val = Entry.TheLexer->isNextPPTokenLParen();
+ return false;
       else
         Val = Entry.TheMacroExpander->isNextTokenLParen();
     }

That's not quite right either. I'll repost.

Neil.

This fixes the search for opening parentheses by stopping at EOF.

Neil.

Index: Lex/Preprocessor.cpp

Thanks Neil, this is great. Some requests for future patches:

  * First, please include the patch as an attachment.
  * Please don't use tabs, use spaces instead.
  * Please include a testcase.

I'll took care of these with this one:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20070716/001309.html

Thanks Neil,

-Chris