[cfe-commits] r156043 - /cfe/trunk/lib/Lex/LiteralSupport.cpp
Argyrios Kyrtzidis
kyrtzidis at apple.com
Thu May 3 10:51:53 PDT 2012
On May 2, 2012, at 6:56 PM, Eli Friedman wrote:
> On Wed, May 2, 2012 at 6:01 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>> Author: akirtzidis
>> Date: Wed May 2 20:01:56 2012
>> New Revision: 156043
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=156043&view=rev
>> Log:
>> In StringLiteralParser::init(), fail gracefully if the string is
>> not as we expect; it may be due to racing issue of a file coming from PCH
>> changing after the PCH is loaded.
>>
>> rdar://11353109
>>
>> Modified:
>> cfe/trunk/lib/Lex/LiteralSupport.cpp
>>
>> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=156043&r1=156042&r2=156043&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
>> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed May 2 20:01:56 2012
>> @@ -1192,7 +1192,12 @@
>> if (DiagnoseBadString(StringToks[i]))
>> hadError = true;
>> } else {
>> - assert(ThisTokBuf[0] == '"' && "Expected quote, lexer broken?");
>> + if (ThisTokBuf[0] != '"') {
>> + // The file may have come from PCH and then changed after loading the
>> + // PCH; Fail gracefully.
>> + hadError = true;
>> + continue;
>> + }
>> ++ThisTokBuf; // skip "
>
> If we're calling the literal parser from Sema (or anywhere else that
> expects diagnostics), this recovery won't work correctly... setting
> hadError without actually printing a diagnostic will lead to an
> invalid AST, which is likely to explode later on.
In r156081, thanks for reviewing!
>
> -Eli
More information about the cfe-commits
mailing list