[clang] a2f2c2f - Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 13 13:23:14 PST 2020


Author: Duncan P. N. Exon Smith
Date: 2020-11-13T16:23:04-05:00
New Revision: a2f2c2f3a46351bc5478acd290258d318af2cd88

URL: https://github.com/llvm/llvm-project/commit/a2f2c2f3a46351bc5478acd290258d318af2cd88
DIFF: https://github.com/llvm/llvm-project/commit/a2f2c2f3a46351bc5478acd290258d318af2cd88.diff

LOG: Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

Clean up the logic for `err_fe_{pch,module,ast}_file_modified` to use a
`select` like other ASTReader diagnostics. There should be no
functionality change here, just a cleanup.

Differential Revision: https://reviews.llvm.org/D91367

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index 2720e85df6f5..ce48833a8703 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -17,17 +17,10 @@ def err_fe_pch_malformed : Error<
     "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<
-    "file '%0' has been modified since the precompiled header '%1' was built"
-    ": %select{size|mtime|content}2 changed">,
-    DefaultFatal;
-def err_fe_module_file_modified : Error<
-    "file '%0' has been modified since the module file '%1' was built"
-    ": %select{size|mtime|content}2 changed">,
-    DefaultFatal;
 def err_fe_ast_file_modified : Error<
-    "file '%0' has been modified since the AST file '%1' was built"
-    ": %select{size|mtime|content}2 changed">,
+    "file '%0' has been modified since the "
+    "%select{precompiled header|module file|AST file}1 '%2' was built"
+    ": %select{size|mtime|content}3 changed">,
     DefaultFatal;
 def err_fe_pch_file_overridden : Error<
     "file '%0' from the precompiled header has been overridden">;

diff  --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 31831b7a5bfe..600454399f68 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2397,17 +2397,9 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
 
       // The top-level PCH is stale.
       StringRef TopLevelPCHName(ImportStack.back()->FileName);
-      unsigned DiagnosticKind =
-          moduleKindForDiagnostic(ImportStack.back()->Kind);
-      if (DiagnosticKind == 0)
-        Diag(diag::err_fe_pch_file_modified)
-            << Filename << TopLevelPCHName << FileChange;
-      else if (DiagnosticKind == 1)
-        Diag(diag::err_fe_module_file_modified)
-            << Filename << TopLevelPCHName << FileChange;
-      else
-        Diag(diag::err_fe_ast_file_modified)
-            << Filename << TopLevelPCHName << FileChange;
+      Diag(diag::err_fe_ast_file_modified)
+          << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+          << TopLevelPCHName << FileChange;
 
       // Print the import stack.
       if (ImportStack.size() > 1) {


        


More information about the cfe-commits mailing list