[PATCH] Include non-explicit submodules in exported module list
Dmitri Gribenko
gribozavr at gmail.com
Mon Nov 4 13:38:47 PST 2013
Removed the now-redundant code in ASTReader to handle non-explicit submodules.
Hi rsmith, doug.gregor,
http://llvm-reviews.chandlerc.com/D2100
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2100?vs=5339&id=5341#toc
Files:
lib/Basic/Module.cpp
lib/Serialization/ASTReader.cpp
test/Modules/Inputs/module.map
test/Modules/Inputs/recursive_visibility_a1_inner.h
test/Modules/Inputs/recursive_visibility_a2_more_inner.h
test/Modules/Inputs/recursive_visibility_b.h
test/Modules/Inputs/recursive_visibility_c.h
test/Modules/recursive_visibility.mm
Index: lib/Basic/Module.cpp
===================================================================
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -194,6 +194,16 @@
}
void Module::getExportedModules(SmallVectorImpl<Module *> &Exported) const {
+ // All non-explicit submodules are exported.
+ for (std::vector<Module *>::const_iterator I = SubModules.begin(),
+ E = SubModules.end();
+ I != E; ++I) {
+ Module *Mod = *I;
+ if (!Mod->IsExplicit)
+ Exported.push_back(Mod);
+ }
+
+ // Find re-exported modules by filtering the list of imported modules.
bool AnyWildcard = false;
bool UnrestrictedWildcard = false;
SmallVector<Module *, 4> WildcardRestrictions;
Index: lib/Serialization/ASTReader.cpp
===================================================================
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2845,16 +2845,7 @@
makeNamesVisible(Hidden->second, Hidden->first);
HiddenNamesMap.erase(Hidden);
}
-
- // Push any non-explicit submodules onto the stack to be marked as
- // visible.
- for (Module::submodule_iterator Sub = Mod->submodule_begin(),
- SubEnd = Mod->submodule_end();
- Sub != SubEnd; ++Sub) {
- if (!(*Sub)->IsExplicit && Visited.insert(*Sub))
- Stack.push_back(*Sub);
- }
-
+
// Push any exported modules onto the stack to be marked as visible.
SmallVector<Module *, 16> Exports;
Mod->getExportedModules(Exports);
Index: test/Modules/Inputs/module.map
===================================================================
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -263,3 +263,21 @@
module a { header "using-decl-a.h" export * }
module b { header "using-decl-b.h" export * }
}
+
+module recursive_visibility_a1 {
+ module inner { header "recursive_visibility_a1_inner.h" }
+}
+module recursive_visibility_a2 {
+ module inner {
+ module more_inner {
+ header "recursive_visibility_a2_more_inner.h"
+ }
+ }
+}
+module recursive_visibility_b {
+ header "recursive_visibility_b.h"
+ export *
+}
+module recursive_visibility_c {
+ header "recursive_visibility_c.h"
+}
Index: test/Modules/Inputs/recursive_visibility_a1_inner.h
===================================================================
--- test/Modules/Inputs/recursive_visibility_a1_inner.h
+++ test/Modules/Inputs/recursive_visibility_a1_inner.h
@@ -0,0 +1,4 @@
+namespace A1_Inner {
+ struct X {};
+ void f(X);
+}
Index: test/Modules/Inputs/recursive_visibility_a2_more_inner.h
===================================================================
--- test/Modules/Inputs/recursive_visibility_a2_more_inner.h
+++ test/Modules/Inputs/recursive_visibility_a2_more_inner.h
@@ -0,0 +1,4 @@
+namespace A2_More_Inner {
+ struct X {};
+ void f(X);
+}
Index: test/Modules/Inputs/recursive_visibility_b.h
===================================================================
--- test/Modules/Inputs/recursive_visibility_b.h
+++ test/Modules/Inputs/recursive_visibility_b.h
@@ -0,0 +1,2 @@
+ at import recursive_visibility_a1.inner;
+ at import recursive_visibility_a2;
Index: test/Modules/Inputs/recursive_visibility_c.h
===================================================================
--- test/Modules/Inputs/recursive_visibility_c.h
+++ test/Modules/Inputs/recursive_visibility_c.h
@@ -0,0 +1,5 @@
+ at import recursive_visibility_b;
+template<template<typename T> class Y> void g() {
+ f(typename Y<A1_Inner::X>::type{});
+ f(typename Y<A2_More_Inner::X>::type{});
+}
Index: test/Modules/recursive_visibility.mm
===================================================================
--- test/Modules/recursive_visibility.mm
+++ test/Modules/recursive_visibility.mm
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+
+// expected-no-diagnostics
+
+ at import recursive_visibility_c;
+
+template<typename T> struct Z { typedef T type; };
+template void g<Z>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2100.2.patch
Type: text/x-patch
Size: 4088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131104/dd6f0e3d/attachment.bin>
More information about the cfe-commits
mailing list