summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-05-24 23:47:43 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-05-24 23:47:43 +0000
commitecdbbfa1cd26c0b0f322366973c7dae51c1e83df (patch)
treec0b265a5113fd94b41f36b23a516715a5b844a10 /lib/Basic/SourceManager.cpp
parentb07d448a625d7399d871079d55491c6b10316e6f (diff)
downloadclang-ecdbbfa1cd26c0b0f322366973c7dae51c1e83df.tar.gz
Make isBeforeInTranslationUnit consistent in the face of failures to get a valid FileID.
Suggested by Jordan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r--lib/Basic/SourceManager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index a4f4f9d366..dfd2a1baf4 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -2039,8 +2039,11 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
std::pair<FileID, unsigned> LOffs = getDecomposedLoc(LHS);
std::pair<FileID, unsigned> ROffs = getDecomposedLoc(RHS);
+ // getDecomposedLoc may have failed to return a valid FileID because, e.g. it
+ // is a serialized one referring to a file that was removed after we loaded
+ // the PCH.
if (LOffs.first.isInvalid() || ROffs.first.isInvalid())
- return false;
+ return LOffs.first.isInvalid();
// If the source locations are in the same file, just compare offsets.
if (LOffs.first == ROffs.first)