r342096 - When we leave a module header, make that header visible in its
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 12 16:09:24 PDT 2018
Author: rsmith
Date: Wed Sep 12 16:09:23 2018
New Revision: 342096
URL: http://llvm.org/viewvc/llvm-project?rev=342096&view=rev
Log:
When we leave a module header, make that header visible in its
includer's context, even if its overall module is unavailable.
Added:
cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/
cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/a.h
cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/b.h
cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/module.modulemap
cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/x.h
cfe/trunk/test/Modules/unavailable-local-visibility.test
Modified:
cfe/trunk/lib/Basic/Module.cpp
Modified: cfe/trunk/lib/Basic/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=342096&r1=342095&r2=342096&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Wed Sep 12 16:09:23 2018
@@ -577,10 +577,6 @@ void VisibleModuleSet::setVisible(Module
};
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
// 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)) {
Added: cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/a.h?rev=342096&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/a.h Wed Sep 12 16:09:23 2018
@@ -0,0 +1,4 @@
+#ifndef A_H
+#define A_H
+#include "x.h"
+#endif
Added: cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/b.h?rev=342096&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/b.h Wed Sep 12 16:09:23 2018
@@ -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
Added: cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/module.modulemap?rev=342096&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/module.modulemap Wed Sep 12 16:09:23 2018
@@ -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 *
+}
Added: cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/x.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/x.h?rev=342096&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/x.h (added)
+++ cfe/trunk/test/Modules/Inputs/unavailable-local-visibility/x.h Wed Sep 12 16:09:23 2018
@@ -0,0 +1,4 @@
+#ifndef X_H
+#define X_H
+struct X {};
+#endif
Added: cfe/trunk/test/Modules/unavailable-local-visibility.test
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/unavailable-local-visibility.test?rev=342096&view=auto
==============================================================================
--- cfe/trunk/test/Modules/unavailable-local-visibility.test (added)
+++ cfe/trunk/test/Modules/unavailable-local-visibility.test Wed Sep 12 16:09:23 2018
@@ -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
More information about the cfe-commits
mailing list