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, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
27 // CHECK: call void @_Z3useiPKc(i32 noundef 2, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
29 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
30 // CHECK: call void @_Z3useiPKc(i32 noundef 3, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
32 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
33 // CHECK: call void @_Z3useiPKc(i32 noundef 4, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
34 use(5, Struct(2).name
);
35 // CHECK: call void @_ZN6StructC1Ei(%struct.Struct* {{[^,]*}} %{{.*}}, i32 noundef 2)
36 // CHECK: call void @_Z3useiPKc(i32 noundef 5, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
37 use(6, getPtr()->name
);
38 // CHECK: call noundef %struct.Struct* @_Z6getPtrv()
39 // CHECK: call void @_Z3useiPKc(i32 noundef 6, i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
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, float* %[[coerce0:.*]].{{.*}}, align 4
47 // CHECK: store float 0.000000e+00, float* %[[coerce0]].{{.*}}, align 4
48 // CHECK: %[[cast0:.*]] = bitcast { float, float }* %[[coerce0]] to <2 x float>*
49 // CHECK: %[[vector0:.*]] = load <2 x float>, <2 x float>* %[[cast0]], align 4
50 // CHECK: call void @_Z3useiCf(i32 noundef 1, <2 x float> noundef %[[vector0]])
52 use(2, s
.complexValue
);
53 // CHECK: store float 4.200000e+01, float* %[[coerce1:.*]].{{.*}}, align 4
54 // CHECK: store float 0.000000e+00, float* %[[coerce1]].{{.*}}, align 4
55 // CHECK: %[[cast1:.*]] = bitcast { float, float }* %[[coerce1]] to <2 x float>*
56 // CHECK: %[[vector1:.*]] = load <2 x float>, <2 x float>* %[[cast1]], align 4
57 // CHECK: call void @_Z3useiCf(i32 noundef 2, <2 x float> noundef %[[vector1]])
58 use(3, ptr
->complexValue
);
59 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
60 // CHECK: store float 4.200000e+01, float* %[[coerce2:.*]].{{.*}}, align 4
61 // CHECK: store float 0.000000e+00, float* %[[coerce2]].{{.*}}, align 4
62 // CHECK: %[[cast2:.*]] = bitcast { float, float }* %[[coerce2]] to <2 x float>*
63 // CHECK: %[[vector2:.*]] = load <2 x float>, <2 x float>* %[[cast2]], align 4
64 // CHECK: call void @_Z3useiCf(i32 noundef 3, <2 x float> noundef %[[vector2]])
65 use(4, ref
.complexValue
);
66 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
67 // CHECK: store float 4.200000e+01, float* %[[coerce3:.*]].{{.*}}, align 4
68 // CHECK: store float 0.000000e+00, float* %[[coerce3]].{{.*}}, align 4
69 // CHECK: %[[cast3:.*]] = bitcast { float, float }* %[[coerce3]] to <2 x float>*
70 // CHECK: %[[vector3:.*]] = load <2 x float>, <2 x float>* %[[cast3]], align 4
71 // CHECK: call void @_Z3useiCf(i32 noundef 4, <2 x float> noundef %[[vector3]])
72 use(5, Struct(2).complexValue
);
73 // CHECK: call void @_ZN6StructC1Ei(%struct.Struct* {{[^,]*}} %{{.*}}, i32 noundef 2)
74 // CHECK: store float 4.200000e+01, float* %[[coerce4:.*]].{{.*}}, align 4
75 // CHECK: store float 0.000000e+00, float* %[[coerce4]].{{.*}}, align 4
76 // CHECK: %[[cast4:.*]] = bitcast { float, float }* %[[coerce4]] to <2 x float>*
77 // CHECK: %[[vector4:.*]] = load <2 x float>, <2 x float>* %[[cast4]], align 4
78 // CHECK: call void @_Z3useiCf(i32 noundef 5, <2 x float> noundef %[[vector4]])
79 use(6, getPtr()->complexValue
);
80 // CHECK: call noundef %struct.Struct* @_Z6getPtrv()
81 // CHECK: store float 4.200000e+01, float* %[[coerce5:.*]].{{.*}}, align 4
82 // CHECK: store float 0.000000e+00, float* %[[coerce5]].{{.*}}, align 4
83 // CHECK: %[[cast5:.*]] = bitcast { float, float }* %[[coerce5]] to <2 x float>*
84 // CHECK: %[[vector5:.*]] = load <2 x float>, <2 x float>* %[[cast5]], align 4
85 // CHECK: call void @_Z3useiCf(i32 noundef 6, <2 x float> noundef %[[vector5]])
88 void aggregateRefInMemberExpr(Struct
*ptr
, Struct
&ref
) {
89 use(1, Struct::agg
.x
);
90 // CHECK: %[[value0:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8
91 // CHECK: call void @_Z3useiPKc(i32 noundef 1, i8* noundef %[[value0]])
94 // CHECK: %[[value1:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8
95 // CHECK: call void @_Z3useiPKc(i32 noundef 2, i8* noundef %[[value1]])
97 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
98 // CHECK: %[[value2:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8
99 // CHECK: call void @_Z3useiPKc(i32 noundef 3, i8* noundef %[[value2]])
101 // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
102 // CHECK: %[[value3:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8
103 // CHECK: call void @_Z3useiPKc(i32 noundef 4, i8* noundef %[[value3]])