]> granicus.if.org Git - clang/commitdiff
Add -Wmodule-build to make it easy to see when modules are (re)built
authorBen Langmuir <blangmuir@apple.com>
Mon, 5 May 2014 16:58:47 +0000 (16:58 +0000)
committerBen Langmuir <blangmuir@apple.com>
Mon, 5 May 2014 16:58:47 +0000 (16:58 +0000)
Warning is default ignore, and not in -Wall.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207975 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticFrontendKinds.td
lib/Frontend/CompilerInstance.cpp
test/Modules/Wmodule-build.m [new file with mode: 0644]

index 7b500eed5c049b6caf27deedb404f8d14d8e552a..674d6d6c42f9f7b6fd02e531e83c31d9557ee4f5 100644 (file)
@@ -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;
index d7b526b2da2660aca3cc371c4e649da9427b968c..4a75186d9756d5e21874dedc92e9bcdebef9449b 100644 (file)
@@ -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/test/Modules/Wmodule-build.m b/test/Modules/Wmodule-build.m
new file mode 100644 (file)
index 0000000..74e0209
--- /dev/null
@@ -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'