xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/new-array-init.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z2fni
fn(int n)4f4a2713aSLionel Sambuc void fn(int n) {
5f4a2713aSLionel Sambuc   // CHECK: icmp ult i{{32|64}} %{{[^ ]+}}, 3
6f4a2713aSLionel Sambuc   // CHECK: store i32 1
7f4a2713aSLionel Sambuc   // CHECK: store i32 2
8f4a2713aSLionel Sambuc   // CHECK: store i32 3
9*0a6a1f1dSLionel Sambuc   // CHECK: sub {{.*}}, 12
10*0a6a1f1dSLionel Sambuc   // CHECK: call void @llvm.memset
11f4a2713aSLionel Sambuc   new int[n] { 1, 2, 3 };
12f4a2713aSLionel Sambuc }
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z15const_underflowv
const_underflow()15f4a2713aSLionel Sambuc void const_underflow() {
16f4a2713aSLionel Sambuc   // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
17f4a2713aSLionel Sambuc   // CHECK: call noalias i8* @_Zna{{.}}(i{{32|64}} -1)
18f4a2713aSLionel Sambuc   new int[2] { 1, 2, 3 };
19f4a2713aSLionel Sambuc }
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z11const_exactv
const_exact()22f4a2713aSLionel Sambuc void const_exact() {
23f4a2713aSLionel Sambuc   // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
24f4a2713aSLionel Sambuc   // CHECK-NOT: icmp eq i32*
25f4a2713aSLionel Sambuc   new int[3] { 1, 2, 3 };
26f4a2713aSLionel Sambuc }
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z16const_sufficientv
const_sufficient()29f4a2713aSLionel Sambuc void const_sufficient() {
30f4a2713aSLionel Sambuc   // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
31f4a2713aSLionel Sambuc   new int[4] { 1, 2, 3 };
32f4a2713aSLionel Sambuc   // CHECK: ret void
33f4a2713aSLionel Sambuc }
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_Z22check_array_value_initv
check_array_value_init()36*0a6a1f1dSLionel Sambuc void check_array_value_init() {
37*0a6a1f1dSLionel Sambuc   struct S;
38*0a6a1f1dSLionel Sambuc   new (int S::*[3][4][5]) ();
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc   // CHECK: call noalias i8* @_Zna{{.}}(i{{32 240|64 480}})
41*0a6a1f1dSLionel Sambuc   // CHECK: getelementptr inbounds i{{32|64}}* {{.*}}, i{{32|64}} 60
42*0a6a1f1dSLionel Sambuc 
43*0a6a1f1dSLionel Sambuc   // CHECK: phi
44*0a6a1f1dSLionel Sambuc   // CHECK: store i{{32|64}} -1,
45*0a6a1f1dSLionel Sambuc   // CHECK: getelementptr inbounds i{{32|64}}* {{.*}}, i{{32|64}} 1
46*0a6a1f1dSLionel Sambuc   // CHECK: icmp eq
47*0a6a1f1dSLionel Sambuc   // CHECK: br i1
48*0a6a1f1dSLionel Sambuc }
49