From d3555ae09f3d31f7cac84a85d3915459fd34c657 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 15 Jun 2009 04:35:16 +0000 Subject: [PATCH] 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 --- lib/Frontend/PCHReader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 87fc8394c8..8ea917c3e3 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -804,9 +804,16 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) { 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], -- 2.50.1