diff options
Diffstat (limited to 'clang/test/CodeGen/catch-undef-behavior.c')
-rw-r--r-- | clang/test/CodeGen/catch-undef-behavior.c | 13 |
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 |