Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx0x-initializer-array.cpp
blob79b6df515a0edf08fd9cf6af77d75c63efa75979
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s -Wno-address-of-temporary | FileCheck %s
3 // CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1]
5 struct A { int a[1]; };
6 typedef A x[];
7 int f() {
8 x{{{1}}};
9 // CHECK-LABEL: define{{.*}} i32 @_Z1fv
10 // CHECK: store i32 1
11 // (It's okay if the output changes here, as long as we don't crash.)
12 return 0;
15 namespace ValueInitArrayOfMemPtr {
16 struct S {};
17 typedef int (S::*p);
18 typedef p a[3];
19 void f(const a &);
21 struct Agg1 {
22 int n;
23 p x;
26 struct Agg2 {
27 int n;
28 a x;
31 struct S1 {
32 p x;
33 S1();
36 // CHECK-LABEL: define{{.*}} void @_ZN22ValueInitArrayOfMemPtr1fEi
37 void f(int n) {
38 Agg1 a = { n };
39 // CHECK: store i32 -1,
41 Agg2 b = { n };
42 // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %{{.*}}, ptr align 4 @[[THREE_NULL_MEMPTRS]], i32 12, i1 false)
45 // Test dynamic initialization.
46 // CHECK-LABEL: define{{.*}} void @_ZN22ValueInitArrayOfMemPtr1gEMNS_1SEi
47 void g(p ptr) {
48 // CHECK: store i32 -1,
49 f(a{ptr});
53 namespace array_dtor {
54 struct S { S(); ~S(); };
55 using T = S[3];
56 void f(const T &);
57 void f(T *);
58 // CHECK-LABEL: define{{.*}} void @_ZN10array_dtor1gEv(
59 void g() {
60 // CHECK: %[[ARRAY:.*]] = alloca [3 x
61 // CHECK: br
63 // Construct loop.
64 // CHECK: call void @_ZN10array_dtor1SC1Ev(
65 // CHECK: br i1
67 // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
68 // CHECK: br
70 // Destruct loop.
71 // CHECK: call void @_ZN10array_dtor1SD1Ev(
72 // CHECK: br i1
73 f(T{});
75 // CHECK: ret void
77 // CHECK-LABEL: define{{.*}} void @_ZN10array_dtor1hEv(
78 void h() {
79 // CHECK: %[[ARRAY:.*]] = alloca [3 x
80 // CHECK: br
82 // CHECK: call void @_ZN10array_dtor1SC1Ev(
83 // CHECK: br i1
84 T &&t = T{};
86 // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
87 // CHECK: br
88 f(t);
90 // CHECK: call void @_ZN10array_dtor1SD1Ev(
91 // CHECK: br i1
93 // CHECK: ret void
95 // CHECK-LABEL: define{{.*}} void @_ZN10array_dtor1iEv(
96 void i() {
97 // CHECK: %[[ARRAY:.*]] = alloca [3 x
98 // CHECK: br
100 // CHECK: call void @_ZN10array_dtor1SC1Ev(
101 // CHECK: br i1
103 // CHECK: call void @_ZN10array_dtor1fEPA3_NS_1SE(
104 // CHECK: br
106 // CHECK: call void @_ZN10array_dtor1SD1Ev(
107 // CHECK: br i1
108 f(&T{});
110 // CHECK: ret void