Skip to content

Commit 7aa2491

Browse files
NuriAmariNuri Amari
andauthored
[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@fb.com>
1 parent 5f5faf4 commit 7aa2491

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def err_ast_file_out_of_date : Error<
6262
"%select{PCH|module|AST}0 file '%1' is out of date and "
6363
"needs to be rebuilt%select{|: %3}2">, DefaultFatal;
6464
def err_ast_file_invalid : Error<
65-
"file '%1' is not a valid precompiled %select{PCH|module|AST}0 file">, DefaultFatal;
65+
"file '%1' is not a valid precompiled %select{PCH|module|AST}0 file: %2">, DefaultFatal;
6666
def note_module_file_imported_by : Note<
6767
"imported by %select{|module '%2' in }1'%0'">;
6868
def err_module_file_not_module : Error<

clang/test/Modules/explicit-build.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
// RUN: -fmodule-file=%t/not.pcm \
162162
// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s
163163
//
164-
// CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file
164+
// CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file: file too small to contain AST file magic
165165

166166
// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
167167
// RUN: -fmodule-file=%t/nonexistent.pcm \

0 commit comments

Comments
 (0)