1 // RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility %s -o - | FileCheck %s 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 8 9 class Test1 { 10 private: 11 int x_; 12 double y_; 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 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; } 34 void PutX(T i, T j, T k) { j = i = k; } 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 51 // CHECK-LABEL: main 52 int main(int argc, char **argv) { 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* % 64 // CHECK-NEXT: call void @"\01?PutX@?$St@M@@QEAAXMMM@Z"(%class.St* %{{.+}}, float 2.300000e+01, float 1.000000e+00, float [[J1]]) 65 p2->x[23][1] = j1; 66 // CHECK: [[IDX:%.+]] = call i32 @"\01?idx@@YAHXZ"() 67 // CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float 68 // CHECK-NEXT: [[GET:%.+]] = call float @"\01?GetX@?$St@M@@QEAAMMM@Z"(%class.St* %{{.+}}, float [[CONV]], float 1.000000e+00) 69 // CHECK-NEXT: [[INC:%.+]] = fadd float [[GET]], 1.000000e+00 70 // CHECK-NEXT: [[CONV:%.+]] = sitofp i32 [[IDX]] to float 71 // CHECK-NEXT: call void @"\01?PutX@?$St@M@@QEAAXMMM@Z"(%class.St* %{{.+}}, float [[CONV]], float 1.000000e+00, float [[INC]]) 72 ++p2->x[idx()][1]; 73 // CHECK: call void @"\01??$foo@H@@YAXHH@Z"(i32 %{{.+}}, i32 %{{.+}}) 74 foo(argc, (int)argv[0][0]); 75 // CHECK: [[P2:%.+]] = load %class.St*, %class.St** % 76 // CHECK: [[T_X:%.+]] = call i32 @"\01?get_x@Test1@@QEBAHXZ"(%class.Test1* %{{.+}}) 77 // CHECK: [[P1:%.+]] = load %class.S*, %class.S** % 78 // CHECK: [[P1_X_22_33:%.+]] = call i32 @"\01?GetX@S@@QEAAHHH@Z"(%class.S* [[P1]], i32 22, i32 33) 79 // CHECK: [[CAST:%.+]] = sitofp i32 [[P1_X_22_33]] to double 80 // CHECK: [[ARGC:%.+]] = load i32, i32* % 81 // CHECK: [[CAST2:%.+]] = trunc i32 [[T_X]] to i8 82 // CHECK: call void @"\01?PutY@?$St@M@@QEAAXDHN@Z"(%class.St* [[P2]], i8 [[CAST2]], i32 [[ARGC]], double [[CAST]]) 83 p2->y[t.X][argc] = p1->x[22][33]; 84 // CHECK: [[P2_1:%.+]] = load %class.St*, %class.St** 85 // CHECK: [[P2_2:%.+]] = load %class.St*, %class.St** 86 // CHECK: [[P1:%.+]] = load %class.S*, %class.S** 87 // CHECK: [[ARGC:%.+]] = load i32, i32* % 88 // CHECK: [[P1_X_ARGC_0:%.+]] = call i32 @"\01?GetX@S@@QEAAHHH@Z"(%class.S* [[P1]], i32 [[ARGC]], i32 0) 89 // CHECK: [[CAST:%.+]] = trunc i32 [[P1_X_ARGC_0]] to i8 90 // CHECK: [[P2_Y_p1_X_ARGC_0_T:%.+]] = call i8 @"\01?GetY@?$St@M@@QEAADDVTest1@@@Z"(%class.St* [[P2_2]], i8 [[CAST]], %class.Test1* %{{.+}}) 91 // CHECK: [[CAST:%.+]] = sitofp i8 [[P2_Y_p1_X_ARGC_0_T]] to float 92 // CHECK: [[J:%.+]] = load i32, i32* % 93 // CHECK: [[CAST1:%.+]] = sitofp i32 [[J]] to float 94 // CHECK: [[J:%.+]] = load i32, i32* % 95 // CHECK: [[CAST2:%.+]] = sitofp i32 [[J]] to float 96 // CHECK: call void @"\01?PutX@?$St@M@@QEAAXMMM@Z"(%class.St* [[P2_1]], float [[CAST2]], float [[CAST1]], float [[CAST]]) 97 p2->x[j][j] = p2->y[p1->x[argc][0]][t]; 98 // CHECK: [[CALL:%.+]] = call %class.Test1* @"\01?GetTest1@Test1@@SAPEAV1@XZ"() 99 // CHECK-NEXT: call i32 @"\01?get_x@Test1@@QEBAHXZ"(%class.Test1* [[CALL]]) 100 return Test1::GetTest1()->X; 101 } 102 103 // CHECK: define linkonce_odr void @"\01??$foo@H@@YAXHH@Z"(i32 %{{.+}}, i32 %{{.+}}) 104 // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR:%.+]], i32 %{{.+}} i32 %{{.+}}) 105 // CHECK: call void @"\01?PutX@?$St@H@@QEAAXHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}) 106 // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}} i32 %{{.+}}) 107 // CHECK: call void @"\01?PutY@?$St@H@@QEAAXDHN@Z"(%class.St{{.+}}* [[BAR]], i8 %{{.+}}, i32 %{{.+}}, double %{{.+}} 108 // CHECK: call i32 @"\01?GetX@?$St@H@@QEAAHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}} i32 %{{.+}}) 109 // CHECK: call i8 @"\01?GetY@?$St@H@@QEAADDVTest1@@@Z"(%class.St{{.+}}* [[BAR]], i8 %{{.+}}, %class.Test1* %{{.+}}) 110 // CHECK: call void @"\01?PutX@?$St@H@@QEAAXHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}) 111 #endif //HEADER 112