Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 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; |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 9 | public: |
Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 10 | teste() : A(2) {} |
Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 11 | }; |
| 12 | |
| 13 | void f1() { |
Chris Lattner | 6c552c1 | 2010-07-20 20:19:24 +0000 | [diff] [blame] | 14 | // SANE: declare noalias i8* @_Znwj( |
| 15 | // SANENOT: declare i8* @_Znwj( |
Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 16 | new teste(); |
| 17 | } |
Chris Lattner | 6c552c1 | 2010-07-20 20:19:24 +0000 | [diff] [blame] | 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: call{{.*}}@llvm.umul.with.overflow |
| 25 | // SANE: extractvalue |
Chris Lattner | c11787f | 2010-07-20 21:34:36 +0000 | [diff] [blame] | 26 | // SANE: br i1 |
| 27 | // SANE: = phi {{.*}} [ {{.*}} ], [ -1, |
Chris Lattner | 83252dc | 2010-07-20 21:07:09 +0000 | [diff] [blame] | 28 | // SANE: call noalias i8* @_Znaj( |
Chris Lattner | 6c552c1 | 2010-07-20 20:19:24 +0000 | [diff] [blame] | 29 | } |