aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Module.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2025-02-21 10:04:42 -0800
committerGitHub <noreply@github.com>2025-02-21 10:04:42 -0800
commit4bb04d417669be7a3d0359dfd313f0bf4f7ca531 (patch)
tree7b2d877217869fac67c7d1b5eb3c17ab4ee43125 /clang/lib/Basic/Module.cpp
parent9738f20bb03c1a53f64dce5626972f4f6c1b815e (diff)
downloadllvm-4bb04d417669be7a3d0359dfd313f0bf4f7ca531.zip
llvm-4bb04d417669be7a3d0359dfd313f0bf4f7ca531.tar.gz
llvm-4bb04d417669be7a3d0359dfd313f0bf4f7ca531.tar.bz2
[clang][modules] Fix local submodule visibility of macros from transitive import (#122955)
When we mark a module visible, we normally mark all of its non-explicit submodules and other exports as visible. However, when we first enter a submodule we should not make them visible to the submodule itself until they are actually imported. Marking exports visible before import would cause bizarre behaviour with local submodule visibility, because it happened before we discovered the submodule's transitive imports and could fail to make them visible in the parent module depending on whether the submodules involved were explicitly defined (module X) or implicitly defined from an umbrella (module *). rdar://136524433
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r--clang/lib/Basic/Module.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 330108d..bb85a40 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -662,7 +662,8 @@ LLVM_DUMP_METHOD void Module::dump() const {
}
void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
- VisibleCallback Vis, ConflictCallback Cb) {
+ bool IncludeExports, VisibleCallback Vis,
+ ConflictCallback Cb) {
// We can't import a global module fragment so the location can be invalid.
assert((M->isGlobalModule() || Loc.isValid()) &&
"setVisible expects a valid import location");
@@ -688,12 +689,14 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
Vis(V.M);
// Make any exported modules visible.
- SmallVector<Module *, 16> Exports;
- V.M->getExportedModules(Exports);
- for (Module *E : Exports) {
- // Don't import non-importable modules.
- if (!E->isUnimportable())
- VisitModule({E, &V});
+ if (IncludeExports) {
+ SmallVector<Module *, 16> Exports;
+ V.M->getExportedModules(Exports);
+ for (Module *E : Exports) {
+ // Don't import non-importable modules.
+ if (!E->isUnimportable())
+ VisitModule({E, &V});
+ }
}
for (auto &C : V.M->Conflicts) {