blob: b108d27ab923d95e6f0bfdfa801da9105dddca8b [file] [log] [blame]
Nuno Lopesfc284482009-12-16 16:59:22 +00001// 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
7class teste {
8 int A;
John McCall7002f4c2010-04-09 19:03:51 +00009public:
Nuno Lopesfc284482009-12-16 16:59:22 +000010 teste() : A(2) {}
Nuno Lopesfc284482009-12-16 16:59:22 +000011};
12
13void f1() {
Chris Lattner6c552c12010-07-20 20:19:24 +000014 // SANE: declare noalias i8* @_Znwj(
15 // SANENOT: declare i8* @_Znwj(
Nuno Lopesfc284482009-12-16 16:59:22 +000016 new teste();
17}
Chris Lattner6c552c12010-07-20 20:19:24 +000018
19
20// rdar://5739832 - operator new should check for overflow in multiply.
21void *f2(long N) {
22 return new int[N];
23
24// SANE: call{{.*}}@llvm.umul.with.overflow
25// SANE: extractvalue
Chris Lattner83252dc2010-07-20 21:07:09 +000026// SANE: br i1{{.*}}, label %overflow, label %no_overflow
Chris Lattner6c552c12010-07-20 20:19:24 +000027
Chris Lattner83252dc2010-07-20 21:07:09 +000028// SANE: = phi {{.*}} [ {{.*}}, %entry ], [ -1, %overflow ]
29// SANE: call noalias i8* @_Znaj(
Chris Lattner6c552c12010-07-20 20:19:24 +000030}