]> granicus.if.org Git - clang/commit
[ubsan] Sanity-check shift amounts before truncation (fixes PR27271)
authorVedant Kumar <vsk@apple.com>
Fri, 27 Jan 2017 23:02:44 +0000 (23:02 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 27 Jan 2017 23:02:44 +0000 (23:02 +0000)
commitb43c9aaed9ad87912ac02de3854d56ddad84321a
treea9b585202fca52f3a45915158d5599839562b9e4
parentf3d6129af4a5469818f8759837730c17c795a3e1
[ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293343 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprScalar.cpp
test/CodeGen/ubsan-shift.c [new file with mode: 0644]