Teach SourceManager::getSLocEntry() that it can fail due to problems
during deserialization from a precompiled header, and update all of
its callers to note when this problem occurs and recover (more)
gracefully. Fixes <rdar://problem/9119249>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129839 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index dc74cd3..90d9881 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2773,8 +2773,9 @@
// Check that the FileID is invalid on the instantiation location.
// This can manifest in invalid code.
FileID fileID = SM.getFileID(InstLoc);
- const SrcMgr::SLocEntry &sloc = SM.getSLocEntry(fileID);
- if (!sloc.isFile()) {
+ bool Invalid = false;
+ const SrcMgr::SLocEntry &sloc = SM.getSLocEntry(fileID, &Invalid);
+ if (!sloc.isFile() || Invalid) {
createNullLocation(file, line, column, offset);
return;
}