brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 0d527e1 Raw
64 lines · cpp
1// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -o - %s  2>&1 | FileCheck %s2 3struct A {4  A();5  A(const A &);6  int x;7};8void decayToFp(int (*f)(A));9void test() {10  auto ld = [](A a) {11    static int calls = 0;12    ++calls;13    return a.x + calls;14  };15  decayToFp(ld);16  ld(A{});17}18 19// CHECK: define internal x86_thiscallcc noundef i3220// CHECK-SAME: @"??R<lambda_0>@?0??test@@YAXXZ@QBE?A?<auto>@@UA@@@Z"21// CHECK-SAME: (ptr noundef %this, ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])22// CHECK: %[[V:.*]] = getelementptr inbounds nuw <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 023// CHECK: %call = call x86_thiscallcc noundef i3224// CHECK-SAME: @"?__impl@<lambda_0>@?0??test@@YAXXZ@QBE?A?<auto>@@UA@@@Z"25// CHECK-SAME: (ptr noundef %this, ptr dead_on_return noundef %[[V]])26 27// CHECK: define internal noundef i3228// CHECK-SAME: @"?__invoke@<lambda_0>@?0??test@@YAXXZ@CA?A?<auto>@@UA@@@Z"29// CHECK-SAME: (ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])30// CHECK: %unused.capture = alloca %class.anon, align 131// CHECK: %[[VAR:.*]] = getelementptr inbounds nuw <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 032// CHECK: %call = call x86_thiscallcc noundef i3233// CHECK-SAME: @"?__impl@<lambda_0>@?0??test@@YAXXZ@QBE?A?<auto>@@UA@@@Z"34// CHECK-SAME: (ptr noundef %unused.capture, ptr dead_on_return noundef %[[VAR]])35// CHECK: ret i32 %call36 37// CHECK: define internal x86_thiscallcc noundef i3238// CHECK-SAME: @"?__impl@<lambda_0>@?0??test@@YAXXZ@QBE?A?<auto>@@UA@@@Z"39// CHECK-SAME: (ptr noundef %this, ptr dead_on_return noundef %[[ARG:.*]])40// CHECK: %this.addr = alloca ptr, align 441// CHECK: store ptr %this, ptr %this.addr, align 442// CHECK: %this1 = load ptr, ptr %this.addr, align 443// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R<lambda_0>44// CHECK: %inc = add nsw i32 %{{.*}}, 145// CHECK: store i32 %inc, ptr @"?calls@?1???R<lambda_0>46// CHECK: %{{.*}} = getelementptr inbounds nuw %struct.A, ptr %{{.*}}, i32 0, i32 047// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 448// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R<lambda_0>49// CHECK: %add = add nsw i32 %{{.*}}, %{{.*}}50// CHECK: ret i32 %add51 52// Make sure we don't try to copy an uncopyable type.53struct B {54  B();55  B(B &);56  void operator=(B);57  long long x;58} b;59 60void f() {61  [](B) {}(b);62}63 64