diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2025-06-20 17:01:35 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2025-06-20 17:03:29 +0800 |
commit | 14e89b061fdecedcec4bb035060a56588610cb5c (patch) | |
tree | b93774623304ea4c26c09773b41ed255257aed43 /clang/lib/Sema/SemaModule.cpp | |
parent | 874773635d31501ab21812c05c44caf281c1acc7 (diff) | |
download | llvm-14e89b061fdecedcec4bb035060a56588610cb5c.zip llvm-14e89b061fdecedcec4bb035060a56588610cb5c.tar.gz llvm-14e89b061fdecedcec4bb035060a56588610cb5c.tar.bz2 |
[C++20] [Modules] Add exported modules as transitive imported modules
Close https://github.com/llvm/llvm-project/issues/144230
The root cause of the problem is, when we decide the transitive imports,
we didn't deal with exported imports.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r-- | clang/lib/Sema/SemaModule.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index 9fcaad48..54ee048 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -136,6 +136,7 @@ makeTransitiveImportsVisible(ASTContext &Ctx, VisibleModuleSet &VisibleModules, "modules only."); llvm::SmallVector<Module *, 4> Worklist; + llvm::SmallSet<Module *, 16> Visited; Worklist.push_back(Imported); Module *FoundPrimaryModuleInterface = @@ -144,18 +145,22 @@ makeTransitiveImportsVisible(ASTContext &Ctx, VisibleModuleSet &VisibleModules, while (!Worklist.empty()) { Module *Importing = Worklist.pop_back_val(); - if (VisibleModules.isVisible(Importing)) + if (Visited.count(Importing)) continue; + Visited.insert(Importing); // FIXME: The ImportLoc here is not meaningful. It may be problematic if we // use the sourcelocation loaded from the visible modules. VisibleModules.setVisible(Importing, ImportLoc); if (isImportingModuleUnitFromSameModule(Ctx, Importing, CurrentModule, - FoundPrimaryModuleInterface)) + FoundPrimaryModuleInterface)) { for (Module *TransImported : Importing->Imports) - if (!VisibleModules.isVisible(TransImported)) - Worklist.push_back(TransImported); + Worklist.push_back(TransImported); + + for (auto [Exports, _] : Importing->Exports) + Worklist.push_back(Exports); + } } } |