]> granicus.if.org Git - clang/commitdiff
If PCH refers to a file that doesn't exist anymore, emit a nice error
authorChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 04:35:16 +0000 (04:35 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 04:35:16 +0000 (04:35 +0000)
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

index 87fc8394c8db594075547c754d621380c88a6561..8ea917c3e347eba4ef8febcc99dacfb91c37c5e0 100644 (file)
@@ -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],