diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-18 18:15:39 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-18 18:15:39 +0000 |
commit | 415913b28c463121c176e842ffaf6b0fd9f4a98c (patch) | |
tree | 801af1687f51319af888c86919b129e5984e213b /test/CodeGenCXX/catch-undef-behavior.cpp | |
parent | 82b49e4abc2d71c474af2f616b125396e98d2f8c (diff) |
[UBsan] Skip -fsanitize=vptr instrumentations when the pointer value is null.
Otherwise -fsanitize=vptr causes the program to crash when it downcasts
a null pointer.
Reviewed in http://reviews.llvm.org/D4412.
Patch by Byoungyoung Lee!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/catch-undef-behavior.cpp')
-rw-r--r-- | test/CodeGenCXX/catch-undef-behavior.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/CodeGenCXX/catch-undef-behavior.cpp b/test/CodeGenCXX/catch-undef-behavior.cpp index f875d9299e..333855d0ba 100644 --- a/test/CodeGenCXX/catch-undef-behavior.cpp +++ b/test/CodeGenCXX/catch-undef-behavior.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++11 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s // RUN: %clang_cc1 -std=c++11 -fsanitize=vptr,address -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-ASAN +// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=DOWNCAST-NULL struct S { double d; @@ -190,10 +191,15 @@ int bad_enum_value() { } // CHECK-LABEL: @_Z20bad_downcast_pointer +// DOWNCAST-NULL-LABEL: @_Z20bad_downcast_pointer void bad_downcast_pointer(S *p) { // CHECK: %[[NONNULL:.*]] = icmp ne {{.*}}, null // CHECK: br i1 %[[NONNULL]], + // A null poiner access is guarded without -fsanitize=null. + // DOWNCAST-NULL: %[[NONNULL:.*]] = icmp ne {{.*}}, null + // DOWNCAST-NULL: br i1 %[[NONNULL]], + // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8( // CHECK: %[[E1:.*]] = icmp uge i64 %[[SIZE]], 24 // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7 |