From 5fd822c28369d6c2c530816e8bda1ffd135b807f Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 24 May 2013 23:47:43 +0000 Subject: [PATCH] Make isBeforeInTranslationUnit consistent in the face of failures to get a valid FileID. Suggested by Jordan. llvm-svn: 182695 --- clang/lib/Basic/SourceManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index a4f4f9d366e6..dfd2a1baf4e6 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -2039,8 +2039,11 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, std::pair LOffs = getDecomposedLoc(LHS); std::pair 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)