diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-12 07:15:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-12 07:15:47 +0000 |
commit | cb7b1e17b63967317ab5cc55682168cf0380519a (patch) | |
tree | ae64d4fe18e56974c3aae2c99e86aa954410ccdb /lib/Basic/SourceLocation.cpp | |
parent | 8f0889ce457db51d3af1eb1245bceee272d4dc7d (diff) |
Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of
an invalid presumed location. Doing so can cause crashes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceLocation.cpp')
-rw-r--r-- | lib/Basic/SourceLocation.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp index 7412b95560..1571e2205f 100644 --- a/lib/Basic/SourceLocation.cpp +++ b/lib/Basic/SourceLocation.cpp @@ -43,6 +43,11 @@ void SourceLocation::print(llvm::raw_ostream &OS, const SourceManager &SM)const{ if (isFileID()) { PresumedLoc PLoc = SM.getPresumedLoc(*this); + + if (PLoc.isInvalid()) { + OS << "<invalid>"; + return; + } // The instantiation and spelling pos is identical for file locs. OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':' << PLoc.getColumn(); |