1 // RUN: %clang_cc1 -std=c++2b -emit-llvm -triple=x86_64-pc-win32 -o - %s 2>/dev/null | FileCheck %s 2 3 struct S { 4 friend void test(); 5 public: 6 void a(this auto){} 7 void b(this auto&){} 8 void c(this S){} 9 void c(this S, int){} 10 private: 11 void d(this auto){} 12 void e(this auto&){} 13 void f(this S){} 14 void f(this S, int){} 15 protected: 16 void g(this auto){} 17 void h(this auto&){} 18 void i(this S){} 19 void i(this S, int){} 20 }; 21 22 void test() { 23 S s; 24 s.a(); 25 // CHECK: call void @"??$a@US@@@S@@SAX_VU0@@Z" 26 s.b(); 27 // CHECK: call void @"??$b@US@@@S@@SAX_VAEAU0@@Z" 28 s.c(); 29 // CHECK: call void @"?c@S@@SAX_VU1@@Z" 30 s.c(0); 31 // CHECK: call void @"?c@S@@SAX_VU1@H@Z" 32 s.d(); 33 // CHECK: call void @"??$d@US@@@S@@CAX_VU0@@Z" 34 s.e(); 35 // CHECK: call void @"??$e@US@@@S@@CAX_VAEAU0@@Z" 36 s.f(); 37 // CHECK: call void @"?f@S@@CAX_VU1@@Z" 38 s.f(0); 39 // CHECK: call void @"?f@S@@CAX_VU1@H@Z" 40 s.g(); 41 // CHECK: call void @"??$g@US@@@S@@KAX_VU0@@Z" 42 s.h(); 43 // CHECK: call void @"??$h@US@@@S@@KAX_VAEAU0@@Z" 44 s.i(); 45 // CHECK: call void @"?i@S@@KAX_VU1@@Z" 46 s.i(0); 47 // CHECK: call void @"?i@S@@KAX_VU1@H@Z" 48 } 49 50 51 struct S2 { 52 int i = 0; 53 void foo(this const S2&, int); 54 }; 55 struct T { 56 S2 bar(this const T&, int); 57 }; 58 void chain_test() { 59 T t; 60 t.bar(0).foo(0); 61 } 62 // CHECK: define {{.*}}chain_test{{.*}} 63 // CHECK-NEXT: entry: 64 // CHECK: {{.*}} = alloca %struct.T, align 1 65 // CHECK: {{.*}} = alloca %struct.S2, align 4 66 // CHECK: %call = call i32 @"?bar@T@@SA?AUS2@@_VAEBU1@H@Z"{{.*}} 67 // CHECK: %coerce.dive = getelementptr inbounds nuw %struct.S2, {{.*}} %{{.*}}, i32 0, i32 0 68 // CHECK store i32 %call, ptr %coerce.dive, align 4 69 // CHECK: call void @"?foo@S2@@SAX_VAEBU1@H@Z" 70 // CHECK: ret void 71