[clang] 2dbcfd2 - Revert "[clang][Interp][NFC] Move CheckDivRem() implementation into Interp.cpp"

Roman Lebedev via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 05:20:13 PST 2023


Reminder to please always mention the reason for the revert/recommit
in the commit message.

On Thu, Jan 19, 2023 at 2:37 PM Timm Bäder via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
>
> Author: Timm Bäder
> Date: 2023-01-19T12:37:20+01:00
> New Revision: 2dbcfd298f7cb1454ca16f544b7df980ec8fc17d
>
> URL: https://github.com/llvm/llvm-project/commit/2dbcfd298f7cb1454ca16f544b7df980ec8fc17d
> DIFF: https://github.com/llvm/llvm-project/commit/2dbcfd298f7cb1454ca16f544b7df980ec8fc17d.diff
>
> LOG: Revert "[clang][Interp][NFC] Move CheckDivRem() implementation into Interp.cpp"
>
> This reverts commit 9ee0d7494eb35f5addefcb730cdf5c002ddeacd2.
>
> Added:
>
>
> Modified:
>     clang/lib/AST/Interp/Interp.cpp
>     clang/lib/AST/Interp/Interp.h
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
> index d7195148d015..76ade4401e08 100644
> --- a/clang/lib/AST/Interp/Interp.cpp
> +++ b/clang/lib/AST/Interp/Interp.cpp
> @@ -422,26 +422,6 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const RT &RHS, unsigned Bits) {
>    return true;
>  }
>
> -template <typename T>
> -bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS) {
> -  if (RHS.isZero()) {
> -    const SourceInfo &Loc = S.Current->getSource(OpPC);
> -    S.FFDiag(Loc, diag::note_expr_divide_by_zero);
> -    return false;
> -  }
> -
> -  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();
> -    return false;
> -  }
> -  return true;
> -}
> -
>  static void DiagnoseUninitializedSubobject(InterpState &S, const SourceInfo &SI,
>                                             QualType SubObjType,
>                                             SourceLocation SubObjLoc) {
>
> diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
> index 3fa977d4a02e..903c68f4511c 100644
> --- a/clang/lib/AST/Interp/Interp.h
> +++ b/clang/lib/AST/Interp/Interp.h
> @@ -100,7 +100,24 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const RT &RHS, unsigned Bits);
>
>  /// Checks if Div/Rem operation on LHS and RHS is valid.
>  template <typename T>
> -bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS);
> +bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS) {
> +  if (RHS.isZero()) {
> +    const SourceInfo &Loc = S.Current->getSource(OpPC);
> +    S.FFDiag(Loc, diag::note_expr_divide_by_zero);
> +    return false;
> +  }
> +
> +  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();
> +    return false;
> +  }
> +  return true;
> +}
>
>  /// Interpreter entry point.
>  bool Interpret(InterpState &S, APValue &Result);
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list