r207024 - Do not print inferred submodules explicitly in __inferred_module.map
Ben Langmuir
blangmuir at apple.com
Wed Apr 23 14:10:46 PDT 2014
Author: benlangmuir
Date: Wed Apr 23 16:10:46 2014
New Revision: 207024
URL: http://llvm.org/viewvc/llvm-project?rev=207024&view=rev
Log:
Do not print inferred submodules explicitly in __inferred_module.map
Otherwise including a header in your source file that is not included by
framework's umbrella header will silently add an empty submodule with that
name.
is automatically translated to
@import Foo.NotInModule;
which then would have succeeded because the inferred module map
contained an empty submodule called NotInModule.
Added:
cfe/trunk/test/Modules/missing-submodule.m
Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
Modified: cfe/trunk/include/clang/Basic/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=207024&r1=207023&r2=207024&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Apr 23 16:10:46 2014
@@ -150,6 +150,9 @@ public:
/// imported within such a block).
unsigned IsExternC : 1;
+ /// \brief Whether this is an inferred submodule (module * { ... }).
+ unsigned IsInferred : 1;
+
/// \brief Whether we should infer submodules for this module based on
/// the headers.
///
Modified: cfe/trunk/lib/Basic/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=207024&r1=207023&r2=207024&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Wed Apr 23 16:10:46 2014
@@ -29,9 +29,10 @@ Module::Module(StringRef Name, SourceLoc
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), ModuleMap(File),
Umbrella(), ASTFile(0), IsMissingRequirement(false), IsAvailable(true),
IsFromModuleFile(false), IsFramework(IsFramework), IsExplicit(IsExplicit),
- IsSystem(false), IsExternC(false), InferSubmodules(false),
- InferExplicitSubmodules(false), InferExportWildcard(false),
- ConfigMacrosExhaustive(false), NameVisibility(Hidden) {
+ IsSystem(false), IsExternC(false), IsInferred(false),
+ InferSubmodules(false), InferExplicitSubmodules(false),
+ InferExportWildcard(false), ConfigMacrosExhaustive(false),
+ NameVisibility(Hidden) {
if (Parent) {
if (!Parent->isAvailable())
IsAvailable = false;
@@ -360,7 +361,8 @@ void Module::print(raw_ostream &OS, unsi
for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end();
MI != MIEnd; ++MI)
- (*MI)->print(OS, Indent + 2);
+ if (!(*MI)->IsInferred)
+ (*MI)->print(OS, Indent + 2);
for (unsigned I = 0, N = Exports.size(); I != N; ++I) {
OS.indent(Indent + 2);
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=207024&r1=207023&r2=207024&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Wed Apr 23 16:10:46 2014
@@ -365,6 +365,7 @@ ModuleMap::findModuleForHeader(const Fil
llvm::sys::path::stem(SkippedDirs[I-1]->getName()), NameBuf);
Result = findOrCreateModule(Name, Result, UmbrellaModule->ModuleMap,
/*IsFramework=*/false, Explicit).first;
+ Result->IsInferred = true;
// Associate the module and the directory.
UmbrellaDirs[SkippedDirs[I-1]] = Result;
@@ -381,6 +382,7 @@ ModuleMap::findModuleForHeader(const Fil
llvm::sys::path::stem(File->getName()), NameBuf);
Result = findOrCreateModule(Name, Result, UmbrellaModule->ModuleMap,
/*IsFramework=*/false, Explicit).first;
+ Result->IsInferred = true;
Result->addTopHeader(File);
// If inferred submodules export everything they import, add a
Added: cfe/trunk/test/Modules/missing-submodule.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/missing-submodule.m?rev=207024&view=auto
==============================================================================
--- cfe/trunk/test/Modules/missing-submodule.m (added)
+++ cfe/trunk/test/Modules/missing-submodule.m Wed Apr 23 16:10:46 2014
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -F %S/Inputs %s -verify
+#include <Module/NotInModule.h> // expected-warning{{missing submodule 'Module.NotInModule'}}
+
+int getNotInModule() {
+ return not_in_module;
+}
More information about the cfe-commits
mailing list