]> granicus.if.org Git - clang/commitdiff
Introduce an opt-in warning when a module is being implicitly built
authorDouglas Gregor <dgregor@apple.com>
Thu, 29 Sep 2011 00:52:27 +0000 (00:52 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 29 Sep 2011 00:52:27 +0000 (00:52 +0000)
from sources.

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

include/clang/Basic/DiagnosticCommonKinds.td
include/clang/Basic/DiagnosticGroups.td
lib/Frontend/CompilerInstance.cpp
test/Modules/on-demand-build-warnings.m [new file with mode: 0644]

index 7639b5b05145dd8e87c794e4a39aa7387066be3b..1313174b1678b0049e033490fc66b680ddb768b1 100644 (file)
@@ -63,6 +63,8 @@ def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
 def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
+def warn_module_build : Warning<"building module '%0' from source">, 
+  InGroup<ModuleBuild>, DefaultIgnore;
 
 // Sema && Lex
 def ext_longlong : Extension<
index a4dbf962435f03bbad22ceb808bc334246e0f1d3..9901b79bec2906723c36e22172b2a8599b75afe7 100644 (file)
@@ -85,6 +85,7 @@ def : DiagGroup<"newline-eof">;
 def LongLong : DiagGroup<"long-long">;
 def MismatchedTags : DiagGroup<"mismatched-tags">;
 def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
+def ModuleBuild : DiagGroup<"module-build">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
 def NonNull : DiagGroup<"nonnull">;
index 554ca352e1cc874ff796197fd5a2e4cb237099b8..27fe3f15ffa6feb003594317b7f70954877385d6 100644 (file)
@@ -752,6 +752,8 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
       return 0;
     }
     
+    getDiagnostics().Report(ModuleNameLoc, diag::warn_module_build)
+      << ModuleName.getName();
     BuildingModule = true;
     compileModule(*this, ModuleName.getName(), ModuleFileName, UmbrellaHeader);
     ModuleFile = PP->getHeaderSearchInfo().lookupModule(ModuleName.getName());
diff --git a/test/Modules/on-demand-build-warnings.m b/test/Modules/on-demand-build-warnings.m
new file mode 100644 (file)
index 0000000..ea53169
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -DFOO -verify %s
+
+__import_module__ Module; // expected-warning{{building module 'Module' from source}}
+