@@ -100,18 +100,17 @@ class IteratorModeling
100
100
const AdvanceFn *Handler) const ;
101
101
102
102
void handleComparison (CheckerContext &C, const Expr *CE, SVal RetVal,
103
- const SVal &LVal, const SVal &RVal,
104
- OverloadedOperatorKind Op) const ;
103
+ SVal LVal, SVal RVal, OverloadedOperatorKind Op) const ;
105
104
void processComparison (CheckerContext &C, ProgramStateRef State,
106
- SymbolRef Sym1, SymbolRef Sym2, const SVal & RetVal,
105
+ SymbolRef Sym1, SymbolRef Sym2, SVal RetVal,
107
106
OverloadedOperatorKind Op) const ;
108
- void handleIncrement (CheckerContext &C, const SVal & RetVal, const SVal & Iter,
107
+ void handleIncrement (CheckerContext &C, SVal RetVal, SVal Iter,
109
108
bool Postfix) const ;
110
- void handleDecrement (CheckerContext &C, const SVal & RetVal, const SVal & Iter,
109
+ void handleDecrement (CheckerContext &C, SVal RetVal, SVal Iter,
111
110
bool Postfix) const ;
112
111
void handleRandomIncrOrDecr (CheckerContext &C, const Expr *CE,
113
- OverloadedOperatorKind Op, const SVal & RetVal,
114
- const SVal & Iterator, const SVal & Amount) const ;
112
+ OverloadedOperatorKind Op, SVal RetVal,
113
+ SVal Iterator, SVal Amount) const ;
115
114
void handlePtrIncrOrDecr (CheckerContext &C, const Expr *Iterator,
116
115
OverloadedOperatorKind OK, SVal Offset) const ;
117
116
void handleAdvance (CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
@@ -120,7 +119,7 @@ class IteratorModeling
120
119
SVal Amount) const ;
121
120
void handleNext (CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
122
121
SVal Amount) const ;
123
- void assignToContainer (CheckerContext &C, const Expr *CE, const SVal & RetVal,
122
+ void assignToContainer (CheckerContext &C, const Expr *CE, SVal RetVal,
124
123
const MemRegion *Cont) const ;
125
124
bool noChangeInAdvance (CheckerContext &C, SVal Iter, const Expr *CE) const ;
126
125
void printState (raw_ostream &Out, ProgramStateRef State, const char *NL,
@@ -160,7 +159,7 @@ class IteratorModeling
160
159
161
160
bool isSimpleComparisonOperator (OverloadedOperatorKind OK);
162
161
bool isSimpleComparisonOperator (BinaryOperatorKind OK);
163
- ProgramStateRef removeIteratorPosition (ProgramStateRef State, const SVal & Val);
162
+ ProgramStateRef removeIteratorPosition (ProgramStateRef State, SVal Val);
164
163
ProgramStateRef relateSymbols (ProgramStateRef State, SymbolRef Sym1,
165
164
SymbolRef Sym2, bool Equal);
166
165
bool isBoundThroughLazyCompoundVal (const Environment &Env,
@@ -283,7 +282,7 @@ void IteratorModeling::checkPostStmt(const BinaryOperator *BO,
283
282
// The non-iterator side must have an integral or enumeration type.
284
283
if (!AmountExpr->getType ()->isIntegralOrEnumerationType ())
285
284
return ;
286
- const SVal & AmountVal = IsIterOnLHS ? RVal : LVal;
285
+ SVal AmountVal = IsIterOnLHS ? RVal : LVal;
287
286
handlePtrIncrOrDecr (C, IterExpr, BinaryOperator::getOverloadedOperator (OK),
288
287
AmountVal);
289
288
}
@@ -388,8 +387,8 @@ IteratorModeling::handleOverloadedOperator(CheckerContext &C,
388
387
const bool IsIterFirst = FirstType->isStructureOrClassType ();
389
388
const SVal FirstArg = Call.getArgSVal (0 );
390
389
const SVal SecondArg = Call.getArgSVal (1 );
391
- const SVal & Iterator = IsIterFirst ? FirstArg : SecondArg;
392
- const SVal & Amount = IsIterFirst ? SecondArg : FirstArg;
390
+ SVal Iterator = IsIterFirst ? FirstArg : SecondArg;
391
+ SVal Amount = IsIterFirst ? SecondArg : FirstArg;
393
392
394
393
handleRandomIncrOrDecr (C, OrigExpr, Op, Call.getReturnValue (),
395
394
Iterator, Amount);
@@ -444,14 +443,13 @@ IteratorModeling::handleAdvanceLikeFunction(CheckerContext &C,
444
443
}
445
444
446
445
void IteratorModeling::handleComparison (CheckerContext &C, const Expr *CE,
447
- SVal RetVal, const SVal &LVal,
448
- const SVal &RVal,
449
- OverloadedOperatorKind Op) const {
446
+ SVal RetVal, SVal LVal, SVal RVal,
447
+ OverloadedOperatorKind Op) const {
450
448
// Record the operands and the operator of the comparison for the next
451
449
// evalAssume, if the result is a symbolic expression. If it is a concrete
452
450
// value (only one branch is possible), then transfer the state between
453
451
// the operands according to the operator and the result
454
- auto State = C.getState ();
452
+ auto State = C.getState ();
455
453
const auto *LPos = getIteratorPosition (State, LVal);
456
454
const auto *RPos = getIteratorPosition (State, RVal);
457
455
const MemRegion *Cont = nullptr ;
@@ -504,7 +502,7 @@ void IteratorModeling::handleComparison(CheckerContext &C, const Expr *CE,
504
502
505
503
void IteratorModeling::processComparison (CheckerContext &C,
506
504
ProgramStateRef State, SymbolRef Sym1,
507
- SymbolRef Sym2, const SVal & RetVal,
505
+ SymbolRef Sym2, SVal RetVal,
508
506
OverloadedOperatorKind Op) const {
509
507
if (const auto TruthVal = RetVal.getAs <nonloc::ConcreteInt>()) {
510
508
if ((State = relateSymbols (State, Sym1, Sym2,
@@ -532,8 +530,8 @@ void IteratorModeling::processComparison(CheckerContext &C,
532
530
}
533
531
}
534
532
535
- void IteratorModeling::handleIncrement (CheckerContext &C, const SVal & RetVal,
536
- const SVal & Iter, bool Postfix) const {
533
+ void IteratorModeling::handleIncrement (CheckerContext &C, SVal RetVal,
534
+ SVal Iter, bool Postfix) const {
537
535
// Increment the symbolic expressions which represents the position of the
538
536
// iterator
539
537
auto State = C.getState ();
@@ -558,8 +556,8 @@ void IteratorModeling::handleIncrement(CheckerContext &C, const SVal &RetVal,
558
556
C.addTransition (State);
559
557
}
560
558
561
- void IteratorModeling::handleDecrement (CheckerContext &C, const SVal & RetVal,
562
- const SVal & Iter, bool Postfix) const {
559
+ void IteratorModeling::handleDecrement (CheckerContext &C, SVal RetVal,
560
+ SVal Iter, bool Postfix) const {
563
561
// Decrement the symbolic expressions which represents the position of the
564
562
// iterator
565
563
auto State = C.getState ();
@@ -586,9 +584,8 @@ void IteratorModeling::handleDecrement(CheckerContext &C, const SVal &RetVal,
586
584
587
585
void IteratorModeling::handleRandomIncrOrDecr (CheckerContext &C, const Expr *CE,
588
586
OverloadedOperatorKind Op,
589
- const SVal &RetVal,
590
- const SVal &Iterator,
591
- const SVal &Amount) const {
587
+ SVal RetVal, SVal Iterator,
588
+ SVal Amount) const {
592
589
// Increment or decrement the symbolic expressions which represents the
593
590
// position of the iterator
594
591
auto State = C.getState ();
@@ -684,7 +681,7 @@ void IteratorModeling::handleNext(CheckerContext &C, const Expr *CE,
684
681
}
685
682
686
683
void IteratorModeling::assignToContainer (CheckerContext &C, const Expr *CE,
687
- const SVal & RetVal,
684
+ SVal RetVal,
688
685
const MemRegion *Cont) const {
689
686
Cont = Cont->getMostDerivedObjectRegion ();
690
687
@@ -772,7 +769,7 @@ bool isSimpleComparisonOperator(BinaryOperatorKind OK) {
772
769
return OK == BO_EQ || OK == BO_NE;
773
770
}
774
771
775
- ProgramStateRef removeIteratorPosition (ProgramStateRef State, const SVal & Val) {
772
+ ProgramStateRef removeIteratorPosition (ProgramStateRef State, SVal Val) {
776
773
if (auto Reg = Val.getAsRegion ()) {
777
774
Reg = Reg->getMostDerivedObjectRegion ();
778
775
return State->remove <IteratorRegionMap>(Reg);
0 commit comments