[PATCH] D134749: [clang][Interp] Implement Div opcode

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 07:22:48 PDT 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from a simple refactoring (feel free to apply it when landing or do it post-commit as an NFC change).



================
Comment at: clang/lib/AST/Interp/Interp.h:203-211
+  if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {
+    APSInt LHSInt = LHS.toAPSInt();
+    SmallString<32> Trunc;
+    (-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
+    const SourceInfo &Loc = S.Current->getSource(OpPC);
+    const Expr *E = S.Current->getExpr(OpPC);
+    S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
----------------
We should factor this out into a helper function so we don't have duplication between Div and Rem. Same for the above block checking for division by zero.


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

https://reviews.llvm.org/D134749



More information about the cfe-commits mailing list