Skip to content

Commit 1445cfb

Browse files
committed
Address review comments
1 parent 0d879e0 commit 1445cfb

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

clang/lib/AST/Interp/Context.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ std::optional<PrimType> Context::classify(QualType T) const {
104104
return PT_Sint8;
105105
default:
106106
return PT_IntAPS;
107-
// return std::nullopt;
108107
}
109108
}
110109

@@ -120,7 +119,6 @@ std::optional<PrimType> Context::classify(QualType T) const {
120119
return PT_Uint8;
121120
default:
122121
return PT_IntAP;
123-
// return std::nullopt;
124122
}
125123
}
126124

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ template <bool Signed> class IntegralAP final {
4343

4444
IntegralAP(APInt V) : V(V) {}
4545
IntegralAP(APSInt V) : V(V) {}
46-
IntegralAP(bool b) : V(APInt(8, b, Signed)) {}
47-
/// Bullshit value for initialized variables.
46+
/// Arbitrary value for initialized variables.
4847
IntegralAP() : V(APSInt::getMaxValue(1024, Signed)) {}
4948

5049
IntegralAP operator-() const { return IntegralAP(-V); }
51-
// bool operator <=> (const IntegralAP &RHS) const = default;
5250
bool operator>(IntegralAP RHS) const { return V > RHS.V; }
5351
bool operator>=(IntegralAP RHS) const { return V >= RHS.V; }
5452
bool operator<(IntegralAP RHS) const { return V < RHS.V; }
@@ -85,7 +83,7 @@ template <bool Signed> class IntegralAP final {
8583
template <unsigned Bits, bool InputSigned>
8684
static IntegralAP from(Integral<Bits, InputSigned> I) {
8785
assert(InputSigned);
88-
/// TODO: Take bits parameter.
86+
/// FIXME: Take bits parameter.
8987
APSInt Copy =
9088
APSInt(APInt(128, static_cast<int64_t>(I), InputSigned), !Signed);
9189
Copy.setIsSigned(Signed);
@@ -108,13 +106,13 @@ template <bool Signed> class IntegralAP final {
108106
APSInt toAPSInt(unsigned Bits = 0) const { return V; }
109107
APValue toAPValue() const { return APValue(V); }
110108

111-
bool isZero() const { return false; }
112-
bool isPositive() const { return true; }
113-
bool isNegative() const { return false; }
114-
bool isMin() const { return false; }
115-
bool isMax() const { return false; }
109+
bool isZero() const { return V.isZero(); }
110+
bool isPositive() const { return V.isNonNegative(); }
111+
bool isNegative() const { return !V.isNonNegative(); }
112+
bool isMin() const { return V.isMinValue(); }
113+
bool isMax() const { return V.isMaxValue(); }
116114
static bool isSigned() { return Signed; }
117-
bool isMinusOne() const { return false; }
115+
bool isMinusOne() const { return Signed && V == -1; }
118116

119117
unsigned countLeadingZeros() const { return V.countl_zero(); }
120118

@@ -142,12 +140,11 @@ template <bool Signed> class IntegralAP final {
142140
}
143141

144142
static bool add(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) {
145-
/// TODO: Gotta check if the result fits into OpBits bits.
146143
return CheckAddUB(A, B, OpBits, R);
147144
}
148145

149146
static bool sub(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) {
150-
/// TODO: Gotta check if the result fits into OpBits bits.
147+
/// FIXME: Gotta check if the result fits into OpBits bits.
151148
return CheckSubUB(A, B, R);
152149
}
153150

0 commit comments

Comments
 (0)