[clang] ba6e747 - [clang] Set ShowInSystemHeader for module-build and module-import remarks

Dave Lee via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 15:56:15 PDT 2023


Author: Dave Lee
Date: 2023-03-31T15:56:09-07:00
New Revision: ba6e747f9b05e541e88822e1dbd6bd5424cfe2fb

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

LOG: [clang] Set ShowInSystemHeader for module-build and module-import remarks

Without this change, the use of `-Rmodule-build` and `-Rmodule-import` only
produces diagnostics for modules built or imported by non-system code.

For example, if a project source file requires the Foundation module to be
built, then `-Rmodule-build` will show a single diagnostic for Foundation, but
not in turn for any of Foundation's (direct or indirect) dependencies. This is
because the locations of those transitive module builds are initiated from
system headers, which are ignored by default. When wanting to observe module
building/importing, the system modules can represent a significant amount of
module diagnostics, and I think should be shown by default when
`-Rmodule-build` and `-Rmodule-import` are specified.

I noticed some other remarks use `ShowInSystemHeader`.

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

Added: 
    clang/test/Modules/system-Rmodule-build.m

Modified: 
    clang/include/clang/Basic/DiagnosticFrontendKinds.td
    clang/include/clang/Basic/DiagnosticSerializationKinds.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 9f788380f4337..3a71d67d72792 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -241,8 +241,10 @@ def warn_module_config_macro_undef : Warning<
 def note_module_def_undef_here : Note<
   "macro was %select{defined|#undef'd}0 here">;
 def remark_module_build : Remark<"building module '%0' as '%1'">,
+  ShowInSystemHeader,
   InGroup<ModuleBuild>;
 def remark_module_build_done : Remark<"finished building module '%0'">,
+  ShowInSystemHeader,
   InGroup<ModuleBuild>;
 def remark_module_lock : Remark<"locking '%0' to build module '%1'">,
   InGroup<ModuleLock>;

diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index 30ee291d0d85e..919472417fe98 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -75,6 +75,7 @@ def note_module_file_conflict : Note<
 
 def remark_module_import : Remark<
   "importing module '%0'%select{| into '%3'}2 from '%1'">,
+  ShowInSystemHeader,
   InGroup<ModuleImport>;
 
 def err_imported_module_not_found : Error<

diff  --git a/clang/test/Modules/system-Rmodule-build.m b/clang/test/Modules/system-Rmodule-build.m
new file mode 100644
index 0000000000000..f631487befd20
--- /dev/null
+++ b/clang/test/Modules/system-Rmodule-build.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/sys
+// RUN: echo '#include <B.h>' > %t/sys/A.h
+// RUN: echo '' > %t/sys/B.h
+// RUN: echo 'module A { header "A.h" }' > %t/sys/module.modulemap
+// RUN: echo 'module B { header "B.h" }' >> %t/sys/module.modulemap
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fsyntax-only %s \
+// RUN:            -isystem %t/sys -Rmodule-build 2>&1 | FileCheck %s
+
+ at import A;
+
+// CHECK: building module 'A' as
+// CHECK: building module 'B' as
+// CHECK: finished building module 'B'
+// CHECK: finished building module 'A'


        


More information about the cfe-commits mailing list