2015-03-20 08:31:07 +08:00
|
|
|
// Check that delete exprs call the sized deallocation function if
|
|
|
|
// -fsized-deallocation is passed in both C++11 and C++14.
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -std=c++14 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
|
|
|
|
|
|
|
|
// Check that we don't used sized deallocation without -fsized-deallocation and
|
|
|
|
// C++14.
|
2013-11-05 17:12:18 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
|
2015-03-20 08:31:07 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
|
2013-09-29 12:40:38 +08:00
|
|
|
|
|
|
|
// CHECK-UNSIZED-NOT: _ZdlPvm
|
|
|
|
// CHECK-UNSIZED-NOT: _ZdaPvm
|
|
|
|
|
|
|
|
typedef decltype(sizeof(0)) size_t;
|
|
|
|
|
|
|
|
typedef int A;
|
|
|
|
struct B { int n; };
|
|
|
|
struct C { ~C() {} };
|
|
|
|
struct D { D(); virtual ~D() {} };
|
|
|
|
struct E {
|
|
|
|
void *operator new(size_t);
|
|
|
|
void *operator new[](size_t);
|
|
|
|
void operator delete(void *) noexcept;
|
|
|
|
void operator delete[](void *) noexcept;
|
|
|
|
};
|
|
|
|
struct F {
|
|
|
|
void *operator new(size_t);
|
|
|
|
void *operator new[](size_t);
|
|
|
|
void operator delete(void *, size_t) noexcept;
|
|
|
|
void operator delete[](void *, size_t) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T> T get();
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void del() {
|
|
|
|
::delete get<T*>();
|
|
|
|
::delete[] get<T*>();
|
2013-12-05 16:30:59 +08:00
|
|
|
delete get<T*>();
|
|
|
|
delete[] get<T*>();
|
2013-09-29 12:40:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template void del<A>();
|
|
|
|
template void del<B>();
|
|
|
|
template void del<C>();
|
|
|
|
template void del<D>();
|
|
|
|
template void del<E>();
|
|
|
|
template void del<F>();
|
|
|
|
|
|
|
|
D::D() {}
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delIiEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
|
|
|
|
// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
|
|
|
|
// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
2015-03-20 08:31:07 +08:00
|
|
|
// CHECK-LABEL: declare void @_ZdlPvm(i8*
|
2013-11-05 17:12:18 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delI1BEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
|
|
|
|
// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 4)
|
|
|
|
// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delI1CEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
|
2013-09-29 12:40:38 +08:00
|
|
|
// CHECK: mul i64 1, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
|
2013-12-05 16:30:59 +08:00
|
|
|
// CHECK: mul i64 1, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
2015-03-20 08:31:07 +08:00
|
|
|
// CHECK-LABEL: declare void @_ZdaPvm(i8*
|
2013-11-05 17:12:18 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delI1DEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8)
|
2013-09-29 12:40:38 +08:00
|
|
|
// CHECK: mul i64 8, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2015-03-20 01:03:58 +08:00
|
|
|
// CHECK-NOT: Zdl
|
2013-12-05 16:30:59 +08:00
|
|
|
// CHECK: call void %{{.*}}
|
|
|
|
// CHECK-NOT: Zdl
|
|
|
|
// CHECK: mul i64 8, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delI1EEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
|
|
|
|
// CHECK: call void @_ZdaPv(i8* %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZN1EdlEPv(i8* %{{[^ ]*}})
|
|
|
|
// CHECK: call void @_ZN1EdaEPv(i8* %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z3delI1FEvv()
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 1)
|
2013-09-29 12:40:38 +08:00
|
|
|
// CHECK: mul i64 1, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdaPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-12-05 16:30:59 +08:00
|
|
|
//
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZN1FdlEPvm(i8* %{{[^ ]*}}, i64 1)
|
2013-12-05 16:30:59 +08:00
|
|
|
// CHECK: mul i64 1, %{{[^ ]*}}
|
|
|
|
// CHECK: add i64 %{{[^ ]*}}, 8
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZN1FdaEPvm(i8* %{{[^ ]*}}, i64 %{{[^ ]*}})
|
2013-09-29 12:40:38 +08:00
|
|
|
|
|
|
|
|
2020-11-17 07:04:55 +08:00
|
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1DD0Ev(%{{[^ ]*}}* {{[^,]*}} %this)
|
2021-10-18 22:03:47 +08:00
|
|
|
// CHECK: call void @_ZdlPvm(i8* %{{[^ ]*}}, i64 8)
|