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

Chris Lattner sabre at nondot.org
Mon Jul 12 12:55:30 PDT 2010


Great thanks.  I don't think it's ever valid to go past EOF.

-Chris

On Jul 12, 2010, at 11:57 AM, Argyrios Kyrtzidis wrote:

> This is correct. I just made an addition in r108175 to avoid caching repeated tok::eofs if we go past EOF.
> 
> -Argiris
> 
> On Jul 12, 2010, at 5:25 AM, Chris Lattner wrote:
> 
>> 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}}
>> +
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list