diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2010-09-17 18:29:54 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2010-09-17 18:29:54 +0000 |
commit | dd84ef1e62fb1b732d8655da4d7e058f118c04d8 (patch) | |
tree | 616fa1107962d5c8dda889e890348b4778cb34fd /clang/test/CodeGen/integer-overflow.c | |
parent | 0d35df1cfe3ed138f741e9740914eb87c10406ed (diff) | |
download | bcm5719-llvm-dd84ef1e62fb1b732d8655da4d7e058f118c04d8.tar.gz bcm5719-llvm-dd84ef1e62fb1b732d8655da4d7e058f118c04d8.zip |
Add a -ftrapv-handler= option which allows a handler to invoke instead of simply aborting when a signed operation overflows. This mirrors the (GCC-incompatible) behaviour from clang 1.0 and 1.1 when -ftrapv was specified, but allows the handler to be defined for each compilation unit.
llvm-svn: 114192
Diffstat (limited to 'clang/test/CodeGen/integer-overflow.c')
-rw-r--r-- | clang/test/CodeGen/integer-overflow.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/CodeGen/integer-overflow.c b/clang/test/CodeGen/integer-overflow.c index 9bed741b323..103cc8427bb 100644 --- a/clang/test/CodeGen/integer-overflow.c +++ b/clang/test/CodeGen/integer-overflow.c @@ -1,6 +1,7 @@ // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT // RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV // RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV +// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER // Tests for signed integer overflow stuff. @@ -14,21 +15,25 @@ void test1() { // DEFAULT: add nsw i32 // WRAPV: add i32 // TRAPV: llvm.sadd.with.overflow.i32 + // TRAPV_HANDLER: foo( f11G = a + b; // DEFAULT: sub nsw i32 // WRAPV: sub i32 // TRAPV: llvm.ssub.with.overflow.i32 + // TRAPV_HANDLER: foo( f11G = a - b; // DEFAULT: mul nsw i32 // WRAPV: mul i32 // TRAPV: llvm.smul.with.overflow.i32 + // TRAPV_HANDLER: foo( f11G = a * b; // DEFAULT: sub nsw i32 0, // WRAPV: sub i32 0, // TRAPV: llvm.ssub.with.overflow.i32(i32 0 + // TRAPV_HANDLER: foo( f11G = -a; // PR7426 - Overflow checking for increments. @@ -36,10 +41,12 @@ void test1() { // DEFAULT: add nsw i32 {{.*}}, 1 // WRAPV: add i32 {{.*}}, 1 // TRAPV: llvm.sadd.with.overflow.i32({{.*}}, i32 1) + // TRAPV_HANDLER: foo( ++a; // DEFAULT: add nsw i32 {{.*}}, -1 // WRAPV: add i32 {{.*}}, -1 // TRAPV: llvm.sadd.with.overflow.i32({{.*}}, i32 -1) + // TRAPV_HANDLER: foo( --a; } |