When we leave a module header, make that header visible in its

includer's context, even if its overall module is unavailable.

llvm-svn: 342096
This commit is contained in:
Richard Smith 2018-09-12 23:09:23 +00:00
parent 8a478b79dc
commit 841dbda3ba
6 changed files with 37 additions and 6 deletions

View File

@ -577,10 +577,6 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
};
std::function<void(Visiting)> VisitModule = [&](Visiting V) {
// Modules that aren't available cannot be made visible.
if (!V.M->isAvailable())
return;
// Nothing to do for a module that's already visible.
unsigned ID = V.M->getVisibilityID();
if (ImportLocs.size() <= ID)
@ -594,8 +590,11 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
// Make any exported modules visible.
SmallVector<Module *, 16> Exports;
V.M->getExportedModules(Exports);
for (Module *E : Exports)
VisitModule({E, &V});
for (Module *E : Exports) {
// Don't recurse to unavailable submodules.
if (E->isAvailable())
VisitModule({E, &V});
}
for (auto &C : V.M->Conflicts) {
if (isVisible(C.Other)) {

View File

@ -0,0 +1,4 @@
#ifndef A_H
#define A_H
#include "x.h"
#endif

View File

@ -0,0 +1,13 @@
#ifndef B_H
#define B_H
#include "a.h"
#ifndef A_H
#error where is a?
#endif
#ifndef X_H
#error where is x?
#endif
X f();
#endif

View File

@ -0,0 +1,9 @@
module M {
module a { header "a.h" export * }
module b { header "b.h" export * }
module doesnotexist { header "doesnotexist.h" }
}
module X {
header "x.h"
export *
}

View File

@ -0,0 +1,4 @@
#ifndef X_H
#define X_H
struct X {};
#endif

View File

@ -0,0 +1,2 @@
// RUN: %clang_cc1 -fmodules -I%S/Inputs/unavailable-local-visibility -fmodule-name=X -emit-module -x c++-module-map %S/Inputs/unavailable-local-visibility/module.modulemap -o %t/x.pcm
// RUN: %clang_cc1 -fmodules -I%S/Inputs/unavailable-local-visibility -fmodule-name=M -fmodule-map-file=%S/Inputs/unavailable-local-visibility/module.modulemap -fmodules-local-submodule-visibility -fmodule-file=%t/x.pcm -fsyntax-only -x c++-header %S/Inputs/unavailable-local-visibility/b.h