aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorBjörn Pettersson <bjorn.a.pettersson@ericsson.com>2024-04-19 08:11:40 +0200
committerGitHub <noreply@github.com>2024-04-19 08:11:40 +0200
commit20667dbec30354723d6467b833a081db998eb70a (patch)
treeca58126079038d021a97e99ca1b9773267bcbfc2 /clang/lib/Frontend
parentbd898d5e111e33a7f614f6b6c34940d81be6682c (diff)
downloadllvm-20667dbec30354723d6467b833a081db998eb70a.zip
llvm-20667dbec30354723d6467b833a081db998eb70a.tar.gz
llvm-20667dbec30354723d6467b833a081db998eb70a.tar.bz2
[clang][CodeGen] Fix shift-exponent ubsan check for signed _BitInt (#88004)
Commit 5f87957fefb21d454f2f (pull-requst #80515) corrected some codegen problems related to _BitInt types being used as shift exponents. But it did not fix it properly for the special case when the shift count operand is a signed _BitInt. The basic problem is the same as the one solved for unsigned _BitInt. As we use an unsigned comparison to see if the shift exponent is out-of-bounds, then we need to find an unsigned maximum allowed shift amount to use in the check. Normally the shift amount is limited by bitwidth of the LHS of the shift. However, when the RHS type is small in relation to the LHS then we need to use a value that fits inside the bitwidth of the RHS instead. The earlier fix simply used the unsigned maximum when deterining the max shift amount based on the RHS type. It did however not take into consideration that the RHS type could have a signed representation. In such situations we need to use the signed maximum instead. Otherwise we do not recognize a negative shift exponent as UB.
Diffstat (limited to 'clang/lib/Frontend')
0 files changed, 0 insertions, 0 deletions