Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/AST/Interp/IntegralAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ template <bool Signed> class IntegralAP final {

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(); }
Expand Down
4 changes: 4 additions & 0 deletions clang/test/AST/Interp/intap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down