From a543016fe07030f695d6d56fd22c8c8da617e0d7 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 16 Mar 2010 20:46:42 +0000 Subject: Audit all callers of SourceManager::getCharacterData(); update some of them to recover more gracefully on failure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98672 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/Preprocessor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Lex/Preprocessor.cpp') 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; -- cgit v1.2.3-70-g09d2