diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2023-06-12 20:38:02 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2023-06-25 08:33:39 +0100 |
commit | b37233a253f30e4bd5f040d598826df443293bee (patch) | |
tree | 82d6ff3f6f8eacb0b770e8cc337decb8f3155227 /clang/lib/Basic/Module.cpp | |
parent | 2a61ceddb30aaed291317795e3183371e8cf3d7a (diff) | |
download | llvm-b37233a253f30e4bd5f040d598826df443293bee.zip llvm-b37233a253f30e4bd5f040d598826df443293bee.tar.gz llvm-b37233a253f30e4bd5f040d598826df443293bee.tar.bz2 |
[C++20][Modules] Complete implementation of module.import p7.
The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7)
```
a.cppm:
export module a;
export int foo() {
return 42;
}
b.cppm:
export module b;
import a;
export int bar();
b.cpp:
module b;
int bar() {
return foo();
}
clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required
return foo();
```
This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm).
Differential Revision: https://reviews.llvm.org/D152746
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 3f9b8d0..2bdbe8d2 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -695,6 +695,14 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc, VisitModule({M, nullptr}); } +void VisibleModuleSet::makeTransitiveImportsVisible(Module *M, + SourceLocation Loc, + VisibleCallback Vis, + ConflictCallback Cb) { + for (auto *I : M->Imports) + setVisible(I, Loc, Vis, Cb); +} + ASTSourceDescriptor::ASTSourceDescriptor(Module &M) : Signature(M.Signature), ClangModule(&M) { if (M.Directory) |