mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-17 08:57:34 +00:00
MCExpr: Avoid UB by evaluating this shift as unsigned
We hit undefined behaviour in some MCExpr tests when the LHS of a left shift is -1. Twos-complement semantics are completely reasonable here, so we should just do the shift in unsigned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
46a8f93144
commit
1e4a7e02f8
@ -752,7 +752,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
|
||||
case MCBinaryExpr::Mul: Result = LHS * RHS; break;
|
||||
case MCBinaryExpr::NE: Result = LHS != RHS; break;
|
||||
case MCBinaryExpr::Or: Result = LHS | RHS; break;
|
||||
case MCBinaryExpr::Shl: Result = LHS << RHS; break;
|
||||
case MCBinaryExpr::Shl: Result = uint64_t(LHS) << uint64_t(RHS); break;
|
||||
case MCBinaryExpr::Sub: Result = LHS - RHS; break;
|
||||
case MCBinaryExpr::Xor: Result = LHS ^ RHS; break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user