1 // RUN: %clang_cc1 -std=c++2b %s -emit-llvm -triple x86_64-linux -o - | FileCheck %s
4 void explicit_object_function(this TrivialStruct
) {}
8 s
.explicit_object_function();
10 // CHECK: define {{.*}}test{{.*}}
12 // CHECK: {{.*}} = alloca %struct.TrivialStruct, align 1
13 // CHECK: {{.*}} = alloca %struct.TrivialStruct, align 1
14 // CHECK: call void {{.*}}explicit_object_function{{.*}}
15 // CHECK-NEXT: ret void
18 // CHECK: define {{.*}}explicit_object_function{{.*}}
20 // CHECK: {{.*}} = alloca %struct.TrivialStruct, align 1
26 [](this auto This
) -> int {
31 //CHECK: define dso_local void @{{.*}}test_lambda{{.*}}() #0 {
33 //CHECK: %agg.tmp = alloca %class.anon, align 1
34 //CHECK: %ref.tmp = alloca %class.anon, align 1
35 //CHECK: %call = call noundef i32 @"_ZZ11test_lambdavENH3$_0clIS_EEiT_"()
39 //CHECK: define internal noundef i32 @"_ZZ11test_lambdavENH3$_0clIS_EEiT_"() #0 align 2 {
41 //CHECK: %This = alloca %class.anon, align 1
42 //CHECK: %agg.tmp = alloca %class.anon, align 1
43 //CHECK: %call = call noundef i32 @"_ZZ11test_lambdavENH3$_0clIS_EEiT_"()
44 //CHECK: ret i32 %call
47 void test_lambda_ref() {
48 auto l
= [i
= 42](this auto & This
, int j
) -> int {
54 // CHECK: define dso_local void @_Z15test_lambda_refv() #0 {
56 // CHECK: %[[This_address:.]] = alloca %class.anon{{.*}}, align 4
57 // CHECK: %[[i_addr:.*]] = getelementptr inbounds %class.anon{{.*}}, ptr %[[This_address]], i32 0, i32 0
58 // CHECK: store i32 42, ptr %[[i_addr]], align 4
59 // CHECK: %call = call noundef i32 @"_ZZ15test_lambda_refvENH3$_0clIS_EEiRT_i"{{.*}}
63 // CHECK: define internal noundef i32 @"_ZZ15test_lambda_refvENH3$_0clIS_EEiRT_i"{{.*}}
65 // CHECK: %This.addr = alloca ptr, align 8
66 // CHECK: %j.addr = alloca i32, align 4
67 // CHECK: store ptr %This, ptr %This.addr, align 8
68 // CHECK: store i32 %j, ptr %j.addr, align 4
69 // CHECK: %[[this_addr:.*]] = load ptr, ptr %This.addr, align 8
70 // CHECK: %[[j_addr:.*]] = load i32, ptr %j.addr, align 4
71 // CHECK: %call = call noundef i32 @"_ZZ15test_lambda_refvENH3$_0clIS_EEiRT_i"(ptr noundef nonnull align 4 dereferenceable(4) %[[this_addr]], i32 noundef %[[j_addr]])
72 // CHECK: ret i32 %call
77 void f(this TestPointer
&);
82 using Fn
= void(TestPointer
&);
83 Fn
* fn
= &TestPointer::f
;
86 //CHECK: define dso_local void @_Z12test_pointerv() #0 {
88 //CHECK-NEXT: %t = alloca %struct.TestPointer, align 1
89 //CHECK-NEXT: %fn = alloca ptr, align 8
90 //CHECK-NEXT: store ptr @_ZNH11TestPointer1fERS_, ptr %fn, align 8
91 //CHECK: %[[fn_ptr:.*]] = load ptr, ptr %fn, align 8
92 //CHECK-NEXT: call void %[[fn_ptr]](ptr noundef nonnull align 1 dereferenceable(1) %t)
93 //CHECK-NEXT: ret void
97 struct MaterializedTemporary
{
98 void foo(this MaterializedTemporary
&&);
99 MaterializedTemporary();
100 ~MaterializedTemporary();
103 void test_temporary() {
104 MaterializedTemporary
{}.foo();
107 //CHECK: define dso_local void @_Z14test_temporaryv(){{.*}}
109 //CHECK: %ref.tmp = alloca %struct.MaterializedTemporary, align 1
110 //CHECK: call void @_ZN21MaterializedTemporaryC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %ref.tmp){{.*}}
111 //CHECK invoke void @_ZNH21MaterializedTemporary3fooEOS_(ptr noundef nonnull align 1 dereferenceable(1) %ref.tmp){{.*}}