================ @@ -12120,8 +12120,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, auto FXSema = S.Context.getFixedPointSemantics(LHSExprType); LeftSize = FXSema.getWidth() - (unsigned)FXSema.hasUnsignedPadding(); } - llvm::APInt LeftBits(Right.getBitWidth(), LeftSize); - if (Right.uge(LeftBits)) { + if (Right.uge(LeftSize)) { ---------------- bjope wrote:
I tried to understand why the old code used an APInt here. What if you have something like ` x >> larger_than_64_bits_value`? I suspect that then the uge helper here will do a 64-bit unsigned compare. So it will truncate `Right` to 64 bits instead, right? So I think the easiest way would be to compare to APInt:s. But make sure those are zero-extended to have a common size. Maybe something like this: ``` unsigned CompareBits = std::max(Right.getBitWidth(), 64); llvm::APInt LeftBits(CompareBits, LeftSize); if (Right.zext(CompareBits).uge(LeftBits)) { ``` https://github.com/llvm/llvm-project/pull/69521 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits