If PCH refers to a file that doesn't exist anymore, emit a nice error
like:
fatal error: could not find file '1.h' referenced by PCH file
instead of aborting with an assertion failure, PR4219
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73371 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 87fc839..8ea917c 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -804,9 +804,16 @@
return Failure;
case pch::SM_SLOC_FILE_ENTRY: {
- const FileEntry *File
- = PP.getFileManager().getFile(BlobStart, BlobStart + BlobLen);
- // FIXME: Error recovery if file cannot be found.
+ const FileEntry *File = PP.getFileManager().getFile(BlobStart,
+ BlobStart + BlobLen);
+ if (File == 0) {
+ std::string ErrorStr = "could not find file '";
+ ErrorStr.append(BlobStart, BlobLen);
+ ErrorStr += "' referenced by PCH file";
+ Error(ErrorStr.c_str());
+ return Failure;
+ }
+
FileID FID = SourceMgr.createFileID(File,
SourceLocation::getFromRawEncoding(Record[1]),
(SrcMgr::CharacteristicKind)Record[2],