File tree Expand file tree Collapse file tree 4 files changed +63
-4
lines changed Expand file tree Collapse file tree 4 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -666,13 +666,13 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
666
666
// Module initializers for imported modules are emitted first.
667
667
668
668
// Collect all the modules that we import
669
- SmallVector <Module *> AllImports;
669
+ llvm::SmallSetVector <Module *, 8 > AllImports;
670
670
// Ones that we export
671
671
for (auto I : Primary->Exports )
672
- AllImports.push_back (I.getPointer ());
672
+ AllImports.insert (I.getPointer ());
673
673
// Ones that we only import.
674
674
for (Module *M : Primary->Imports )
675
- AllImports.push_back (M);
675
+ AllImports.insert (M);
676
676
// Ones that we import in the global module fragment or the private module
677
677
// fragment.
678
678
llvm::for_each (Primary->submodules (), [&AllImports](Module *SubM) {
@@ -683,7 +683,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
683
683
" The global mdoule fragments and the private module fragments are "
684
684
" not allowed to export import modules." );
685
685
for (Module *M : SubM->Imports )
686
- AllImports.push_back (M);
686
+ AllImports.insert (M);
687
687
});
688
688
689
689
SmallVector<llvm::Function *, 8 > ModuleInits;
Original file line number Diff line number Diff line change @@ -2938,6 +2938,9 @@ void CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
2938
2938
// Third any associated with the Privat eMOdule Fragment, if present.
2939
2939
if (auto PMF = Primary->getPrivateModuleFragment ()) {
2940
2940
for (Decl *D : getContext ().getModuleInitializers (PMF)) {
2941
+ // Skip import decls, the inits for those are called explicitly.
2942
+ if (isa<ImportDecl>(D))
2943
+ continue ;
2941
2944
assert (isa<VarDecl>(D) && " PMF initializer decl is not a var?" );
2942
2945
EmitTopLevelDecl (D);
2943
2946
}
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
3
+ // RUN: cd %t
4
+ //
5
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/a.cppm \
6
+ // RUN: -emit-module-interface -o %t/a.pcm
7
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.cppm \
8
+ // RUN: -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/m.pcm
9
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.pcm \
10
+ // RUN: -S -emit-llvm -o - | FileCheck %t/m.cppm
11
+
12
+ // --- a.cppm
13
+ export module a;
14
+ export struct A {
15
+ A (){};
16
+ };
17
+ export A __dynamic_inited_a;
18
+
19
+ // --- m.cppm
20
+ export module m;
21
+ import a;
22
+ export import a;
23
+
24
+
25
+ // CHECK: define void @_ZGIW1m
26
+ // CHECK: store i8 1, ptr @_ZGIW1m__in_chrg
27
+ // CHECK: call{{.*}}@_ZGIW1a
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
3
+ // RUN: cd %t
4
+ //
5
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/a.cppm \
6
+ // RUN: -emit-module-interface -o %t/a.pcm
7
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.cppm \
8
+ // RUN: -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/m.pcm
9
+ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.pcm \
10
+ // RUN: -S -emit-llvm -o - | FileCheck %t/m.cppm
11
+
12
+ // --- a.cppm
13
+ export module a;
14
+ export struct A {
15
+ A (){};
16
+ };
17
+ export A __dynamic_inited_a;
18
+
19
+ // --- m.cppm
20
+ module ;
21
+ import a;
22
+ export module m;
23
+ import a;
24
+ module :private;
25
+ import a;
26
+
27
+ // CHECK: define void @_ZGIW1m
28
+ // CHECK: store i8 1, ptr @_ZGIW1m__in_chrg
29
+ // CHECK: call{{.*}}@_ZGIW1a
You can’t perform that action at this time.
0 commit comments