Home | History | Annotate | Download | only in CodeGen
      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 
      4 typedef __typeof__(sizeof(0)) size_t;
      5 namespace std {
      6   struct nothrow_t {};
      7   std::nothrow_t nothrow;
      8 }
      9 void *operator new[](size_t, const std::nothrow_t &) throw();
     10 void *operator new[](size_t, char *);
     11 
     12 struct C {
     13   int x;
     14   ~C();
     15 };
     16 
     17 C *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 
     28 C *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 
     39 void 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 
     50 char Buffer[20];
     51 C *CallPlacementNew() {
     52   return new (Buffer) C[20];
     53 }
     54 // ASAN-LABEL: CallPlacementNew
     55 // ASAN-NOT: __asan_poison_cxx_array_cookie
     56