https://github.com/NuriAmari updated https://github.com/llvm/llvm-project/pull/69489
>From 3fa795fae47d00ece00e9414a268610d3c4a6bf3 Mon Sep 17 00:00:00 2001 From: Nuri Amari <nuriam...@meta.com> Date: Fri, 22 Sep 2023 12:03:23 -0700 Subject: [PATCH 1/2] Expand invalid PCM diagnostic 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. Test Plan: The modified LIT test. --- clang/include/clang/Basic/DiagnosticSerializationKinds.td | 2 +- clang/test/Modules/explicit-build.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index a1ae23a62802104..1c049792d16eda4 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..42444369dc92c5f 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 \ >From e2bb320ff4f64188c9b248b769efed51ab7bac0f Mon Sep 17 00:00:00 2001 From: Nuri Amari <nuriam...@fb.com> Date: Wed, 18 Oct 2023 14:36:56 -0700 Subject: [PATCH 2/2] Address PR Feedback --- clang/include/clang/Basic/DiagnosticSerializationKinds.td | 2 +- clang/test/Modules/explicit-build.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index 1c049792d16eda4..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: '%2'">, 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 42444369dc92c5f..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: 'file too small to contain AST file magic' +// 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 \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits