forked from OSchip/llvm-project
Include non-explicit submodules in exported module list
This change fixes Richard's testcase for r193815. Now we include non-explicit submodules into the list of exports. The test failed previously because: - recursive_visibility_a1.inner is not imported (only recursive_visibility_a1 is), - thus the 'inner' submodule is not showing up in any of the import lists, - and because of this getExportedModules() is not returning the correct module set -- it only considers modules that are imported. The fix is to make Module::getExportedModules() include non-explicit submodules into the list of exports. llvm-svn: 194018
This commit is contained in:
parent
d1382b6c31
commit
e9bcf5b7b1
|
@ -194,6 +194,16 @@ static void printModuleId(raw_ostream &OS, const ModuleId &Id) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -2845,16 +2845,7 @@ void ASTReader::makeModuleVisible(Module *Mod,
|
|||
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);
|
||||
|
|
|
@ -263,3 +263,21 @@ module using_decl {
|
|||
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"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
namespace A1_Inner {
|
||||
struct X {};
|
||||
void f(X);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
namespace A2_More_Inner {
|
||||
struct X {};
|
||||
void f(X);
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
@import recursive_visibility_a1.inner;
|
||||
@import recursive_visibility_a2;
|
|
@ -0,0 +1,5 @@
|
|||
@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{});
|
||||
}
|
|
@ -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
|
||||
|
||||
@import recursive_visibility_c;
|
||||
|
||||
template<typename T> struct Z { typedef T type; };
|
||||
template void g<Z>();
|
Loading…
Reference in New Issue