aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-16 20:46:42 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-16 20:46:42 +0000
commita543016fe07030f695d6d56fd22c8c8da617e0d7 (patch)
tree4f007b8435178d3d477774b9f2a69f4b70a1badf /lib/Lex/Preprocessor.cpp
parent47a3fcd4afe122b23f9e7b6148f147bfa460cfe8 (diff)
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
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp5
1 files changed, 3 insertions, 2 deletions
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;