]> granicus.if.org Git - clang/commitdiff
Enhance PTHManager::Create() to take an optional Diagnostic* argument that can be...
authorTed Kremenek <kremenek@apple.com>
Wed, 28 Jan 2009 20:49:33 +0000 (20:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 28 Jan 2009 20:49:33 +0000 (20:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63231 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
include/clang/Lex/PTHManager.h
lib/Lex/PTHLexer.cpp

index bc548e4e8b8496dfacf811a5e4150bb20acda571..fba2df13a37ad508a30143d4c29c991fcad7adae 100644 (file)
@@ -1154,7 +1154,7 @@ public:
 
     // Use PTH?
     if (!TokenCache.empty())
-      PTHMgr.reset(PTHManager::Create(TokenCache));
+      PTHMgr.reset(PTHManager::Create(TokenCache, &Diags));
     
     // Create the Preprocessor.
     llvm::OwningPtr<Preprocessor> PP(new Preprocessor(Diags, LangInfo, Target,
index b77cda1f0b7dde735791efac64bb6430454dfc05..22343e208c2771008403f318bf512dd26b1a6931 100644 (file)
@@ -29,6 +29,7 @@ namespace clang {
 
 class FileEntry;
 class PTHLexer;
+class Diagnostic;
   
 class PTHManager : public IdentifierInfoLookup {
   friend class PTHLexer;
@@ -107,7 +108,7 @@ public:
   
   /// Create - This method creates PTHManager objects.  The 'file' argument
   ///  is the name of the PTH file.  This method returns NULL upon failure.
-  static PTHManager *Create(const std::string& file);
+  static PTHManager *Create(const std::string& file, Diagnostic* Diags = 0);
 
   void setPreprocessor(Preprocessor *pp) { PP = pp; }    
   
index f9f2b21061203e497c44f1af2e44c81a83d0f595..36f509cba64813822922843ebe85aea4bf3cb232 100644 (file)
@@ -390,13 +390,20 @@ PTHManager::~PTHManager() {
   free(PerIDCache);
 }
 
-PTHManager* PTHManager::Create(const std::string& file) {
+PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
   // Memory map the PTH file.
   llvm::OwningPtr<llvm::MemoryBuffer>
   File(llvm::MemoryBuffer::getFile(file.c_str()));
   
-  if (!File)
+  if (!File) {
+    if (Diags) {
+      unsigned DiagID = Diags->getCustomDiagID(Diagnostic::Note,
+                                               "PTH file %0 could not be read");
+      Diags->Report(FullSourceLoc(), DiagID) << file;
+    }
+    
     return 0;
+  }
   
   // Get the buffer ranges and check if there are at least three 32-bit
   // words at the end of the file.