Skip to content

Commit bda8441

Browse files
committed
[analyzer][NFC] Migrate nonloc::ConcreteInt to use APSIntPtr (2/4)
1 parent eddf348 commit bda8441

18 files changed

+65
-61
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ class ElementRegion : public TypedValueRegion {
12061206
: TypedValueRegion(sReg, ElementRegionKind), ElementType(elementType),
12071207
Index(Idx) {
12081208
assert((!isa<nonloc::ConcreteInt>(Idx) ||
1209-
Idx.castAs<nonloc::ConcreteInt>().getValue().isSigned()) &&
1209+
Idx.castAs<nonloc::ConcreteInt>().getValue()->isSigned()) &&
12101210
"The index must be signed");
12111211
assert(!elementType.isNull() && !elementType->isVoidType() &&
12121212
"Invalid region type!");

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/AST/Expr.h"
1818
#include "clang/AST/Type.h"
1919
#include "clang/Basic/LLVM.h"
20+
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntPtr.h"
2021
#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
2122
#include "llvm/ADT/APSInt.h"
2223
#include "llvm/ADT/FoldingSet.h"
@@ -298,9 +299,12 @@ class SymbolVal : public NonLoc {
298299
/// Value representing integer constant.
299300
class ConcreteInt : public NonLoc {
300301
public:
301-
explicit ConcreteInt(const llvm::APSInt &V) : NonLoc(ConcreteIntKind, &V) {}
302+
explicit ConcreteInt(APSIntPtr V) : NonLoc(ConcreteIntKind, V.get()) {}
302303

303-
const llvm::APSInt &getValue() const { return *castDataAs<llvm::APSInt>(); }
304+
APSIntPtr getValue() const {
305+
// This is safe because in the ctor we take a safe APSIntPtr.
306+
return APSIntPtr::unsafeConstructor(castDataAs<llvm::APSInt>());
307+
}
304308

305309
static bool classof(SVal V) { return V.getKind() == ConcreteIntKind; }
306310
};

clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
2323
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
2424
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
25+
#include "llvm/ADT/APSInt.h"
2526
#include "llvm/ADT/SmallString.h"
2627
#include "llvm/Support/FormatVariadic.h"
2728
#include "llvm/Support/raw_ostream.h"
@@ -241,26 +242,25 @@ computeOffset(ProgramStateRef State, SValBuilder &SVB, SVal Location) {
241242
static std::pair<NonLoc, nonloc::ConcreteInt>
242243
getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent,
243244
SValBuilder &svalBuilder) {
245+
const llvm::APSInt &extentVal = extent.getValue();
244246
std::optional<nonloc::SymbolVal> SymVal = offset.getAs<nonloc::SymbolVal>();
245247
if (SymVal && SymVal->isExpression()) {
246248
if (const SymIntExpr *SIE = dyn_cast<SymIntExpr>(SymVal->getSymbol())) {
247-
llvm::APSInt constant =
248-
APSIntType(extent.getValue()).convert(SIE->getRHS());
249+
llvm::APSInt constant = APSIntType(extentVal).convert(SIE->getRHS());
249250
switch (SIE->getOpcode()) {
250251
case BO_Mul:
251252
// The constant should never be 0 here, becasue multiplication by zero
252253
// is simplified by the engine.
253-
if ((extent.getValue() % constant) != 0)
254+
if ((extentVal % constant) != 0)
254255
return std::pair<NonLoc, nonloc::ConcreteInt>(offset, extent);
255256
else
256257
return getSimplifiedOffsets(
257258
nonloc::SymbolVal(SIE->getLHS()),
258-
svalBuilder.makeIntVal(extent.getValue() / constant),
259-
svalBuilder);
259+
svalBuilder.makeIntVal(extentVal / constant), svalBuilder);
260260
case BO_Add:
261261
return getSimplifiedOffsets(
262262
nonloc::SymbolVal(SIE->getLHS()),
263-
svalBuilder.makeIntVal(extent.getValue() - constant), svalBuilder);
263+
svalBuilder.makeIntVal(extentVal - constant), svalBuilder);
264264
default:
265265
break;
266266
}
@@ -363,7 +363,7 @@ static std::string getRegionName(const SubRegion *Region) {
363363

364364
static std::optional<int64_t> getConcreteValue(NonLoc SV) {
365365
if (auto ConcreteVal = SV.getAs<nonloc::ConcreteInt>()) {
366-
return ConcreteVal->getValue().tryExtValue();
366+
return ConcreteVal->getValue()->tryExtValue();
367367
}
368368
return std::nullopt;
369369
}

clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ void CFNumberChecker::checkPreStmt(const CallExpr *CE,
457457
if (!V)
458458
return;
459459

460-
uint64_t NumberKind = V->getValue().getLimitedValue();
460+
uint64_t NumberKind = V->getValue()->getLimitedValue();
461461
std::optional<uint64_t> OptCFNumberSize = GetCFNumberSize(Ctx, NumberKind);
462462

463463
// FIXME: In some cases we can emit an error.

clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ BugReportPtr BitwiseShiftValidator::checkLeftShiftOverflow() {
252252

253253
// We should have already reported a bug if the left operand of the shift was
254254
// negative, so it cannot be negative here.
255-
assert(Left->getValue().isNonNegative());
255+
assert(Left->getValue()->isNonNegative());
256256

257257
const unsigned LeftAvailableBitWidth =
258258
LeftBitWidth - static_cast<unsigned>(ShouldPreserveSignBit);
259-
const unsigned UsedBitsInLeftOperand = Left->getValue().getActiveBits();
259+
const unsigned UsedBitsInLeftOperand = Left->getValue()->getActiveBits();
260260
assert(LeftBitWidth >= UsedBitsInLeftOperand);
261261
const unsigned MaximalAllowedShift =
262262
LeftAvailableBitWidth - UsedBitsInLeftOperand;
@@ -275,9 +275,9 @@ BugReportPtr BitwiseShiftValidator::checkLeftShiftOverflow() {
275275
if (const auto ConcreteRight = Right.getAs<nonloc::ConcreteInt>()) {
276276
// Here ConcreteRight must contain a small non-negative integer, because
277277
// otherwise one of the earlier checks should've reported a bug.
278-
const unsigned RHS = ConcreteRight->getValue().getExtValue();
278+
const int64_t RHS = ConcreteRight->getValue()->getExtValue();
279279
assert(RHS > MaximalAllowedShift);
280-
const unsigned OverflownBits = RHS - MaximalAllowedShift;
280+
const int64_t OverflownBits = RHS - MaximalAllowedShift;
281281
ShortMsg = formatv(
282282
"The shift '{0} << {1}' overflows the capacity of '{2}'",
283283
Left->getValue(), ConcreteRight->getValue(), LHSTy.getAsString());

clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ BuiltinFunctionChecker::checkOverflow(CheckerContext &C, SVal RetVal,
155155
unsigned BitWidth = C.getASTContext().getIntWidth(Res);
156156
bool IsUnsigned = Res->isUnsignedIntegerType();
157157

158+
SValBuilder &SVB = C.getSValBuilder();
159+
BasicValueFactory &VF = SVB.getBasicValueFactory();
160+
158161
auto MinValType = llvm::APSInt::getMinValue(BitWidth, IsUnsigned);
159162
auto MaxValType = llvm::APSInt::getMaxValue(BitWidth, IsUnsigned);
160-
nonloc::ConcreteInt MinVal{MinValType};
161-
nonloc::ConcreteInt MaxVal{MaxValType};
163+
nonloc::ConcreteInt MinVal{VF.getValue(MinValType)};
164+
nonloc::ConcreteInt MaxVal{VF.getValue(MaxValType)};
162165

163-
SValBuilder &SVB = C.getSValBuilder();
164166
ProgramStateRef State = C.getState();
165167
SVal IsLeMax = SVB.evalBinOp(State, BO_LE, RetVal, MaxVal, Res);
166168
SVal IsGeMin = SVB.evalBinOp(State, BO_GE, RetVal, MinVal, Res);

clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
124124
"requires {1} bytes. Current overhead requires the size of {2} "
125125
"bytes",
126126
SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue(),
127-
SizeOfPlaceCI->getValue() - SizeOfTargetCI->getValue()));
127+
*SizeOfPlaceCI->getValue().get() - SizeOfTargetCI->getValue()));
128128
else if (IsArrayTypeAllocated &&
129129
SizeOfPlaceCI->getValue() == SizeOfTargetCI->getValue())
130130
Msg = std::string(llvm::formatv(

clang/lib/StaticAnalyzer/Checkers/Iterator.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ ProgramStateRef advancePosition(ProgramStateRef State, SVal Iter,
241241
// For concrete integers we can calculate the new position
242242
nonloc::ConcreteInt IntDist = *IntDistOp;
243243

244-
if (IntDist.getValue().isNegative()) {
244+
if (IntDist.getValue()->isNegative()) {
245245
IntDist = nonloc::ConcreteInt(BVF.getValue(-IntDist.getValue()));
246246
BinOp = (BinOp == BO_Add) ? BO_Sub : BO_Add;
247247
}
@@ -272,19 +272,19 @@ ProgramStateRef assumeNoOverflow(ProgramStateRef State, SymbolRef Sym,
272272
ProgramStateRef NewState = State;
273273

274274
llvm::APSInt Max = AT.getMaxValue() / AT.getValue(Scale);
275-
SVal IsCappedFromAbove =
276-
SVB.evalBinOpNN(State, BO_LE, nonloc::SymbolVal(Sym),
277-
nonloc::ConcreteInt(Max), SVB.getConditionType());
275+
SVal IsCappedFromAbove = SVB.evalBinOpNN(
276+
State, BO_LE, nonloc::SymbolVal(Sym),
277+
nonloc::ConcreteInt(BV.getValue(Max)), SVB.getConditionType());
278278
if (auto DV = IsCappedFromAbove.getAs<DefinedSVal>()) {
279279
NewState = NewState->assume(*DV, true);
280280
if (!NewState)
281281
return State;
282282
}
283283

284284
llvm::APSInt Min = -Max;
285-
SVal IsCappedFromBelow =
286-
SVB.evalBinOpNN(State, BO_GE, nonloc::SymbolVal(Sym),
287-
nonloc::ConcreteInt(Min), SVB.getConditionType());
285+
SVal IsCappedFromBelow = SVB.evalBinOpNN(
286+
State, BO_GE, nonloc::SymbolVal(Sym),
287+
nonloc::ConcreteInt(BV.getValue(Min)), SVB.getConditionType());
288288
if (auto DV = IsCappedFromBelow.getAs<DefinedSVal>()) {
289289
NewState = NewState->assume(*DV, true);
290290
if (!NewState)

clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ void IteratorModeling::processComparison(CheckerContext &C,
507507
OverloadedOperatorKind Op) const {
508508
if (const auto TruthVal = RetVal.getAs<nonloc::ConcreteInt>()) {
509509
if ((State = relateSymbols(State, Sym1, Sym2,
510-
(Op == OO_EqualEqual) ==
511-
(TruthVal->getValue() != 0)))) {
510+
(Op == OO_EqualEqual) ==
511+
(TruthVal->getValue()->getBoolValue())))) {
512512
C.addTransition(State);
513513
} else {
514514
C.generateSink(State, C.getPredecessor());

clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void MmapWriteExecChecker::checkPreCall(const CallEvent &Call,
6868
auto ProtLoc = ProtVal.getAs<nonloc::ConcreteInt>();
6969
if (!ProtLoc)
7070
return;
71-
int64_t Prot = ProtLoc->getValue().getSExtValue();
71+
int64_t Prot = ProtLoc->getValue()->getSExtValue();
7272

7373
if ((Prot & ProtWrite) && (Prot & ProtExec)) {
7474
ExplodedNode *N = C.generateNonFatalErrorNode();

clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ StreamChecker::ensureFseekWhenceCorrect(SVal WhenceVal, CheckerContext &C,
19771977
if (!CI)
19781978
return State;
19791979

1980-
int64_t X = CI->getValue().getSExtValue();
1980+
int64_t X = CI->getValue()->getSExtValue();
19811981
if (X == SeekSetVal || X == SeekCurVal || X == SeekEndVal)
19821982
return State;
19831983

clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ getConcreteIntegerValue(const Expr *CondVarExpr, const ExplodedNode *N) {
264264

265265
if (std::optional<SVal> V = getSValForVar(CondVarExpr, N))
266266
if (auto CI = V->getAs<nonloc::ConcreteInt>())
267-
return &CI->getValue();
267+
return CI->getValue().get();
268268
return std::nullopt;
269269
}
270270

clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ std::string MemRegion::getDescriptiveName(bool UseQuotes) const {
743743
// Index is a ConcreteInt.
744744
if (auto CI = ER->getIndex().getAs<nonloc::ConcreteInt>()) {
745745
llvm::SmallString<2> Idx;
746-
CI->getValue().toString(Idx);
746+
CI->getValue()->toString(Idx);
747747
ArrayIndices = (llvm::Twine("[") + Idx.str() + "]" + ArrayIndices).str();
748748
}
749749
// Index is symbolic, but may have a descriptive name.
@@ -1458,9 +1458,7 @@ RegionRawOffset ElementRegion::getAsArrayOffset() const {
14581458
SVal index = ER->getIndex();
14591459
if (auto CI = index.getAs<nonloc::ConcreteInt>()) {
14601460
// Update the offset.
1461-
int64_t i = CI->getValue().getSExtValue();
1462-
1463-
if (i != 0) {
1461+
if (int64_t i = CI->getValue()->getSExtValue(); i != 0) {
14641462
QualType elemType = ER->getElementType();
14651463

14661464
// If we are pointing to an incomplete type, go no further.
@@ -1632,7 +1630,7 @@ static RegionOffset calculateOffset(const MemRegion *R) {
16321630
if (SymbolicOffsetBase)
16331631
continue;
16341632

1635-
int64_t i = CI->getValue().getSExtValue();
1633+
int64_t i = CI->getValue()->getSExtValue();
16361634
// This type size is in bits.
16371635
Offset += i * R->getContext().getTypeSize(EleTy);
16381636
} else {

clang/lib/StaticAnalyzer/Core/ProgramState.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,10 @@ SVal ProgramState::getSVal(Loc location, QualType T) const {
288288
// The symbolic value stored to 'x' is actually the conjured
289289
// symbol for the call to foo(); the type of that symbol is 'char',
290290
// not unsigned.
291-
const llvm::APSInt &NewV = getBasicVals().Convert(T, *Int);
292-
291+
APSIntPtr NewV = getBasicVals().Convert(T, *Int);
293292
if (V.getAs<Loc>())
294293
return loc::ConcreteInt(NewV);
295-
else
296-
return nonloc::ConcreteInt(NewV);
294+
return nonloc::ConcreteInt(NewV);
297295
}
298296
}
299297
}

clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ class EvalCastVisitor : public SValVisitor<EvalCastVisitor, SVal> {
875875

876876
// Integer to bool.
877877
if (CastTy->isBooleanType())
878-
return VB.makeTruthVal(V.getValue().getBoolValue(), CastTy);
878+
return VB.makeTruthVal(V.getValue()->getBoolValue(), CastTy);
879879

880880
// Integer to pointer.
881881
if (CastTy->isIntegralOrEnumerationType())

clang/lib/StaticAnalyzer/Core/SVals.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ SymbolRef SVal::getAsSymbol(bool IncludeBaseRegions) const {
111111

112112
const llvm::APSInt *SVal::getAsInteger() const {
113113
if (auto CI = getAs<nonloc::ConcreteInt>())
114-
return &CI->getValue();
114+
return CI->getValue().get();
115115
if (auto CI = getAs<loc::ConcreteInt>())
116116
return &CI->getValue();
117117
return nullptr;
@@ -251,7 +251,7 @@ bool SVal::isConstant(int I) const {
251251
if (std::optional<loc::ConcreteInt> LV = getAs<loc::ConcreteInt>())
252252
return LV->getValue() == I;
253253
if (std::optional<nonloc::ConcreteInt> NV = getAs<nonloc::ConcreteInt>())
254-
return NV->getValue() == I;
254+
return *NV->getValue().get() == I;
255255
return false;
256256
}
257257

@@ -314,9 +314,9 @@ void SVal::dumpToStream(raw_ostream &os) const {
314314
void NonLoc::dumpToStream(raw_ostream &os) const {
315315
switch (getKind()) {
316316
case nonloc::ConcreteIntKind: {
317-
const auto &Value = castAs<nonloc::ConcreteInt>().getValue();
318-
os << Value << ' ' << (Value.isSigned() ? 'S' : 'U') << Value.getBitWidth()
319-
<< 'b';
317+
APSIntPtr Value = castAs<nonloc::ConcreteInt>().getValue();
318+
os << Value << ' ' << (Value->isSigned() ? 'S' : 'U')
319+
<< Value->getBitWidth() << 'b';
320320
break;
321321
}
322322
case nonloc::SymbolValKind:

clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State,
7575
}
7676

7777
case nonloc::ConcreteIntKind: {
78-
bool b = Cond.castAs<nonloc::ConcreteInt>().getValue() != 0;
78+
bool b = *Cond.castAs<nonloc::ConcreteInt>().getValue().get() != 0;
7979
bool isFeasible = b ? Assumption : !Assumption;
8080
return isFeasible ? State : nullptr;
8181
}

clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
13+
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntPtr.h"
1414
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
1515
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
1616
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
17+
#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
1718
#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
1819
#include <optional>
1920

@@ -179,8 +180,7 @@ SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS,
179180
if (RHS == 0)
180181
isIdempotent = true;
181182
else if (RHS.isAllOnes()) {
182-
const llvm::APSInt &Result = BasicVals.Convert(resultTy, RHS);
183-
return nonloc::ConcreteInt(Result);
183+
return nonloc::ConcreteInt(BasicVals.Convert(resultTy, RHS));
184184
}
185185
break;
186186
}
@@ -234,9 +234,10 @@ SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS,
234234
static bool isInRelation(BinaryOperator::Opcode Rel, SymbolRef Sym,
235235
llvm::APSInt Bound, ProgramStateRef State) {
236236
SValBuilder &SVB = State->getStateManager().getSValBuilder();
237-
SVal Result =
238-
SVB.evalBinOpNN(State, Rel, nonloc::SymbolVal(Sym),
239-
nonloc::ConcreteInt(Bound), SVB.getConditionType());
237+
BasicValueFactory &BV = SVB.getBasicValueFactory();
238+
SVal Result = SVB.evalBinOpNN(State, Rel, nonloc::SymbolVal(Sym),
239+
nonloc::ConcreteInt(BV.getValue(Bound)),
240+
SVB.getConditionType());
240241
if (auto DV = Result.getAs<DefinedSVal>()) {
241242
return !State->assume(*DV, false);
242243
}
@@ -273,14 +274,14 @@ static bool isWithinConstantOverflowBounds(llvm::APSInt I) {
273274
return (I <= Max) && (I >= -Max);
274275
}
275276

276-
static std::pair<SymbolRef, llvm::APSInt>
277-
decomposeSymbol(SymbolRef Sym, BasicValueFactory &BV) {
277+
static std::pair<SymbolRef, APSIntPtr> decomposeSymbol(SymbolRef Sym,
278+
BasicValueFactory &BV) {
278279
if (const auto *SymInt = dyn_cast<SymIntExpr>(Sym))
279280
if (BinaryOperator::isAdditiveOp(SymInt->getOpcode()))
280281
return std::make_pair(SymInt->getLHS(),
281-
(SymInt->getOpcode() == BO_Add) ?
282-
(SymInt->getRHS()) :
283-
(-SymInt->getRHS()));
282+
(SymInt->getOpcode() == BO_Add)
283+
? BV.getValue(SymInt->getRHS())
284+
: BV.getValue(-SymInt->getRHS()));
284285

285286
// Fail to decompose: "reduce" the problem to the "$x + 0" case.
286287
return std::make_pair(Sym, BV.getValue(0, Sym->getType()));
@@ -314,8 +315,9 @@ static NonLoc doRearrangeUnchecked(ProgramStateRef State,
314315
llvm_unreachable("Operation not suitable for unchecked rearrangement!");
315316

316317
if (LSym == RSym)
317-
return SVB.evalBinOpNN(State, Op, nonloc::ConcreteInt(LInt),
318-
nonloc::ConcreteInt(RInt), ResultTy)
318+
return SVB
319+
.evalBinOpNN(State, Op, nonloc::ConcreteInt(BV.getValue(LInt)),
320+
nonloc::ConcreteInt(BV.getValue(RInt)), ResultTy)
319321
.castAs<NonLoc>();
320322

321323
SymbolRef ResultSym = nullptr;
@@ -1211,7 +1213,7 @@ const llvm::APSInt *SimpleSValBuilder::getConcreteValue(SVal V) {
12111213
return &X->getValue();
12121214

12131215
if (std::optional<nonloc::ConcreteInt> X = V.getAs<nonloc::ConcreteInt>())
1214-
return &X->getValue();
1216+
return X->getValue().get();
12151217

12161218
return nullptr;
12171219
}

0 commit comments

Comments
 (0)