summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticFrontendKinds.td2
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp3
-rw-r--r--clang/test/Modules/Wmodule-build.m22
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 7b500eed5c0..674d6d6c42f 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -167,6 +167,8 @@ def warn_module_config_macro_undef : Warning<
InGroup<ConfigMacros>;
def note_module_def_undef_here : Note<
"macro was %select{defined|#undef'd}0 here">;
+def warn_module_build : Warning<"building module '%0' as '%1'">,
+ InGroup<DiagGroup<"module-build">>, DefaultIgnore;
def err_missing_vfs_overlay_file : Error<
"virtual filesystem overlay file '%0' not found">, DefaultFatal;
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index d7b526b2da2..4a75186d975 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1219,6 +1219,9 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
return ModuleLoadResult();
}
+ getDiagnostics().Report(ImportLoc, diag::warn_module_build)
+ << ModuleName << ModuleFileName;
+
// Check whether we have already attempted to build this module (but
// failed).
if (getPreprocessorOpts().FailedModules &&
diff --git a/clang/test/Modules/Wmodule-build.m b/clang/test/Modules/Wmodule-build.m
new file mode 100644
index 00000000000..74e020965c4
--- /dev/null
+++ b/clang/test/Modules/Wmodule-build.m
@@ -0,0 +1,22 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo '// A' > %t/A.h
+// RUN: echo '// B' > %t/B.h
+// RUN: echo 'module A { header "A.h" }' > %t/module.modulemap
+// RUN: echo 'module B { header "B.h" }' >> %t/module.modulemap
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -verify \
+// RUN: -I %t -Wmodule-build
+
+@import A; // expected-warning{{building module 'A' as}}
+@import B; // expected-warning{{building module 'B' as}}
+@import A; // no diagnostic
+@import B; // no diagnostic
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN: -Wmodule-build 2>&1 | FileCheck %s
+
+// CHECK-NOT: building module 'A'
+// CHECK: building module 'B'
OpenPOWER on IntegriCloud