[PATCH] D140059: [APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Peter Rong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 12:15:27 PST 2022


Peter marked an inline comment as done.
Peter added inline comments.


================
Comment at: llvm/unittests/ADT/APSIntTest.cpp:88
+  ASSERT_EQ(-7, APSInt(APInt(64, -7), false).tryExtValue().value_or(42));
+  ASSERT_EQ(42, APSInt(APInt(128, -7), false).tryExtValue().value_or(42));
+  ASSERT_EQ(42, APSInt(APInt(64, -7), true).tryExtValue().value_or(42));
----------------
RKSimon wrote:
> why can't a i128 -7 be represented as a i64 -7?
`APInt(128, -7) == (uint64)-7`, there are 64 leading zeros and thus is a actually a huge positive number.

I added  two more tests to make this clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140059



More information about the llvm-commits mailing list