]> granicus.if.org Git - clang/commitdiff
Make isBeforeInTranslationUnit consistent in the face of failures to get a valid...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 24 May 2013 23:47:43 +0000 (23:47 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 24 May 2013 23:47:43 +0000 (23:47 +0000)
Suggested by Jordan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182695 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index a4f4f9d366e6e68534dfcc58d9ec3ac48378ecc0..dfd2a1baf4e67e3910a78a65d2a0431b6be0673d 100644 (file)
@@ -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)