[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / module-initializer-guard-elision.cpp
blob2b01a670fb72764143dd798ac167a2630e8e01f0
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: cd %t
5 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp \
6 // RUN: -emit-module-interface -o O.pcm
7 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.pcm -S -emit-llvm \
8 // RUN: -o - | FileCheck %s --check-prefix=CHECK-O
10 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.cpp \
11 // RUN: -emit-module-interface -fmodule-file=O.pcm -o P.pcm
12 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.pcm -S -emit-llvm \
13 // RUN: -o - | FileCheck %s --check-prefix=CHECK-P
15 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 Q.cpp \
16 // RUN: -emit-module-interface -fmodule-file=O.pcm -o Q.pcm
17 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 Q.pcm -S -emit-llvm \
18 // RUN: -o - | FileCheck %s --check-prefix=CHECK-Q
20 // Testing cases where we can elide the module initializer guard variable.
22 // This module has no global inits and does not import any other module
23 //--- O.cpp
25 export module O;
27 export int foo ();
29 // CHECK-O: define void @_ZGIW1O
30 // CHECK-O-LABEL: entry
31 // CHECK-O-NEXT: ret void
32 // CHECK-O-NOT: @_ZGIW1O__in_chrg
34 // This has no global inits but imports a module, and therefore needs a guard
35 // variable.
36 //--- P.cpp
38 export module P;
40 export import O;
41 export int bar ();
43 // CHECK-P: define void @_ZGIW1P
44 // CHECK-P-LABEL: init
45 // CHECK-P: store i8 1, ptr @_ZGIW1P__in_chrg
46 // CHECK-P: call void @_ZGIW1O()
47 // CHECK-P-NOT: call void @__cxx_global_var_init
49 // This imports a module and has global inits, so needs a guard.
50 //--- Q.cpp
52 export module Q;
53 export import O;
55 export struct Quack {
56 Quack(){};
59 export Quack Duck;
61 export int baz ();
63 // CHECK-Q: define internal void @__cxx_global_var_init
64 // CHECK-Q: call {{.*}} @_ZNW1Q5QuackC1Ev
65 // CHECK-Q: define void @_ZGIW1Q
66 // CHECK-Q: store i8 1, ptr @_ZGIW1Q__in_chrg
67 // CHECK-Q: call void @_ZGIW1O()
68 // CHECK-Q: call void @__cxx_global_var_init