From: Argyrios Kyrtzidis Date: Thu, 3 May 2012 01:01:56 +0000 (+0000) Subject: In StringLiteralParser::init(), fail gracefully if the string is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07a075870110a8376ddc1cd09412a0ec00987153;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156043 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index c1d228b879..b01fc1f8c6 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -1192,7 +1192,12 @@ void StringLiteralParser::init(const Token *StringToks, unsigned NumStringToks){ 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 " // Check if this is a pascal string