1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc typedef __typeof__(sizeof(0)) size_t;
4f4a2713aSLionel Sambuc
5*0a6a1f1dSLionel Sambuc // Declare an 'operator new' template to tickle a bug in __builtin_operator_new.
6*0a6a1f1dSLionel Sambuc template<typename T> void *operator new(size_t, int (*)(T));
7*0a6a1f1dSLionel Sambuc
8f4a2713aSLionel Sambuc // Ensure that this declaration doesn't cause operator new to lose its
9f4a2713aSLionel Sambuc // 'noalias' attribute.
10f4a2713aSLionel Sambuc void *operator new[](size_t);
11f4a2713aSLionel Sambuc
t1()12f4a2713aSLionel Sambuc void t1() {
13f4a2713aSLionel Sambuc delete new int;
14f4a2713aSLionel Sambuc delete [] new int [3];
15f4a2713aSLionel Sambuc }
16f4a2713aSLionel Sambuc
17f4a2713aSLionel Sambuc // CHECK: declare noalias i8* @_Znwm(i64) [[ATTR_NOBUILTIN:#[^ ]*]]
18f4a2713aSLionel Sambuc // CHECK: declare void @_ZdlPv(i8*) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
19f4a2713aSLionel Sambuc // CHECK: declare noalias i8* @_Znam(i64) [[ATTR_NOBUILTIN]]
20f4a2713aSLionel Sambuc // CHECK: declare void @_ZdaPv(i8*) [[ATTR_NOBUILTIN_NOUNWIND]]
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc namespace std {
23f4a2713aSLionel Sambuc struct nothrow_t {};
24f4a2713aSLionel Sambuc }
25f4a2713aSLionel Sambuc std::nothrow_t nothrow;
26f4a2713aSLionel Sambuc
27f4a2713aSLionel Sambuc // Declare the reserved placement operators.
28f4a2713aSLionel Sambuc void *operator new(size_t, void*) throw();
29f4a2713aSLionel Sambuc void operator delete(void*, void*) throw();
30f4a2713aSLionel Sambuc void *operator new[](size_t, void*) throw();
31f4a2713aSLionel Sambuc void operator delete[](void*, void*) throw();
32f4a2713aSLionel Sambuc
33f4a2713aSLionel Sambuc // Declare the replaceable global allocation operators.
34f4a2713aSLionel Sambuc void *operator new(size_t, const std::nothrow_t &) throw();
35f4a2713aSLionel Sambuc void *operator new[](size_t, const std::nothrow_t &) throw();
36f4a2713aSLionel Sambuc void operator delete(void *, const std::nothrow_t &) throw();
37f4a2713aSLionel Sambuc void operator delete[](void *, const std::nothrow_t &) throw();
38f4a2713aSLionel Sambuc
t2(int * a)39f4a2713aSLionel Sambuc void t2(int* a) {
40f4a2713aSLionel Sambuc int* b = new (a) int;
41f4a2713aSLionel Sambuc }
42f4a2713aSLionel Sambuc
43f4a2713aSLionel Sambuc struct S {
44f4a2713aSLionel Sambuc int a;
45f4a2713aSLionel Sambuc };
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc // POD types.
t3()48f4a2713aSLionel Sambuc void t3() {
49f4a2713aSLionel Sambuc int *a = new int(10);
50f4a2713aSLionel Sambuc _Complex int* b = new _Complex int(10i);
51f4a2713aSLionel Sambuc
52f4a2713aSLionel Sambuc S s;
53f4a2713aSLionel Sambuc s.a = 10;
54f4a2713aSLionel Sambuc S *sp = new S(s);
55f4a2713aSLionel Sambuc }
56f4a2713aSLionel Sambuc
57f4a2713aSLionel Sambuc // Non-POD
58f4a2713aSLionel Sambuc struct T {
59f4a2713aSLionel Sambuc T();
60f4a2713aSLionel Sambuc int a;
61f4a2713aSLionel Sambuc };
62f4a2713aSLionel Sambuc
t4()63f4a2713aSLionel Sambuc void t4() {
64f4a2713aSLionel Sambuc // CHECK: call void @_ZN1TC1Ev
65f4a2713aSLionel Sambuc T *t = new T;
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc
68f4a2713aSLionel Sambuc struct T2 {
69f4a2713aSLionel Sambuc int a;
70f4a2713aSLionel Sambuc T2(int, int);
71f4a2713aSLionel Sambuc };
72f4a2713aSLionel Sambuc
t5()73f4a2713aSLionel Sambuc void t5() {
74f4a2713aSLionel Sambuc // CHECK: call void @_ZN2T2C1Eii
75f4a2713aSLionel Sambuc T2 *t2 = new T2(10, 10);
76f4a2713aSLionel Sambuc }
77f4a2713aSLionel Sambuc
t6()78f4a2713aSLionel Sambuc int *t6() {
79f4a2713aSLionel Sambuc // Null check.
80f4a2713aSLionel Sambuc return new (0) int(10);
81f4a2713aSLionel Sambuc }
82f4a2713aSLionel Sambuc
t7()83f4a2713aSLionel Sambuc void t7() {
84f4a2713aSLionel Sambuc new int();
85f4a2713aSLionel Sambuc }
86f4a2713aSLionel Sambuc
87f4a2713aSLionel Sambuc struct U {
88f4a2713aSLionel Sambuc ~U();
89f4a2713aSLionel Sambuc };
90f4a2713aSLionel Sambuc
t8(int n)91f4a2713aSLionel Sambuc void t8(int n) {
92f4a2713aSLionel Sambuc new int[10];
93f4a2713aSLionel Sambuc new int[n];
94f4a2713aSLionel Sambuc
95f4a2713aSLionel Sambuc // Non-POD
96f4a2713aSLionel Sambuc new T[10];
97f4a2713aSLionel Sambuc new T[n];
98f4a2713aSLionel Sambuc
99f4a2713aSLionel Sambuc // Cookie required
100f4a2713aSLionel Sambuc new U[10];
101f4a2713aSLionel Sambuc new U[n];
102f4a2713aSLionel Sambuc }
103f4a2713aSLionel Sambuc
t9()104f4a2713aSLionel Sambuc void t9() {
105f4a2713aSLionel Sambuc bool b;
106f4a2713aSLionel Sambuc
107f4a2713aSLionel Sambuc new bool(true);
108f4a2713aSLionel Sambuc new (&b) bool(true);
109f4a2713aSLionel Sambuc }
110f4a2713aSLionel Sambuc
111f4a2713aSLionel Sambuc struct A {
112f4a2713aSLionel Sambuc void* operator new(__typeof(sizeof(int)), int, float, ...);
113f4a2713aSLionel Sambuc A();
114f4a2713aSLionel Sambuc };
115f4a2713aSLionel Sambuc
t10()116f4a2713aSLionel Sambuc A* t10() {
117f4a2713aSLionel Sambuc // CHECK: @_ZN1AnwEmifz
118f4a2713aSLionel Sambuc return new(1, 2, 3.45, 100) A;
119f4a2713aSLionel Sambuc }
120f4a2713aSLionel Sambuc
121f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z3t11i
122f4a2713aSLionel Sambuc struct B { int a; };
123f4a2713aSLionel Sambuc struct Bmemptr { int Bmemptr::* memptr; int a; };
124f4a2713aSLionel Sambuc
t11(int n)125f4a2713aSLionel Sambuc void t11(int n) {
126f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znwm
127f4a2713aSLionel Sambuc // CHECK: call void @llvm.memset.p0i8.i64(
128f4a2713aSLionel Sambuc B* b = new B();
129f4a2713aSLionel Sambuc
130f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam
131f4a2713aSLionel Sambuc // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
132f4a2713aSLionel Sambuc B *b2 = new B[n]();
133f4a2713aSLionel Sambuc
134f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam
135f4a2713aSLionel Sambuc // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
136f4a2713aSLionel Sambuc // CHECK: br
137f4a2713aSLionel Sambuc Bmemptr *b_memptr = new Bmemptr[n]();
138f4a2713aSLionel Sambuc
139f4a2713aSLionel Sambuc // CHECK: ret void
140f4a2713aSLionel Sambuc }
141f4a2713aSLionel Sambuc
142f4a2713aSLionel Sambuc struct Empty { };
143f4a2713aSLionel Sambuc
144f4a2713aSLionel Sambuc // We don't need to initialize an empty class.
145f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z3t12v
t12()146f4a2713aSLionel Sambuc void t12() {
147f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam
148f4a2713aSLionel Sambuc // CHECK-NOT: br
149f4a2713aSLionel Sambuc (void)new Empty[10];
150f4a2713aSLionel Sambuc
151f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam
152f4a2713aSLionel Sambuc // CHECK-NOT: br
153f4a2713aSLionel Sambuc (void)new Empty[10]();
154f4a2713aSLionel Sambuc
155f4a2713aSLionel Sambuc // CHECK: ret void
156f4a2713aSLionel Sambuc }
157f4a2713aSLionel Sambuc
158f4a2713aSLionel Sambuc // Zero-initialization
159f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z3t13i
t13(int n)160f4a2713aSLionel Sambuc void t13(int n) {
161f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znwm
162f4a2713aSLionel Sambuc // CHECK: store i32 0, i32*
163f4a2713aSLionel Sambuc (void)new int();
164f4a2713aSLionel Sambuc
165f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam
166f4a2713aSLionel Sambuc // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
167f4a2713aSLionel Sambuc (void)new int[n]();
168f4a2713aSLionel Sambuc
169f4a2713aSLionel Sambuc // CHECK-NEXT: ret void
170f4a2713aSLionel Sambuc }
171f4a2713aSLionel Sambuc
172f4a2713aSLionel Sambuc struct Alloc{
173f4a2713aSLionel Sambuc int x;
174f4a2713aSLionel Sambuc void* operator new[](size_t size);
175f4a2713aSLionel Sambuc void operator delete[](void* p);
176f4a2713aSLionel Sambuc ~Alloc();
177f4a2713aSLionel Sambuc };
178f4a2713aSLionel Sambuc
f()179f4a2713aSLionel Sambuc void f() {
180f4a2713aSLionel Sambuc // CHECK: call i8* @_ZN5AllocnaEm(i64 808)
181f4a2713aSLionel Sambuc // CHECK: store i64 200
182f4a2713aSLionel Sambuc // CHECK: call void @_ZN5AllocD1Ev(
183f4a2713aSLionel Sambuc // CHECK: call void @_ZN5AllocdaEPv(i8*
184f4a2713aSLionel Sambuc delete[] new Alloc[10][20];
185f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znwm
186f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPv(i8*
187f4a2713aSLionel Sambuc delete new bool;
188f4a2713aSLionel Sambuc // CHECK: ret void
189f4a2713aSLionel Sambuc }
190f4a2713aSLionel Sambuc
191f4a2713aSLionel Sambuc namespace test15 {
192f4a2713aSLionel Sambuc struct A { A(); ~A(); };
193f4a2713aSLionel Sambuc
194f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN6test155test0EPv(
195f4a2713aSLionel Sambuc // CHECK: [[P:%.*]] = load i8*
196f4a2713aSLionel Sambuc // CHECK-NEXT: icmp eq i8* [[P]], null
197f4a2713aSLionel Sambuc // CHECK-NEXT: br i1
198f4a2713aSLionel Sambuc // CHECK: [[T0:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
199f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[T0]])
test0(void * p)200f4a2713aSLionel Sambuc void test0(void *p) {
201f4a2713aSLionel Sambuc new (p) A();
202f4a2713aSLionel Sambuc }
203f4a2713aSLionel Sambuc
204f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN6test155test1EPv(
205f4a2713aSLionel Sambuc // CHECK: [[P:%.*]] = load i8**
206f4a2713aSLionel Sambuc // CHECK-NEXT: icmp eq i8* [[P]], null
207f4a2713aSLionel Sambuc // CHECK-NEXT: br i1
208f4a2713aSLionel Sambuc // CHECK: [[BEGIN:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
209f4a2713aSLionel Sambuc // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 5
210f4a2713aSLionel Sambuc // CHECK-NEXT: br label
211f4a2713aSLionel Sambuc // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
212f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[CUR]])
213f4a2713aSLionel Sambuc // CHECK-NEXT: [[NEXT]] = getelementptr inbounds [[A]]* [[CUR]], i64 1
214f4a2713aSLionel Sambuc // CHECK-NEXT: [[DONE:%.*]] = icmp eq [[A]]* [[NEXT]], [[END]]
215f4a2713aSLionel Sambuc // CHECK-NEXT: br i1 [[DONE]]
test1(void * p)216f4a2713aSLionel Sambuc void test1(void *p) {
217f4a2713aSLionel Sambuc new (p) A[5];
218f4a2713aSLionel Sambuc }
219f4a2713aSLionel Sambuc
220f4a2713aSLionel Sambuc // TODO: it's okay if all these size calculations get dropped.
221f4a2713aSLionel Sambuc // FIXME: maybe we should try to throw on overflow?
222f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN6test155test2EPvi(
223f4a2713aSLionel Sambuc // CHECK: [[N:%.*]] = load i32*
224f4a2713aSLionel Sambuc // CHECK-NEXT: [[T0:%.*]] = sext i32 [[N]] to i64
225f4a2713aSLionel Sambuc // CHECK-NEXT: [[T1:%.*]] = icmp slt i64 [[T0]], 0
226f4a2713aSLionel Sambuc // CHECK-NEXT: [[T2:%.*]] = select i1 [[T1]], i64 -1, i64 [[T0]]
227f4a2713aSLionel Sambuc // CHECK-NEXT: [[P:%.*]] = load i8*
228f4a2713aSLionel Sambuc // CHECK-NEXT: icmp eq i8* [[P]], null
229f4a2713aSLionel Sambuc // CHECK-NEXT: br i1
230f4a2713aSLionel Sambuc // CHECK: [[BEGIN:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
231f4a2713aSLionel Sambuc // CHECK-NEXT: [[ISEMPTY:%.*]] = icmp eq i64 [[T0]], 0
232f4a2713aSLionel Sambuc // CHECK-NEXT: br i1 [[ISEMPTY]],
233f4a2713aSLionel Sambuc // CHECK: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 [[T0]]
234f4a2713aSLionel Sambuc // CHECK-NEXT: br label
235f4a2713aSLionel Sambuc // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]],
236f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[CUR]])
test2(void * p,int n)237f4a2713aSLionel Sambuc void test2(void *p, int n) {
238f4a2713aSLionel Sambuc new (p) A[n];
239f4a2713aSLionel Sambuc }
240f4a2713aSLionel Sambuc }
241f4a2713aSLionel Sambuc
242f4a2713aSLionel Sambuc namespace PR10197 {
243f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN7PR101971fIiEEvv()
244f4a2713aSLionel Sambuc template<typename T>
f()245f4a2713aSLionel Sambuc void f() {
246f4a2713aSLionel Sambuc // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
247f4a2713aSLionel Sambuc // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
248f4a2713aSLionel Sambuc new T;
249f4a2713aSLionel Sambuc // CHECK-NEXT: ret void
250f4a2713aSLionel Sambuc }
251f4a2713aSLionel Sambuc
252f4a2713aSLionel Sambuc template void f<int>();
253f4a2713aSLionel Sambuc }
254f4a2713aSLionel Sambuc
255f4a2713aSLionel Sambuc namespace PR11523 {
256f4a2713aSLionel Sambuc class MyClass;
257f4a2713aSLionel Sambuc typedef int MyClass::* NewTy;
258f4a2713aSLionel Sambuc // CHECK-LABEL: define i64* @_ZN7PR115231fEv
259f4a2713aSLionel Sambuc // CHECK: store i64 -1
f()260f4a2713aSLionel Sambuc NewTy* f() { return new NewTy[2](); }
261f4a2713aSLionel Sambuc }
262f4a2713aSLionel Sambuc
263f4a2713aSLionel Sambuc namespace PR11757 {
264f4a2713aSLionel Sambuc // Make sure we elide the copy construction.
265f4a2713aSLionel Sambuc struct X { X(); X(const X&); };
a(X * x)266f4a2713aSLionel Sambuc X* a(X* x) { return new X(X()); }
267f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_ZN7PR117571aEPNS_1XE
268f4a2713aSLionel Sambuc // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
269f4a2713aSLionel Sambuc // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
270f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN7PR117571XC1Ev({{.*}}* [[CASTED]])
271f4a2713aSLionel Sambuc // CHECK-NEXT: ret {{.*}} [[CASTED]]
272f4a2713aSLionel Sambuc }
273f4a2713aSLionel Sambuc
274f4a2713aSLionel Sambuc namespace PR13380 {
APR13380::A275f4a2713aSLionel Sambuc struct A { A() {} };
276f4a2713aSLionel Sambuc struct B : public A { int x; };
277f4a2713aSLionel Sambuc // CHECK-LABEL: define i8* @_ZN7PR133801fEv
278f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam(
279f4a2713aSLionel Sambuc // CHECK: call void @llvm.memset.p0i8
280f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN7PR133801BC1Ev
f()281f4a2713aSLionel Sambuc void* f() { return new B[2](); }
282f4a2713aSLionel Sambuc }
283f4a2713aSLionel Sambuc
284f4a2713aSLionel Sambuc struct MyPlacementType {} mpt;
285f4a2713aSLionel Sambuc void *operator new(size_t, MyPlacementType);
286f4a2713aSLionel Sambuc
287f4a2713aSLionel Sambuc namespace N3664 {
288f4a2713aSLionel Sambuc struct S { S() throw(int); };
289f4a2713aSLionel Sambuc
290*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN5N36641fEv
f()291f4a2713aSLionel Sambuc void f() {
292f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
293f4a2713aSLionel Sambuc int *p = new int;
294f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
295f4a2713aSLionel Sambuc delete p;
296f4a2713aSLionel Sambuc
297f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam(i64 12) [[ATTR_BUILTIN_NEW]]
298f4a2713aSLionel Sambuc int *q = new int[3];
299f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
300f4a2713aSLionel Sambuc delete [] p;
301f4a2713aSLionel Sambuc
302f4a2713aSLionel Sambuc // CHECK: call i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) [[ATTR_BUILTIN_NOTHROW_NEW:#[^ ]*]]
303f4a2713aSLionel Sambuc (void) new (nothrow) S[3];
304f4a2713aSLionel Sambuc
305f4a2713aSLionel Sambuc // CHECK: call i8* @_Znwm15MyPlacementType(i64 4){{$}}
306f4a2713aSLionel Sambuc (void) new (mpt) int;
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc
309f4a2713aSLionel Sambuc // FIXME: Can we mark this noalias?
310f4a2713aSLionel Sambuc // CHECK: declare i8* @_ZnamRKSt9nothrow_t(i64, {{.*}}) [[ATTR_NOBUILTIN_NOUNWIND]]
311f4a2713aSLionel Sambuc
312*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN5N36641gEv
g()313f4a2713aSLionel Sambuc void g() {
314f4a2713aSLionel Sambuc // It's OK for there to be attributes here, so long as we don't have a
315f4a2713aSLionel Sambuc // 'builtin' attribute.
316f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znwm(i64 4){{$}}
317f4a2713aSLionel Sambuc int *p = (int*)operator new(4);
318f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_NOUNWIND:#[^ ]*]]
319f4a2713aSLionel Sambuc operator delete(p);
320f4a2713aSLionel Sambuc
321f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam(i64 12){{$}}
322f4a2713aSLionel Sambuc int *q = (int*)operator new[](12);
323f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_NOUNWIND]]
324f4a2713aSLionel Sambuc operator delete [](p);
325f4a2713aSLionel Sambuc
326f4a2713aSLionel Sambuc // CHECK: call i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) [[ATTR_NOUNWIND]]
327f4a2713aSLionel Sambuc (void) operator new[](3, nothrow);
328f4a2713aSLionel Sambuc }
329f4a2713aSLionel Sambuc }
330f4a2713aSLionel Sambuc
331*0a6a1f1dSLionel Sambuc namespace builtins {
332*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN8builtins1fEv
f()333*0a6a1f1dSLionel Sambuc void f() {
334*0a6a1f1dSLionel Sambuc // CHECK: call noalias i8* @_Znwm(i64 4) [[ATTR_BUILTIN_NEW]]
335*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
336*0a6a1f1dSLionel Sambuc __builtin_operator_delete(__builtin_operator_new(4));
337*0a6a1f1dSLionel Sambuc }
338*0a6a1f1dSLionel Sambuc }
339*0a6a1f1dSLionel Sambuc
340f4a2713aSLionel Sambuc // CHECK-DAG: attributes [[ATTR_NOBUILTIN]] = {{[{].*}} nobuiltin {{.*[}]}}
341f4a2713aSLionel Sambuc // CHECK-DAG: attributes [[ATTR_NOBUILTIN_NOUNWIND]] = {{[{].*}} nobuiltin nounwind {{.*[}]}}
342f4a2713aSLionel Sambuc
343f4a2713aSLionel Sambuc // CHECK: attributes [[ATTR_NOUNWIND]] =
344f4a2713aSLionel Sambuc // CHECK-NOT: builtin
345f4a2713aSLionel Sambuc // CHECK-NOT: attributes
346f4a2713aSLionel Sambuc // CHECK: nounwind
347f4a2713aSLionel Sambuc // CHECK-NOT: builtin
348f4a2713aSLionel Sambuc // CHECK: attributes
349f4a2713aSLionel Sambuc
350f4a2713aSLionel Sambuc // CHECK-DAG: attributes [[ATTR_BUILTIN_NEW]] = {{[{].*}} builtin {{.*[}]}}
351f4a2713aSLionel Sambuc // CHECK-DAG: attributes [[ATTR_BUILTIN_DELETE]] = {{[{].*}} builtin {{.*[}]}}
352