[ubsan] Treat ObjC's BOOL as if its range is always {0, 1}
authorVedant Kumar <vsk@apple.com>
Fri, 9 Dec 2016 23:48:18 +0000 (23:48 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 9 Dec 2016 23:48:18 +0000 (23:48 +0000)
commit4593a46cd92ab88e9651ae75f6c623851c353964
tree12b5f88c3c4c9c64c51f65d2a06e61952d74f6bd
parent6baa5d276db3180e5397816b7e1c0170a368ea40
[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
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGenObjC/ubsan-bool.m [new file with mode: 0644]