NAKAMURA Takumi | 4a49e16 | 2016-03-21 11:40:15 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - | tee /tmp/__.bak | FileCheck %s |
Faisal Vali | dc6b596 | 2016-03-21 09:25:37 +0000 | [diff] [blame] | 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' |
NAKAMURA Takumi | 4a49e16 | 2016-03-21 11:40:15 +0000 | [diff] [blame^] | 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* |
Faisal Vali | dc6b596 | 2016-03-21 09:25:37 +0000 | [diff] [blame] | 18 | // copy the contents ... |
NAKAMURA Takumi | 4a49e16 | 2016-03-21 11:40:15 +0000 | [diff] [blame^] | 19 | //CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[I1]], i8* %[[I2]], i32 8, i32 8, i1 false) |
Faisal Vali | dc6b596 | 2016-03-21 09:25:37 +0000 | [diff] [blame] | 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) |
NAKAMURA Takumi | 4a49e16 | 2016-03-21 11:40:15 +0000 | [diff] [blame^] | 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 |