[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / cxx-irgen.cpp
blobd552b09c976979b4ad00a4084a71ed1166838022
1 // UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
2 // RUN: rm -rf %t
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-passes -emit-llvm -debug-info-kind=limited -o - %s | FileCheck %s
5 // FIXME: When we have a syntax for modules in C++, use that.
7 @import cxx_irgen_top;
9 CtorInit<int> x;
11 @import cxx_irgen_left;
12 @import cxx_irgen_right;
14 // Keep these two namespace definitions separate; merging them hides the bug.
15 namespace EmitInlineMethods {
16 // CHECK-DAG: define linkonce_odr {{(dso_local )?}}[[CC:([0-9_a-z]*cc[ ]+)?]]void @_ZN17EmitInlineMethods1C1fEPNS_1AE(
17 // CHECK-DAG: declare {{(dso_local )?}}[[CC]]void @_ZN17EmitInlineMethods1A1gEv(
18 struct C {
19 __attribute__((used)) void f(A *p) { p->g(); }
22 namespace EmitInlineMethods {
23 // CHECK-DAG: define linkonce_odr {{(dso_local )?}}[[CC]]void @_ZN17EmitInlineMethods1D1fEPNS_1BE(
24 // CHECK-DAG: define linkonce_odr {{(dso_local )?}}[[CC]]void @_ZN17EmitInlineMethods1B1gEv(
25 struct D {
26 __attribute__((used)) void f(B *p) { p->g(); }
30 // CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[#ALWAYS_INLINE:]]
31 int a = S<int>::g();
33 int b = h();
35 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
36 int c = min(1, 2);
37 // CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[#ALWAYS_INLINE]]
39 namespace ImplicitSpecialMembers {
40 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
41 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
42 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_(
43 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
44 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2ERKS0_(
45 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
46 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2EOS0_(
47 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
48 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2ERKS0_(
49 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
50 // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2EOS0_(
51 // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
52 // CHECK-LABEL: define {{.*}} @_ZN20OperatorDeleteLookup1AD0Ev(
53 // CHECK: call {{.*}}void @_ZN20OperatorDeleteLookup1AdlEPv(
55 // CHECK-DAG: call {{.*}}i32 @_ZN8CtorInitIiE1fEv(
57 extern B b1;
58 B b2(b1);
59 B b3(static_cast<B&&>(b1));
61 extern C c1;
62 C c2(c1);
63 C c3(static_cast<C&&>(c1));
65 extern D d1;
66 D d2(d1);
67 D d3(static_cast<D&&>(d1));
70 namespace OperatorDeleteLookup {
71 // Trigger emission of B's vtable and deleting dtor.
72 // This requires us to know what operator delete was selected.
73 void g() { f(); }
77 // CHECK: attributes #[[#ALWAYS_INLINE]] = {{.*}} alwaysinline