summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-04-23 21:10:46 +0000
committerBen Langmuir <blangmuir@apple.com>2014-04-23 21:10:46 +0000
commitffbafa2af021504d2bdb575b5445e53faf63bb7a (patch)
treeabaec23d08afe7e33630787a00f56c5ec10e0c15 /clang
parent4dbd4891c7bdfcecb4933a50ca72285acc238850 (diff)
downloadbcm5719-llvm-ffbafa2af021504d2bdb575b5445e53faf63bb7a.tar.gz
bcm5719-llvm-ffbafa2af021504d2bdb575b5445e53faf63bb7a.zip
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. llvm-svn: 207024
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/Module.h3
-rw-r--r--clang/lib/Basic/Module.cpp10
-rw-r--r--clang/lib/Lex/ModuleMap.cpp2
-rw-r--r--clang/test/Modules/missing-submodule.m7
4 files changed, 18 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h
index 92de93a4d46..783aa1d57b1 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -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.
///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 067528abac0..e75485dbd66 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -29,9 +29,10 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
: 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, unsigned Indent) const {
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);
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 068e16d0431..39c11210112 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -365,6 +365,7 @@ ModuleMap::findModuleForHeader(const FileEntry *File,
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 FileEntry *File,
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
diff --git a/clang/test/Modules/missing-submodule.m b/clang/test/Modules/missing-submodule.m
new file mode 100644
index 00000000000..4f3553ce6c4
--- /dev/null
+++ b/clang/test/Modules/missing-submodule.m
@@ -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;
+}
OpenPOWER on IntegriCloud