| 1 |
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
| 2 |
|
| 3 |
struct Agg { const char * x; const char * y; constexpr Agg() : x(0), y(0) {} }; |
| 4 |
|
| 5 |
struct Struct { |
| 6 |
constexpr static const char *name = "foo"; |
| 7 |
|
| 8 |
constexpr static __complex float complexValue = 42.0; |
| 9 |
|
| 10 |
static constexpr const Agg &agg = Agg(); |
| 11 |
|
| 12 |
Struct(); |
| 13 |
Struct(int x); |
| 14 |
}; |
| 15 |
|
| 16 |
void use(int n, const char *c); |
| 17 |
|
| 18 |
Struct *getPtr(); |
| 19 |
|
| 20 |
// CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1 |
| 21 |
|
| 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]]) |
| 40 |
} |
| 41 |
|
| 42 |
void use(int n, __complex float v); |
| 43 |
|
| 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]]) |
| 80 |
} |
| 81 |
|
| 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]]) |
| 98 |
} |