1 // RUN: %clang_cc1 -no-opaque-pointers -triple i686-pc-linux-gnu -emit-llvm -o %t-1.ll %s 2 // RUN: FileCheck --check-prefix=ALL -check-prefix SANE --input-file=%t-1.ll %s 3 // RUN: %clang_cc1 -no-opaque-pointers -triple i686-pc-linux-gnu -emit-llvm -fno-assume-sane-operator-new -o %t-2.ll %s 4 // RUN: FileCheck --check-prefix=ALL -check-prefix SANENOT --input-file=%t-2.ll %s 5 6 class teste { 7 int A; 8 public: 9 teste() : A(2) {} 10 }; 11 12 void f1() { 13 // ALL: declare noundef nonnull i8* @_Znwj( 14 new teste(); 15 } 16 17 // rdar://5739832 - operator new should check for overflow in multiply. 18 void *f2(long N) { 19 return new int[N]; 20 21 // ALL: [[UWO:%.*]] = call {{.*}} @llvm.umul.with.overflow 22 // ALL-NEXT: [[OVER:%.*]] = extractvalue {{.*}} [[UWO]], 1 23 // ALL-NEXT: [[SUM:%.*]] = extractvalue {{.*}} [[UWO]], 0 24 // ALL-NEXT: [[RESULT:%.*]] = select i1 [[OVER]], i32 -1, i32 [[SUM]] 25 // SANE-NEXT: call noalias noundef nonnull i8* @_Znaj(i32 noundef [[RESULT]]) 26 // SANENOT-NEXT: call noundef nonnull i8* @_Znaj(i32 noundef [[RESULT]]) 27 } 28 29 // ALL: declare noundef nonnull i8* @_Znaj( 30