]> granicus.if.org Git - clang/commitdiff
[Modules] When things go horribly wrong when reading a module, point at the module...
authorDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 22:15:13 +0000 (22:15 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 22:15:13 +0000 (22:15 +0000)
Sometimes people hack on their system headers. In such cases, they'll
need to delete their module cache, but may not know where it is. Add a
note to show them where it is.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181638 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSerializationKinds.td
lib/Serialization/ASTReader.cpp

index 1b45b10c1221e5ee8df3eb88b65a20ffd5e923df..9f630ae5c1c42b62c9523d7808ae604c87901edb 100644 (file)
@@ -14,7 +14,7 @@ def err_fe_unable_to_read_pch_file : Error<
 def err_fe_not_a_pch_file : Error<
     "input is not a PCH file: '%0'">;
 def err_fe_pch_malformed : Error<
-    "malformed or corrupted PCH file: '%0'">, DefaultFatal;
+    "malformed or corrupted AST file: '%0'">, DefaultFatal;
 def err_fe_pch_malformed_block : Error<
     "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
@@ -22,6 +22,8 @@ def err_fe_pch_file_modified : Error<
     DefaultFatal;
 def err_fe_pch_file_overridden : Error<
     "file '%0' from the precompiled header has been overridden">;
+def note_module_cache_path : Note<
+    "after modifying system headers, please delete the module cache at '%0'">;
 
 def err_pch_targetopt_mismatch : Error<
     "PCH file was compiled for the %0 '%1' but the current translation "
index 4a1ad260e3296b173bc7a443deef06b6706a4c2c..17f01380ed04ea7696beea6f4fd2a4985a32a13b 100644 (file)
@@ -759,6 +759,10 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
 
 void ASTReader::Error(StringRef Msg) {
   Error(diag::err_fe_pch_malformed, Msg);
+  if (Context.getLangOpts().Modules && !Diags.isDiagnosticInFlight()) {
+    Diag(diag::note_module_cache_path)
+      << PP.getHeaderSearchInfo().getModuleCachePath();
+  }
 }
 
 void ASTReader::Error(unsigned DiagID,
@@ -1715,6 +1719,10 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
          )) {
       if (Complain) {
         Error(diag::err_fe_pch_file_modified, Filename, F.FileName);
+        if (Context.getLangOpts().Modules && !Diags.isDiagnosticInFlight()) {
+          Diag(diag::note_module_cache_path)
+            << PP.getHeaderSearchInfo().getModuleCachePath();
+        }
       }
 
       IsOutOfDate = true;