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