]> granicus.if.org Git - clang/commit
[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)
authorVedant Kumar <vsk@apple.com>
Sat, 25 Feb 2017 00:43:36 +0000 (00:43 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 25 Feb 2017 00:43:36 +0000 (00:43 +0000)
commit2b6e4a436d728e605bd68c6c3f06aedfb3825bf8
tree13194bd78aba780e98d4932c5169da5a831490f9
parentc1e33ad623c6df31fcf79616a6ee8e0c0bb70cc2
[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

Differential Revision: https://reviews.llvm.org/D29369

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296213 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprScalar.cpp
test/CodeGen/compound-assign-overflow.c
test/CodeGen/ubsan-promoted-arith.cpp [new file with mode: 0644]
test/CodeGen/unsigned-promotion.c