[cfe-commits] r108124 - in /cfe/trunk: lib/Lex/PPCaching.cpp test/Parser/backtrack-crash.cpp

Chris Lattner sabre at nondot.org
Sun Jul 11 21:25:32 PDT 2010


Author: lattner
Date: Sun Jul 11 23:25:32 2010
New Revision: 108124

URL: http://llvm.org/viewvc/llvm-project?rev=108124&view=rev
Log:
we do in fact have to cache the EOF token returned by the preprocessor.
In the case of backtracking, the cached token lexer will be the only 
lexer on the stack, without this the token stack will be empty and EOF
won't be returned.

This fixes PR7072.


Added:
    cfe/trunk/test/Parser/backtrack-crash.cpp
Modified:
    cfe/trunk/lib/Lex/PPCaching.cpp

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=108124&r1=108123&r2=108124&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Sun Jul 11 23:25:32 2010
@@ -60,13 +60,10 @@
     return;
   }
 
-  // We should cache the lexed token.
-
+  // Cache the lexed token.
   EnterCachingLexMode();
-  if (Result.isNot(tok::eof)) {
-    CachedTokens.push_back(Result);
-    ++CachedLexPos;
-  }
+  CachedTokens.push_back(Result);
+  ++CachedLexPos;
 }
 
 void Preprocessor::EnterCachingLexMode() {

Added: cfe/trunk/test/Parser/backtrack-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/backtrack-crash.cpp?rev=108124&view=auto
==============================================================================
--- cfe/trunk/test/Parser/backtrack-crash.cpp (added)
+++ cfe/trunk/test/Parser/backtrack-crash.cpp Sun Jul 11 23:25:32 2010
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// PR7072
+()( // expected-error {{expected unqualified-id}}
+





More information about the cfe-commits mailing list