diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
| commit | 4a37f65f1c1373c9956d118a012943de2f61edb0 (patch) | |
| tree | 52aebaff3a47b97dbac434530524c30967468412 /lib/Lex/LiteralSupport.cpp | |
| parent | a16e9ac1f192503038f49e0c52edd7dcb2ce023a (diff) | |
Notes
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
| -rw-r--r-- | lib/Lex/LiteralSupport.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 004e6755e5f5d..1cfa0e374506f 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -806,7 +806,14 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks, // Get the spelling of the token, which eliminates trigraphs, etc. We know // that ThisTokBuf points to a buffer that is big enough for the whole token // and 'spelled' tokens can only shrink. - unsigned ThisTokLen = PP.getSpelling(StringToks[i], ThisTokBuf); + bool StringInvalid = false; + unsigned ThisTokLen = PP.getSpelling(StringToks[i], ThisTokBuf, + &StringInvalid); + if (StringInvalid) { + hadError = 1; + continue; + } + const char *ThisTokEnd = ThisTokBuf+ThisTokLen-1; // Skip end quote. // TODO: Input character set mapping support. @@ -904,8 +911,12 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok, llvm::SmallString<16> SpellingBuffer; SpellingBuffer.resize(Tok.getLength()); + bool StringInvalid = false; const char *SpellingPtr = &SpellingBuffer[0]; - unsigned TokLen = PP.getSpelling(Tok, SpellingPtr); + unsigned TokLen = PP.getSpelling(Tok, SpellingPtr, &StringInvalid); + if (StringInvalid) { + return 0; + } assert(SpellingPtr[0] != 'L' && "Doesn't handle wide strings yet"); |
