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) {} };
6 constexpr static const char *name
= "foo";
8 constexpr static __complex
float complexValue
= 42.0;
10 static constexpr const Agg
&agg
= Agg();
16 void use(int n
, const char *c
);
20 // CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1
22 void scalarStaticVariableInMemberExpr(Struct
*ptr
, Struct
&ref
) {
24 // CHECK: call void @_Z3useiPKc(i32 noundef 1, ptr noundef @[[STR]])
27 // CHECK: call void @_Z3useiPKc(i32 noundef 2, ptr noundef @[[STR]])
29 // CHECK: load ptr, ptr %{{.*}}, align 8
30 // CHECK: call void @_Z3useiPKc(i32 noundef 3, ptr noundef @[[STR]])
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]])
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]])
88 // CHECK: %[[value1:.*]] = load ptr, ptr @_ZGRN6Struct3aggE_, align 8
89 // CHECK: call void @_Z3useiPKc(i32 noundef 2, ptr noundef %[[value1]])
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]])
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]])