65 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=PLAIN2// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address %s | FileCheck %s -check-prefix=ASAN3// 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-ARRAY4 5typedef __typeof__(sizeof(0)) size_t;6namespace std {7 struct nothrow_t {};8 std::nothrow_t nothrow;9}10void *operator new[](size_t, const std::nothrow_t &) throw();11void *operator new[](size_t, char *);12void *operator new[](size_t, int, int);13 14struct C {15 int x;16 ~C();17};18 19C *CallNew() {20 return new C[10];21}22// PLAIN-LABEL: CallNew23// PLAIN-NOT: nosanitize24// PLAIN-NOT: __asan_poison_cxx_array_cookie25// ASAN-LABEL: CallNew26// ASAN: store{{.*}}nosanitize27// ASAN-NOT: nosanitize28// ASAN: call void @__asan_poison_cxx_array_cookie29 30C *CallNewNoThrow() {31 return new (std::nothrow) C[10];32}33// PLAIN-LABEL: CallNewNoThrow34// PLAIN-NOT: nosanitize35// PLAIN-NOT: __asan_poison_cxx_array_cookie36// ASAN-LABEL: CallNewNoThrow37// ASAN: store{{.*}}nosanitize38// ASAN-NOT: nosanitize39// ASAN: call void @__asan_poison_cxx_array_cookie40 41void CallDelete(C *c) {42 delete [] c;43}44 45// PLAIN-LABEL: CallDelete46// PLAIN-NOT: nosanitize47// ASAN-LABEL: CallDelete48// ASAN-NOT: nosanitize49// ASAN: call i64 @__asan_load_cxx_array_cookie50// ASAN-NOT: nosanitize51 52char Buffer[20];53C *CallPlacementNew() {54 return new (Buffer) C[20];55}56// ASAN-LABEL: CallPlacementNew57// ASAN-NOT: __asan_poison_cxx_array_cookie58 59C *CallNewWithArgs() {60// ASAN-LABEL: CallNewWithArgs61// ASAN-NOT: call void @__asan_poison_cxx_array_cookie62// ASAN-POISON-ALL-NEW-ARRAY: call void @__asan_poison_cxx_array_cookie63 return new (123, 456) C[20];64}65