diff options
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/Lexer.cpp | 1 | ||||
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 7 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 5 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 6cdb96f37d..0b8b6242db 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -163,6 +163,7 @@ Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc, // Now that the lexer is created, change the start/end locations so that we // just lex the subsection of the file that we want. This is lexing from a // scratch buffer. + bool Invalid = false; const char *StrData = SM.getCharacterData(SpellingLoc); L->BufferPtr = StrData; diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index cddc6cff72..3bf3fc4af9 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -204,7 +204,12 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // to spell an i/e in a strange way that is another letter. Skipping this // allows us to avoid looking up the identifier info for #define/#undef and // other common directives. - const char *RawCharData = SourceMgr.getCharacterData(Tok.getLocation()); + bool Invalid = false; + const char *RawCharData = SourceMgr.getCharacterData(Tok.getLocation(), + &Invalid); + if (Invalid) + return; + char FirstChar = RawCharData[0]; if (FirstChar >= 'a' && FirstChar <= 'z' && FirstChar != 'i' && FirstChar != 'e') { diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 880ff43c66..a86799aafa 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -428,10 +428,11 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart, // Figure out how many physical characters away the specified instantiation // character is. This needs to take into consideration newlines and // trigraphs. - const char *TokPtr = SourceMgr.getCharacterData(TokStart); + bool Invalid = false; + const char *TokPtr = SourceMgr.getCharacterData(TokStart, &Invalid); // If they request the first char of the token, we're trivially done. - if (CharNo == 0 && Lexer::isObviouslySimpleCharacter(*TokPtr)) + if (Invalid || (CharNo == 0 && Lexer::isObviouslySimpleCharacter(*TokPtr))) return TokStart; unsigned PhysOffset = 0; |