Skip to content

Commit c468e89

Browse files
committed
[clang][Interp][NFC] Fix right shifting signed IntegralAP values
1 parent 39830fe commit c468e89

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ template <bool Signed> class IntegralAP final {
248248

249249
static void shiftRight(const IntegralAP A, const IntegralAP B,
250250
unsigned OpBits, IntegralAP *R) {
251-
*R = IntegralAP(A.V.ashr(B.V.getZExtValue()));
251+
unsigned ShiftAmount = B.V.getZExtValue();
252+
if constexpr (Signed)
253+
*R = IntegralAP(A.V.ashr(ShiftAmount));
254+
else
255+
*R = IntegralAP(A.V.lshr(ShiftAmount));
252256
}
253257

254258
private:

0 commit comments

Comments
 (0)