1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
3f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
4f4a2713aSLionel Sambuc
5f4a2713aSLionel Sambuc // CHECK-UNSIZED-NOT: _ZdlPvm
6f4a2713aSLionel Sambuc // CHECK-UNSIZED-NOT: _ZdaPvm
7f4a2713aSLionel Sambuc
8f4a2713aSLionel Sambuc typedef decltype(sizeof(0)) size_t;
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc typedef int A;
11f4a2713aSLionel Sambuc struct B { int n; };
~CC12f4a2713aSLionel Sambuc struct C { ~C() {} };
~DD13f4a2713aSLionel Sambuc struct D { D(); virtual ~D() {} };
14f4a2713aSLionel Sambuc struct E {
15f4a2713aSLionel Sambuc void *operator new(size_t);
16f4a2713aSLionel Sambuc void *operator new[](size_t);
17f4a2713aSLionel Sambuc void operator delete(void *) noexcept;
18f4a2713aSLionel Sambuc void operator delete[](void *) noexcept;
19f4a2713aSLionel Sambuc };
20f4a2713aSLionel Sambuc struct F {
21f4a2713aSLionel Sambuc void *operator new(size_t);
22f4a2713aSLionel Sambuc void *operator new[](size_t);
23f4a2713aSLionel Sambuc void operator delete(void *, size_t) noexcept;
24f4a2713aSLionel Sambuc void operator delete[](void *, size_t) noexcept;
25f4a2713aSLionel Sambuc };
26f4a2713aSLionel Sambuc
27f4a2713aSLionel Sambuc template<typename T> T get();
28f4a2713aSLionel Sambuc
29f4a2713aSLionel Sambuc template<typename T>
del()30f4a2713aSLionel Sambuc void del() {
31f4a2713aSLionel Sambuc ::delete get<T*>();
32f4a2713aSLionel Sambuc ::delete[] get<T*>();
33*0a6a1f1dSLionel Sambuc delete get<T*>();
34*0a6a1f1dSLionel Sambuc delete[] get<T*>();
35f4a2713aSLionel Sambuc }
36f4a2713aSLionel Sambuc
37f4a2713aSLionel Sambuc template void del<A>();
38f4a2713aSLionel Sambuc template void del<B>();
39f4a2713aSLionel Sambuc template void del<C>();
40f4a2713aSLionel Sambuc template void del<D>();
41f4a2713aSLionel Sambuc template void del<E>();
42f4a2713aSLionel Sambuc template void del<F>();
43f4a2713aSLionel Sambuc
D()44f4a2713aSLionel Sambuc D::D() {}
45f4a2713aSLionel Sambuc
46f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delIiEvv()
47f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
48f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
49*0a6a1f1dSLionel Sambuc //
50*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
51*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
52f4a2713aSLionel Sambuc
53f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce void @_ZdlPvm(i8*
54f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPv(i8* %0)
55f4a2713aSLionel Sambuc
56f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delI1BEvv()
57f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
58f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
59*0a6a1f1dSLionel Sambuc //
60*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
61*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
62f4a2713aSLionel Sambuc
63f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delI1CEvv()
64f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
65f4a2713aSLionel Sambuc // CHECK: mul i64 1, %{{[^ ]*}}
66f4a2713aSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
67f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
68*0a6a1f1dSLionel Sambuc //
69*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
70*0a6a1f1dSLionel Sambuc // CHECK: mul i64 1, %{{[^ ]*}}
71*0a6a1f1dSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
72*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
73f4a2713aSLionel Sambuc
74f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce void @_ZdaPvm(i8*
75f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %0)
76f4a2713aSLionel Sambuc
77f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delI1DEvv()
78f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8)
79f4a2713aSLionel Sambuc // CHECK: mul i64 8, %{{[^ ]*}}
80f4a2713aSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
81f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
82*0a6a1f1dSLionel Sambuc //
83*0a6a1f1dSLionel Sambuc // CHECK-NOT: Zdl
84*0a6a1f1dSLionel Sambuc // CHECK: call void %{{.*}}
85*0a6a1f1dSLionel Sambuc // CHECK-NOT: Zdl
86*0a6a1f1dSLionel Sambuc // CHECK: mul i64 8, %{{[^ ]*}}
87*0a6a1f1dSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
88*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
89f4a2713aSLionel Sambuc
90f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delI1EEvv()
91f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
92f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
93*0a6a1f1dSLionel Sambuc //
94*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1EdlEPv(i8* %{{[^ ]*}})
95*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1EdaEPv(i8* %{{[^ ]*}})
96f4a2713aSLionel Sambuc
97f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z3delI1FEvv()
98f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
99f4a2713aSLionel Sambuc // CHECK: mul i64 1, %{{[^ ]*}}
100f4a2713aSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
101f4a2713aSLionel Sambuc // CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
102*0a6a1f1dSLionel Sambuc //
103*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1FdlEPvm(i8* %{{[^ ]*}}, i64 1)
104*0a6a1f1dSLionel Sambuc // CHECK: mul i64 1, %{{[^ ]*}}
105*0a6a1f1dSLionel Sambuc // CHECK: add i64 %{{[^ ]*}}, 8
106*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1FdaEPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
107f4a2713aSLionel Sambuc
108f4a2713aSLionel Sambuc
109f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1DD0Ev(%{{[^ ]*}}* %this)
110f4a2713aSLionel Sambuc // CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8)
111