[clang] 7aa2491 - [clang] Expand invalid PCM diagnostic (#69489)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 18 16:19:59 PDT 2023


Author: Nuri Amari
Date: 2023-10-18T16:19:54-07:00
New Revision: 7aa24915cb66c51bab7c15854877136930d3ed17

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

LOG: [clang] Expand invalid PCM diagnostic (#69489)

Summary:

When a PCM file is loaded, it can go wrong in various ways. The current
diagnostic only produces the name of the malformed PCM, not why it is
malformed. Expand the diagnostic to display what went wrong!

There is only one call site for this diagnostic, and it already passes
the error message:


https://github.com/llvm/llvm-project/blob/main/clang/lib/Serialization/ASTReader.cpp#L4763-L4764

Test Plan:

The modified LIT test.

---------

Co-authored-by: Nuri Amari <nuriamari at fb.com>

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticSerializationKinds.td
    clang/test/Modules/explicit-build.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index a1ae23a62802104..3cb2cd32cf6d09f 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -62,7 +62,7 @@ def err_ast_file_out_of_date : Error<
   "%select{PCH|module|AST}0 file '%1' is out of date and "
   "needs to be rebuilt%select{|: %3}2">, DefaultFatal;
 def err_ast_file_invalid : Error<
-  "file '%1' is not a valid precompiled %select{PCH|module|AST}0 file">, DefaultFatal;
+  "file '%1' is not a valid precompiled %select{PCH|module|AST}0 file: %2">, DefaultFatal;
 def note_module_file_imported_by : Note<
   "imported by %select{|module '%2' in }1'%0'">;
 def err_module_file_not_module : Error<

diff  --git a/clang/test/Modules/explicit-build.cpp b/clang/test/Modules/explicit-build.cpp
index 16eb604708c9d83..7fca0082ea28add 100644
--- a/clang/test/Modules/explicit-build.cpp
+++ b/clang/test/Modules/explicit-build.cpp
@@ -161,7 +161,7 @@
 // RUN:            -fmodule-file=%t/not.pcm \
 // RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s
 //
-// CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file
+// CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file: file too small to contain AST file magic
 
 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
 // RUN:            -fmodule-file=%t/nonexistent.pcm \


        


More information about the cfe-commits mailing list