From: Ben Langmuir Date: Mon, 5 May 2014 16:58:47 +0000 (+0000) Subject: Add -Wmodule-build to make it easy to see when modules are (re)built X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9a44d1c1438a1c9f602f6c76a2076126bee1e45;p=clang Add -Wmodule-build to make it easy to see when modules are (re)built 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 --- diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 7b500eed5c..674d6d6c42 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -167,6 +167,8 @@ def warn_module_config_macro_undef : Warning< InGroup; 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>, DefaultIgnore; def err_missing_vfs_overlay_file : Error< "virtual filesystem overlay file '%0' not found">, DefaultFatal; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index d7b526b2da..4a75186d97 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/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/test/Modules/Wmodule-build.m b/test/Modules/Wmodule-build.m new file mode 100644 index 0000000000..74e020965c --- /dev/null +++ b/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'