summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/catch-undef-behavior.c
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-11-05 22:21:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-11-05 22:21:05 +0000
commitb1b0ab41e79f4f11ab21e6e56ded7147241f8615 (patch)
tree57f380118fb1a78b72d002a2ac906d3417f5ff8a /clang/test/CodeGen/catch-undef-behavior.c
parentae79765676f5fda98cff4131be5abefc77c0317d (diff)
downloadbcm5719-llvm-b1b0ab41e79f4f11ab21e6e56ded7147241f8615.tar.gz
bcm5719-llvm-b1b0ab41e79f4f11ab21e6e56ded7147241f8615.zip
Use the individual -fsanitize=<...> arguments to control which of the UBSan
checks to enable. Remove frontend support for -fcatch-undefined-behavior, -faddress-sanitizer and -fthread-sanitizer now that they don't do anything. llvm-svn: 167413
Diffstat (limited to 'clang/test/CodeGen/catch-undef-behavior.c')
-rw-r--r--clang/test/CodeGen/catch-undef-behavior.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/test/CodeGen/catch-undef-behavior.c b/clang/test/CodeGen/catch-undef-behavior.c
index 5283b3ba51e..bc5ec63e1ae 100644
--- a/clang/test/CodeGen/catch-undef-behavior.c
+++ b/clang/test/CodeGen/catch-undef-behavior.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=null -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NULL
// CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
@@ -17,8 +18,11 @@
// CHECK: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
// CHECK: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
+// CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr constant {{.*}}, i32 100, i32 5 {{.*}}
+
// PR6805
// CHECK: @foo
+// CHECK-NULL: @foo
void foo() {
union { int i; } u;
// CHECK: %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
@@ -37,6 +41,11 @@ void foo() {
// CHECK: %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
// CHECK-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %[[ARG]]) noreturn nounwind
+
+ // With -fsanitize=null, only perform the null check.
+ // CHECK-NULL: %[[NULL:.*]] = icmp ne {{.*}}, null
+ // CHECK-NULL: br i1 %[[NULL]]
+ // CHECK-NULL: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %{{.*}}) noreturn nounwind
#line 100
u.i=1;
}
@@ -137,6 +146,8 @@ int signed_overflow(int a, int b) {
// CHECK: @no_return
int no_return() {
// Reaching the end of a noreturn function is fine in C.
+ // FIXME: If the user explicitly requests -fsanitize=return, we should catch
+ // that here even though it's not undefined behavior.
// CHECK-NOT: call
// CHECK-NOT: unreachable
// CHECK: ret i32
OpenPOWER on IntegriCloud