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 4typedef __typeof__(sizeof(0)) size_t; 5namespace std { 6 struct nothrow_t {}; 7 std::nothrow_t nothrow; 8} 9void *operator new[](size_t, const std::nothrow_t &) throw(); 10void *operator new[](size_t, char *); 11 12struct C { 13 int x; 14 ~C(); 15}; 16 17C *CallNew() { 18 return new C[10]; 19} 20// PLAIN-LABEL: CallNew 21// PLAIN-NOT: nosanitize 22// PLAIN-NOT: __asan_poison_cxx_array_cookie 23// ASAN-LABEL: CallNew 24// ASAN: store{{.*}}nosanitize 25// ASAN-NOT: nosanitize 26// ASAN: call void @__asan_poison_cxx_array_cookie 27 28C *CallNewNoThrow() { 29 return new (std::nothrow) C[10]; 30} 31// PLAIN-LABEL: CallNewNoThrow 32// PLAIN-NOT: nosanitize 33// PLAIN-NOT: __asan_poison_cxx_array_cookie 34// ASAN-LABEL: CallNewNoThrow 35// ASAN: store{{.*}}nosanitize 36// ASAN-NOT: nosanitize 37// ASAN: call void @__asan_poison_cxx_array_cookie 38 39void CallDelete(C *c) { 40 delete [] c; 41} 42 43// PLAIN-LABEL: CallDelete 44// PLAIN-NOT: nosanitize 45// ASAN-LABEL: CallDelete 46// ASAN-NOT: nosanitize 47// ASAN: call i64 @__asan_load_cxx_array_cookie 48// ASAN-NOT: nosanitize 49 50char Buffer[20]; 51C *CallPlacementNew() { 52 return new (Buffer) C[20]; 53} 54// ASAN-LABEL: CallPlacementNew 55// ASAN-NOT: __asan_poison_cxx_array_cookie 56