diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-12 23:09:23 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-12 23:09:23 +0000 |
| commit | 841dbda3ba74ee5a2daa3037d78a877900bde339 (patch) | |
| tree | daf9d4e21ae0133cd014ceb998829d8cb5cf38f9 /clang | |
| parent | 8a478b79dc906c1f737d78fec2431dd58de646cc (diff) | |
| download | bcm5719-llvm-841dbda3ba74ee5a2daa3037d78a877900bde339.tar.gz bcm5719-llvm-841dbda3ba74ee5a2daa3037d78a877900bde339.zip | |
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
Diffstat (limited to 'clang')
6 files changed, 37 insertions, 6 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 1a0c1905905..9ff976c03b9 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -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)) { diff --git a/clang/test/Modules/Inputs/unavailable-local-visibility/a.h b/clang/test/Modules/Inputs/unavailable-local-visibility/a.h new file mode 100644 index 00000000000..865bb65f4d2 --- /dev/null +++ b/clang/test/Modules/Inputs/unavailable-local-visibility/a.h @@ -0,0 +1,4 @@ +#ifndef A_H +#define A_H +#include "x.h" +#endif diff --git a/clang/test/Modules/Inputs/unavailable-local-visibility/b.h b/clang/test/Modules/Inputs/unavailable-local-visibility/b.h new file mode 100644 index 00000000000..71360e38b7b --- /dev/null +++ b/clang/test/Modules/Inputs/unavailable-local-visibility/b.h @@ -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 diff --git a/clang/test/Modules/Inputs/unavailable-local-visibility/module.modulemap b/clang/test/Modules/Inputs/unavailable-local-visibility/module.modulemap new file mode 100644 index 00000000000..8da3d3c1ab0 --- /dev/null +++ b/clang/test/Modules/Inputs/unavailable-local-visibility/module.modulemap @@ -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 * +} diff --git a/clang/test/Modules/Inputs/unavailable-local-visibility/x.h b/clang/test/Modules/Inputs/unavailable-local-visibility/x.h new file mode 100644 index 00000000000..0498c5d2aab --- /dev/null +++ b/clang/test/Modules/Inputs/unavailable-local-visibility/x.h @@ -0,0 +1,4 @@ +#ifndef X_H +#define X_H +struct X {}; +#endif diff --git a/clang/test/Modules/unavailable-local-visibility.test b/clang/test/Modules/unavailable-local-visibility.test new file mode 100644 index 00000000000..10b316a50ec --- /dev/null +++ b/clang/test/Modules/unavailable-local-visibility.test @@ -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 |

