[cfe-commits] r73371 - /cfe/trunk/lib/Frontend/PCHReader.cpp

Chris Lattner sabre at nondot.org
Sun Jun 14 21:35:16 PDT 2009


Author: lattner
Date: Sun Jun 14 23:35:16 2009
New Revision: 73371

URL: http://llvm.org/viewvc/llvm-project?rev=73371&view=rev
Log:
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


Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=73371&r1=73370&r2=73371&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Sun Jun 14 23:35:16 2009
@@ -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],





More information about the cfe-commits mailing list