[clang][Interp] Fix creating APSInt from IntegralAP (#71410)

The boolean argument in the APSInt constructor is IsUnsigned, not
IsSigned.
This commit is contained in:
Timm Baeder 2023-11-08 10:48:07 +01:00 committed by GitHub
parent 32a3f2afe6
commit e6a94dca38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -119,8 +119,8 @@ public:
constexpr unsigned bitWidth() const { return V.getBitWidth(); }
APSInt toAPSInt(unsigned Bits = 0) const { return APSInt(V, Signed); }
APValue toAPValue() const { return APValue(APSInt(V, Signed)); }
APSInt toAPSInt(unsigned Bits = 0) const { return APSInt(V, !Signed); }
APValue toAPValue() const { return APValue(APSInt(V, !Signed)); }
bool isZero() const { return V.isZero(); }
bool isPositive() const { return V.isNonNegative(); }

View File

@ -56,6 +56,10 @@ namespace i128 {
static const __uint128_t UINT128_MAX =__uint128_t(__int128_t(-1L));
static_assert(UINT128_MAX == -1, "");
static_assert(UINT128_MAX == 1, ""); // expected-error {{static assertion failed}} \
// expected-note {{'340282366920938463463374607431768211455 == 1'}} \
// ref-error {{static assertion failed}} \
// ref-note {{'340282366920938463463374607431768211455 == 1'}}
static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t)1;
static_assert(INT128_MAX != 0, "");