[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / member-expr-references-variable.cpp
blob4a6756d22c40c46d8e1d54a51f58331578c13f05
1 // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
3 struct Agg { const char * x; const char * y; constexpr Agg() : x(0), y(0) {} };
5 struct Struct {
6 constexpr static const char *name = "foo";
8 constexpr static __complex float complexValue = 42.0;
10 static constexpr const Agg &agg = Agg();
12 Struct();
13 Struct(int x);
16 void use(int n, const char *c);
18 Struct *getPtr();
20 // CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1
22 void scalarStaticVariableInMemberExpr(Struct *ptr, Struct &ref) {
23 use(1, Struct::name);
24 // CHECK: call void @_Z3useiPKc(i32 noundef 1, ptr noundef @[[STR]])
25 Struct s;
26 use(2, s.name);
27 // CHECK: call void @_Z3useiPKc(i32 noundef 2, ptr noundef @[[STR]])
28 use(3, ptr->name);
29 // CHECK: load ptr, ptr %{{.*}}, align 8
30 // CHECK: call void @_Z3useiPKc(i32 noundef 3, ptr noundef @[[STR]])
31 use(4, ref.name);
32 // CHECK: load ptr, ptr %{{.*}}, align 8
33 // CHECK: call void @_Z3useiPKc(i32 noundef 4, ptr noundef @[[STR]])
34 use(5, Struct(2).name);
35 // CHECK: call void @_ZN6StructC1Ei(ptr {{[^,]*}} %{{.*}}, i32 noundef 2)
36 // CHECK: call void @_Z3useiPKc(i32 noundef 5, ptr noundef @[[STR]])
37 use(6, getPtr()->name);
38 // CHECK: call noundef ptr @_Z6getPtrv()
39 // CHECK: call void @_Z3useiPKc(i32 noundef 6, ptr noundef @[[STR]])
42 void use(int n, __complex float v);
44 void complexStaticVariableInMemberExpr(Struct *ptr, Struct &ref) {
45 use(1, Struct::complexValue);
46 // CHECK: store float 4.200000e+01, ptr %[[coerce0:.*]].{{.*}}, align 4
47 // CHECK: store float 0.000000e+00, ptr %[[coerce0]].{{.*}}, align 4
48 // CHECK: %[[vector0:.*]] = load <2 x float>, ptr %[[coerce0]], align 4
49 // CHECK: call void @_Z3useiCf(i32 noundef 1, <2 x float> noundef %[[vector0]])
50 Struct s;
51 use(2, s.complexValue);
52 // CHECK: store float 4.200000e+01, ptr %[[coerce1:.*]].{{.*}}, align 4
53 // CHECK: store float 0.000000e+00, ptr %[[coerce1]].{{.*}}, align 4
54 // CHECK: %[[vector1:.*]] = load <2 x float>, ptr %[[coerce1]], align 4
55 // CHECK: call void @_Z3useiCf(i32 noundef 2, <2 x float> noundef %[[vector1]])
56 use(3, ptr->complexValue);
57 // CHECK: load ptr, ptr %{{.*}}, align 8
58 // CHECK: store float 4.200000e+01, ptr %[[coerce2:.*]].{{.*}}, align 4
59 // CHECK: store float 0.000000e+00, ptr %[[coerce2]].{{.*}}, align 4
60 // CHECK: %[[vector2:.*]] = load <2 x float>, ptr %[[coerce2]], align 4
61 // CHECK: call void @_Z3useiCf(i32 noundef 3, <2 x float> noundef %[[vector2]])
62 use(4, ref.complexValue);
63 // CHECK: load ptr, ptr %{{.*}}, align 8
64 // CHECK: store float 4.200000e+01, ptr %[[coerce3:.*]].{{.*}}, align 4
65 // CHECK: store float 0.000000e+00, ptr %[[coerce3]].{{.*}}, align 4
66 // CHECK: %[[vector3:.*]] = load <2 x float>, ptr %[[coerce3]], align 4
67 // CHECK: call void @_Z3useiCf(i32 noundef 4, <2 x float> noundef %[[vector3]])
68 use(5, Struct(2).complexValue);
69 // CHECK: call void @_ZN6StructC1Ei(ptr {{[^,]*}} %{{.*}}, i32 noundef 2)
70 // CHECK: store float 4.200000e+01, ptr %[[coerce4:.*]].{{.*}}, align 4
71 // CHECK: store float 0.000000e+00, ptr %[[coerce4]].{{.*}}, align 4
72 // CHECK: %[[vector4:.*]] = load <2 x float>, ptr %[[coerce4]], align 4
73 // CHECK: call void @_Z3useiCf(i32 noundef 5, <2 x float> noundef %[[vector4]])
74 use(6, getPtr()->complexValue);
75 // CHECK: call noundef ptr @_Z6getPtrv()
76 // CHECK: store float 4.200000e+01, ptr %[[coerce5:.*]].{{.*}}, align 4
77 // CHECK: store float 0.000000e+00, ptr %[[coerce5]].{{.*}}, align 4
78 // CHECK: %[[vector5:.*]] = load <2 x float>, ptr %[[coerce5]], align 4
79 // CHECK: call void @_Z3useiCf(i32 noundef 6, <2 x float> noundef %[[vector5]])
82 void aggregateRefInMemberExpr(Struct *ptr, Struct &ref) {
83 use(1, Struct::agg.x);
84 // CHECK: %[[value0:.*]] = load ptr, ptr @_ZGRN6Struct3aggE_, align 8
85 // CHECK: call void @_Z3useiPKc(i32 noundef 1, ptr noundef %[[value0]])
86 Struct s;
87 use(2, s.agg.x);
88 // CHECK: %[[value1:.*]] = load ptr, ptr @_ZGRN6Struct3aggE_, align 8
89 // CHECK: call void @_Z3useiPKc(i32 noundef 2, ptr noundef %[[value1]])
90 use(3, ptr->agg.x);
91 // CHECK: load ptr, ptr %{{.*}}, align 8
92 // CHECK: %[[value2:.*]] = load ptr, ptr @_ZGRN6Struct3aggE_, align 8
93 // CHECK: call void @_Z3useiPKc(i32 noundef 3, ptr noundef %[[value2]])
94 use(4, ref.agg.x);
95 // CHECK: load ptr, ptr %{{.*}}, align 8
96 // CHECK: %[[value3:.*]] = load ptr, ptr @_ZGRN6Struct3aggE_, align 8
97 // CHECK: call void @_Z3useiPKc(i32 noundef 4, ptr noundef %[[value3]])