1 // RUN: %clang_cc1 -no-opaque-pointers -triple i686-pc-linux-gnu %s -o - -emit-llvm -verify | FileCheck %s
2 // expected-no-diagnostics
4 typedef __typeof(sizeof(int)) size_t;
7 struct A
{ void operator delete(void*,size_t); int x
; };
9 // CHECK-LABEL: define{{.*}} void @_ZN5test11aEPNS_1AE(
12 // CHECK-NEXT: icmp eq {{.*}}, null
14 // CHECK: call void @_ZN5test11AdlEPvj(i8* noundef %{{.*}}, i32 noundef 4)
19 // Check that we make cookies for the two-arg delete even when using
20 // the global allocator and deallocator.
24 void *operator new[](size_t);
25 void operator delete[](void *, size_t);
28 // CHECK: define{{.*}} [[A:%.*]]* @_ZN5test24testEv()
30 // CHECK: [[NEW:%.*]] = call noalias noundef nonnull i8* @_Znaj(i32 noundef 44)
31 // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[NEW]] to i32*
32 // CHECK-NEXT: store i32 10, i32* [[T0]]
33 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[NEW]], i32 4
34 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[A]]*
35 // CHECK-NEXT: ret [[A]]* [[T2]]
39 // CHECK-LABEL: define{{.*}} void @_ZN5test24testEPNS_1AE(
41 // CHECK: [[P:%.*]] = alloca [[A]]*, align 4
42 // CHECK-NEXT: store [[A]]* {{%.*}}, [[A]]** [[P]], align 4
43 // CHECK-NEXT: [[T0:%.*]] = load [[A]]*, [[A]]** [[P]], align 4
44 // CHECK-NEXT: [[T1:%.*]] = icmp eq [[A]]* [[T0]], null
45 // CHECK-NEXT: br i1 [[T1]],
46 // CHECK: [[T2:%.*]] = bitcast [[A]]* [[T0]] to i8*
47 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i32 -4
48 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i32*
49 // CHECK-NEXT: [[T5:%.*]] = load i32, i32* [[T4]]
50 // CHECK-NEXT: call void @_ZdaPv(i8* noundef [[T3]])
51 // CHECK-NEXT: br label
56 // rdar://problem/8913519
60 void operator delete[](void *, size_t);
64 // CHECK-LABEL: define{{.*}} void @_ZN5test34testEv()
66 // CHECK: [[CALL:%.*]] = call noalias noundef nonnull i8* @_Znaj(i32 noundef 24)
67 // CHECK-NEXT: bitcast i8* [[CALL]] to i32*
68 // CHECK-NEXT: store i32 5