[PATCH] D118315: [ADT] Refactor comparison operator in APSInt by compareValues

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 00:23:37 PST 2022


ChuanqiXu added a comment.

In D118315#3275007 <https://reviews.llvm.org/D118315#3275007>, @rjmccall wrote:

> These assertions are actually protecting against some pretty significant sources of bugs, like trying to evaluate a constant comparison without applying the appropriate conversions on the operands first.  `APSInt` models a consistent integer type of statically-unknown width and signedness; if you're trying to use it as a possibly-negative arbitrary-precision integer, a lot of the behavior is wrong, like the fact that overflow will wrap around instead of extending the storage.
>
> I do think it would be useful to have a type that models arbitrary-precision integer math, if you want to work on that.

I am confused about the existence of  the method`compareValues`. It handles the bitwidth  and signedeness. And the functionality of `compareValues` looks really like comparison operator to me . I think they should be consistent. If we indeed want the assertion, I think we should have one in the `compareValues` method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118315



More information about the llvm-commits mailing list