diff options
| author | Vedant Kumar <vsk@apple.com> | 2016-12-09 23:48:18 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2016-12-09 23:48:18 +0000 |
| commit | 4593a46cd92ab88e9651ae75f6c623851c353964 (patch) | |
| tree | 12b5f88c3c4c9c64c51f65d2a06e61952d74f6bd /clang/test | |
| parent | 6baa5d276db3180e5397816b7e1c0170a368ea40 (diff) | |
| download | bcm5719-llvm-4593a46cd92ab88e9651ae75f6c623851c353964.tar.gz bcm5719-llvm-4593a46cd92ab88e9651ae75f6c623851c353964.zip | |
[ubsan] Treat ObjC's BOOL as if its range is always {0, 1}
On some Apple platforms, the ObjC BOOL type is defined as a signed char.
When performing instrumentation for -fsanitize=bool, we'd like to treat
the range of BOOL like it's always {0, 1}. While we can't change clang's
IRGen for char-backed BOOL's due to ABI compatibility concerns, we can
teach ubsan to catch potential abuses of this type.
rdar://problem/29502773
Differential Revision: https://reviews.llvm.org/D27607
llvm-svn: 289290
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenObjC/ubsan-bool.m | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/ubsan-bool.m b/clang/test/CodeGenObjC/ubsan-bool.m new file mode 100644 index 00000000000..6d6c08358d0 --- /dev/null +++ b/clang/test/CodeGenObjC/ubsan-bool.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC +// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC +// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C + +typedef signed char BOOL; + +// SHARED-LABEL: f1 +BOOL f1() { + // OBJC: call void @__ubsan_handle_load_invalid_value + // C-NOT: call void @__ubsan_handle_load_invalid_value + BOOL a = 2; + return a + 1; +} |

