Alexey Bataev | 6910347 | 2015-10-14 04:05:42 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility %s -o - | FileCheck %s |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fms-compatibility -emit-pch -o %t %s |
| 3 | // RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility -include-pch %t -verify %s -o - | FileCheck %s |
| 4 | // expected-no-diagnostics |
| 5 | |
| 6 | #ifndef HEADER |
| 7 | #define HEADER |
Alexey Bataev | 6910347 | 2015-10-14 04:05:42 +0000 | [diff] [blame] | 8 | |
| 9 | class Test1 { |
| 10 | private: |
| 11 | int x_; |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 12 | double y_; |
Alexey Bataev | 6910347 | 2015-10-14 04:05:42 +0000 | [diff] [blame] | 13 | |
| 14 | public: |
| 15 | Test1(int x) : x_(x) {} |
| 16 | __declspec(property(get = get_x)) int X; |
| 17 | int get_x() const { return x_; } |
| 18 | static Test1 *GetTest1() { return new Test1(10); } |
| 19 | }; |
| 20 | |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 21 | class S { |
| 22 | public: |
| 23 | __declspec(property(get=GetX,put=PutX)) int x[]; |
| 24 | int GetX(int i, int j) { return i+j; } |
| 25 | void PutX(int i, int j, int k) { j = i = k; } |
| 26 | }; |
| 27 | |
| 28 | template <typename T> |
| 29 | class St { |
| 30 | public: |
| 31 | __declspec(property(get=GetX,put=PutX)) T x[]; |
| 32 | T GetX(T i, T j) { return i+j; } |
| 33 | T GetX() { return 0; } |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 34 | T PutX(T i, T j, T k) { return j = i = k; } |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 35 | __declspec(property(get=GetY,put=PutY)) T y[]; |
| 36 | char GetY(char i, Test1 j) { return i+j.get_x(); } |
| 37 | void PutY(char i, int j, double k) { j = i = k; } |
| 38 | }; |
| 39 | |
| 40 | template <typename T> |
| 41 | void foo(T i, T j) { |
| 42 | St<T> bar; |
| 43 | Test1 t(i); |
| 44 | bar.x[i][j] = bar.x[i][j]; |
| 45 | bar.y[t.X][j] = bar.x[i][j]; |
| 46 | bar.x[i][j] = bar.y[bar.x[i][j]][t]; |
| 47 | } |
| 48 | |
| 49 | int idx() { return 7; } |
| 50 | |
Alexey Bataev | 6910347 | 2015-10-14 04:05:42 +0000 | [diff] [blame] | 51 | // CHECK-LABEL: main |
| 52 | int main(int argc, char **argv) { |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 53 | Test1 t(argc); |
| 54 | S *p1 = 0; |
| 55 | St<float> *p2 = 0; |
| 56 | // CHECK: call i32 @"\01?GetX@S@@QEAAHHH@Z"(%class.S* %{{.+}}, i32 223, i32 11) |
| 57 | int j = p1->x[223][11]; |
| 58 | // CHECK: [[J:%.+]] = load i32, i32* % |
| 59 | // CHECK-NEXT: call void @"\01?PutX@S@@QEAAXHHH@Z"(%class.S* %{{.+}}, i32 23, i32 1, i32 [[J]]) |
| 60 | p1->x[23][1] = j; |
| 61 | // CHECK: call float @"\01?GetX@?$St@M@@QEAAMMM@Z"(%class.St* %{{.+}}, float 2.230000e+02, float 1.100000e+01) |
| 62 | float j1 = p2->x[223][11]; |
| 63 | // CHECK: [[J1:%.+]] = load float, float* % |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 64 | // CHECK-NEXT: [[CALL:%.+]] = call float @"\01?PutX@?$St@M@@QEAAMMMM@Z"(%class.St* %{{.+}}, float 2.300000e+01, float 1.000000e+00, float [[J1]]) |
| 65 | // CHECK-NEXT: [[CONV:%.+]] = fptosi float [[CALL]] to i32 |
| 66 | // CHECK-NEXT: store i32 [[CONV]], i32* |
| 67 | argc = p2->x[23][1] = j1; |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 68 | // CHECK: [[IDX:%.+]] = call i32 @"\01?idx@@YAHXZ"() |
| 69 | // CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float |
| 70 | // CHECK-NEXT: [[GET:%.+]] = call float @"\01?GetX@?$St@M@@QEAAMMM@Z"(%class.St* %{{.+}}, float [[CONV]], float 1.000000e+00) |
| 71 | // CHECK-NEXT: [[INC:%.+]] = fadd float [[GET]], 1.000000e+00 |
| 72 | // CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 73 | // CHECK-NEXT: call float @"\01?PutX@?$St@M@@QEAAMMMM@Z"(%class.St* %{{.+}}, float [[CONV]], float 1.000000e+00, float [[INC]]) |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 74 | ++p2->x[idx()][1]; |
| 75 | // CHECK: call void @"\01??$foo@H@@YAXHH@Z"(i32 %{{.+}}, i32 %{{.+}}) |
| 76 | foo(argc, (int)argv[0][0]); |
| 77 | // CHECK: [[P2:%.+]] = load %class.St*, %class.St** % |
| 78 | // CHECK: [[T_X:%.+]] = call i32 @"\01?get_x@Test1@@QEBAHXZ"(%class.Test1* %{{.+}}) |
| 79 | // CHECK: [[P1:%.+]] = load %class.S*, %class.S** % |
| 80 | // CHECK: [[P1_X_22_33:%.+]] = call i32 @"\01?GetX@S@@QEAAHHH@Z"(%class.S* [[P1]], i32 22, i32 33) |
| 81 | // CHECK: [[CAST:%.+]] = sitofp i32 [[P1_X_22_33]] to double |
| 82 | // CHECK: [[ARGC:%.+]] = load i32, i32* % |
| 83 | // CHECK: [[CAST2:%.+]] = trunc i32 [[T_X]] to i8 |
| 84 | // CHECK: call void @"\01?PutY@?$St@M@@QEAAXDHN@Z"(%class.St* [[P2]], i8 [[CAST2]], i32 [[ARGC]], double [[CAST]]) |
| 85 | p2->y[t.X][argc] = p1->x[22][33]; |
| 86 | // CHECK: [[P2_1:%.+]] = load %class.St*, %class.St** |
| 87 | // CHECK: [[P2_2:%.+]] = load %class.St*, %class.St** |
| 88 | // CHECK: [[P1:%.+]] = load %class.S*, %class.S** |
| 89 | // CHECK: [[ARGC:%.+]] = load i32, i32* % |
| 90 | // CHECK: [[P1_X_ARGC_0:%.+]] = call i32 @"\01?GetX@S@@QEAAHHH@Z"(%class.S* [[P1]], i32 [[ARGC]], i32 0) |
| 91 | // CHECK: [[CAST:%.+]] = trunc i32 [[P1_X_ARGC_0]] to i8 |
| 92 | // CHECK: [[P2_Y_p1_X_ARGC_0_T:%.+]] = call i8 @"\01?GetY@?$St@M@@QEAADDVTest1@@@Z"(%class.St* [[P2_2]], i8 [[CAST]], %class.Test1* %{{.+}}) |
| 93 | // CHECK: [[CAST:%.+]] = sitofp i8 [[P2_Y_p1_X_ARGC_0_T]] to float |
| 94 | // CHECK: [[J:%.+]] = load i32, i32* % |
| 95 | // CHECK: [[CAST1:%.+]] = sitofp i32 [[J]] to float |
| 96 | // CHECK: [[J:%.+]] = load i32, i32* % |
| 97 | // CHECK: [[CAST2:%.+]] = sitofp i32 [[J]] to float |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 98 | // CHECK: call float @"\01?PutX@?$St@M@@QEAAMMMM@Z"(%class.St* [[P2_1]], float [[CAST2]], float [[CAST1]], float [[CAST]]) |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 99 | p2->x[j][j] = p2->y[p1->x[argc][0]][t]; |
Alexey Bataev | 6910347 | 2015-10-14 04:05:42 +0000 | [diff] [blame] | 100 | // CHECK: [[CALL:%.+]] = call %class.Test1* @"\01?GetTest1@Test1@@SAPEAV1@XZ"() |
| 101 | // CHECK-NEXT: call i32 @"\01?get_x@Test1@@QEBAHXZ"(%class.Test1* [[CALL]]) |
| 102 | return Test1::GetTest1()->X; |
| 103 | } |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 104 | |
| 105 | // CHECK: define linkonce_odr void @"\01??$foo@H@@YAXHH@Z"(i32 %{{.+}}, i32 %{{.+}}) |
| 106 | // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR:%.+]], i32 %{{.+}} i32 %{{.+}}) |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 107 | // CHECK: call i32 @"\01?PutX@?$St@H@@QEAAHHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}) |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 108 | // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}} i32 %{{.+}}) |
| 109 | // CHECK: call void @"\01?PutY@?$St@H@@QEAAXDHN@Z"(%class.St{{.+}}* [[BAR]], i8 %{{.+}}, i32 %{{.+}}, double %{{.+}} |
| 110 | // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}} i32 %{{.+}}) |
| 111 | // CHECK: call i8 @"\01?GetY@?$St@H@@QEAADDVTest1@@@Z"(%class.St{{.+}}* [[BAR]], i8 %{{.+}}, %class.Test1* %{{.+}}) |
Alexey Bataev | 60520e2 | 2015-12-10 04:38:18 +0000 | [diff] [blame] | 112 | // CHECK: call i32 @"\01?PutX@?$St@H@@QEAAHHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}) |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 113 | #endif //HEADER |