• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
Test1(int x)15   Test1(int x) : x_(x) {}
16   __declspec(property(get = get_x)) int X;
get_x() const17   int get_x() const { return x_; }
GetTest1()18   static Test1 *GetTest1() { return new Test1(10); }
19 };
20 
21 class S {
22 public:
23   __declspec(property(get=GetX,put=PutX)) int x[];
GetX(int i,int j)24   int GetX(int i, int j) { return i+j; }
PutX(int i,int j,int k)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[];
GetX(T i,T j)32   T GetX(T i, T j) { return i+j; }
GetX()33   T GetX() { return 0; }
PutX(T i,T j,T k)34   T PutX(T i, T j, T k) { return j = i = k; }
35   __declspec(property(get=GetY,put=PutY)) T y[];
GetY(char i,Test1 j)36   char GetY(char i,  Test1 j) { return i+j.get_x(); }
PutY(char i,int j,double k)37   void PutY(char i, int j, double k) { j = i = k; }
38 };
39 
40 template <typename T>
foo(T i,T j)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 
idx()49 int idx() { return 7; }
50 
51 // CHECK-LABEL: main
main(int argc,char ** argv)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:%.+]] = 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;
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
73   // CHECK-NEXT: call float @"\01?PutX@?$St@M@@QEAAMMMM@Z"(%class.St* %{{.+}}, float [[CONV]], float 1.000000e+00, float [[INC]])
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
98   // CHECK: call float @"\01?PutX@?$St@M@@QEAAMMMM@Z"(%class.St* [[P2_1]], float [[CAST2]], float [[CAST1]], float [[CAST]])
99   p2->x[j][j] = p2->y[p1->x[argc][0]][t];
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 }
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 %{{.+}})
107 // CHECK: call i32 @"\01?PutX@?$St@H@@QEAAHHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}})
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* %{{.+}})
112 // CHECK: call i32 @"\01?PutX@?$St@H@@QEAAHHHH@Z"(%class.St{{.+}}* [[BAR]], i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}})
113 #endif //HEADER
114