[PATCH] D136532: [clang][Interp] Implement left and right shifts

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 05:40:03 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.h:1291-1305
+  if (RHS.isNegative()) {
     const SourceInfo &Loc = S.Current->getSource(OpPC);
     S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS.toAPSInt();
-    return ShiftLeft<TL, TR>(S, OpPC, LHS, Trunc<TR, TL>(S, OpPC, Bits, -RHS));
-  } else {
-    return ShiftRight<TL, TR>(S, OpPC, LHS, Trunc<TR, TL>(S, OpPC, Bits, RHS));
+    return false;
   }
-}
 
+  // C++11 [expr.shift]p1: Shift width must be less than the bit width of
----------------
aaron.ballman wrote:
> Should we factor this logic out into a common helper since it's the same between shl and shr? (It could be done as an NFC commit after we land this, too, I don't feel super strongly about it.)
Yes, this is what I meant in my earlier comment with "Excuse the code duplication here"


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136532/new/

https://reviews.llvm.org/D136532



More information about the cfe-commits mailing list