Skip to content

Commit f09ee87

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:c81d6665601d648c1a5349b665ee6019f3786352 into amd-gfx:80a4987ce388
Local branch amd-gfx 80a4987 Merged main:75ef95584d8867d0039a43bad0bd8e53f3293f67 into amd-gfx:600cb8c5e762 Remote branch main c81d666 [clang][bytecode] Fix IntegralAP::is{Positive,Negative} (llvm#105924)
2 parents 80a4987 + c81d666 commit f09ee87

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

clang/lib/AST/ByteCode/IntegralAP.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,16 @@ template <bool Signed> class IntegralAP final {
136136
APValue toAPValue(const ASTContext &) const { return APValue(toAPSInt()); }
137137

138138
bool isZero() const { return V.isZero(); }
139-
bool isPositive() const { return V.isNonNegative(); }
140-
bool isNegative() const { return !V.isNonNegative(); }
139+
bool isPositive() const {
140+
if constexpr (Signed)
141+
return V.isNonNegative();
142+
return true;
143+
}
144+
bool isNegative() const {
145+
if constexpr (Signed)
146+
return !V.isNonNegative();
147+
return false;
148+
}
141149
bool isMin() const { return V.isMinValue(); }
142150
bool isMax() const { return V.isMaxValue(); }
143151
static constexpr bool isSigned() { return Signed; }

clang/test/AST/ByteCode/intap.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ static_assert(INT128_MAX == 0, ""); // expected-error {{failed}} \
104104
// ref-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
105105
static const __int128_t INT128_MIN = -INT128_MAX - 1;
106106

107+
108+
namespace PointerArithmeticOverflow {
109+
int n;
110+
constexpr int *p = (&n + 1) + (unsigned __int128)-1; // expected-error {{constant expression}} \
111+
// expected-note {{cannot refer to element 3402}} \
112+
// ref-error {{constant expression}} \
113+
// ref-note {{cannot refer to element 3402}}
114+
}
115+
107116
namespace i128 {
108117

109118
constexpr int128_t I128_1 = 12;

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 509523
19+
#define LLVM_MAIN_REVISION 509524
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

0 commit comments

Comments
 (0)