summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-02 00:39:22 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-02 00:39:22 +0000
commit75f26d6c757ff525feae9d079692539850144d02 (patch)
tree2fb1702cefee53f10ab93eee2b6a4861457a50c7 /clang/lib/Basic/SourceManager.cpp
parentb3ca2060c085e9fe54b8e779801e83d8a5add67b (diff)
downloadbcm5719-llvm-75f26d6c757ff525feae9d079692539850144d02.tar.gz
bcm5719-llvm-75f26d6c757ff525feae9d079692539850144d02.zip
Teach SourceManager::getPresumedLoc() how to fail gracefully if getLineNumber/getColumnNumber fail
llvm-svn: 117990
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 8564a76feb1..7127e800186 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1058,8 +1058,14 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
Filename = C->Entry->getName();
else
Filename = C->getBuffer(Diag, *this)->getBufferIdentifier();
- unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second);
- unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second);
+ bool Invalid = false;
+ unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second, &Invalid);
+ if (Invalid)
+ return PresumedLoc();
+ unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second, &Invalid);
+ if (Invalid)
+ return PresumedLoc();
+
SourceLocation IncludeLoc = FI.getIncludeLoc();
// If we have #line directives in this file, update and overwrite the physical
OpenPOWER on IntegriCloud