1 // RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - | FileCheck %s 2 //CHECK: %[[A_LAMBDA:.*]] = type { %struct.A } 3 //CHECK: %[[B_LAMBDA:.*]] = type { %struct.B* } 4 struct A { 5 double a = 111; 6 auto foo() { return [*this] { return a; }; } 7 }; 8 9 namespace ns1 { 10 int X = A{}.foo()(); 11 } //end ns1 12 13 //CHECK: @"\01?foo@A@@QAE?A?<auto>@@XZ"(%struct.A* %this, %class.anon* noalias sret %[[A_LAMBDA_RETVAL:.*]]) 14 // get the first object with the closure type, which is of type 'struct.A' 15 //CHECK: %[[I0:.+]] = getelementptr inbounds %[[A_LAMBDA]], %[[A_LAMBDA]]* %[[A_LAMBDA_RETVAL]], i32 0, i32 0 16 //CHECK: %[[I1:.+]] = bitcast %struct.A* %[[I0]] to i8* 17 //CHECK: %[[I2:.+]] = bitcast %struct.A* %this1 to i8* 18 // copy the contents ... 19 //CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[I1]], i8* %[[I2]], i32 8, i32 8, i1 false) 20 21 struct B { 22 double b = 222; 23 auto bar() { return [this] { return b; }; }; 24 }; 25 26 namespace ns2 { 27 int X = B{}.bar()(); 28 } 29 //CHECK: @"\01?bar@B@@QAE?A?<auto>@@XZ"(%struct.B* %this, %class.anon.0* noalias sret %agg.result) 30 //CHECK: %[[I20:.+]] = getelementptr inbounds %class.anon.0, %class.anon.0* %agg.result, i32 0, i32 0 31 //CHECK: store %struct.B* %this1, %struct.B** %[[I20]], align 4 32