1 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=PLAIN
2 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address %s | FileCheck %s -check-prefix=ASAN
3 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address -fsanitize-address-poison-custom-array-cookie %s | FileCheck %s -check-prefix=ASAN-POISON-ALL-NEW-ARRAY
5 typedef __typeof__(sizeof(0)) size_t;
8 std::nothrow_t nothrow
;
10 void *operator new[](size_t, const std::nothrow_t
&) throw();
11 void *operator new[](size_t, char *);
12 void *operator new[](size_t, int, int);
22 // PLAIN-LABEL: CallNew
23 // PLAIN-NOT: nosanitize
24 // PLAIN-NOT: __asan_poison_cxx_array_cookie
25 // ASAN-LABEL: CallNew
26 // ASAN: store{{.*}}nosanitize
27 // ASAN-NOT: nosanitize
28 // ASAN: call void @__asan_poison_cxx_array_cookie
31 return new (std::nothrow
) C
[10];
33 // PLAIN-LABEL: CallNewNoThrow
34 // PLAIN-NOT: nosanitize
35 // PLAIN-NOT: __asan_poison_cxx_array_cookie
36 // ASAN-LABEL: CallNewNoThrow
37 // ASAN: store{{.*}}nosanitize
38 // ASAN-NOT: nosanitize
39 // ASAN: call void @__asan_poison_cxx_array_cookie
41 void CallDelete(C
*c
) {
45 // PLAIN-LABEL: CallDelete
46 // PLAIN-NOT: nosanitize
47 // ASAN-LABEL: CallDelete
48 // ASAN-NOT: nosanitize
49 // ASAN: call i64 @__asan_load_cxx_array_cookie
50 // ASAN-NOT: nosanitize
53 C
*CallPlacementNew() {
54 return new (Buffer
) C
[20];
56 // ASAN-LABEL: CallPlacementNew
57 // ASAN-NOT: __asan_poison_cxx_array_cookie
59 C
*CallNewWithArgs() {
60 // ASAN-LABEL: CallNewWithArgs
61 // ASAN-NOT: call void @__asan_poison_cxx_array_cookie
62 // ASAN-POISON-ALL-NEW-ARRAY: call void @__asan_poison_cxx_array_cookie
63 return new (123, 456) C
[20];