@@ -100,18 +100,17 @@ class IteratorModeling
100100 const AdvanceFn *Handler) const ;
101101
102102 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 ;
105104 void processComparison (CheckerContext &C, ProgramStateRef State,
106- SymbolRef Sym1, SymbolRef Sym2, const SVal & RetVal,
105+ SymbolRef Sym1, SymbolRef Sym2, SVal RetVal,
107106 OverloadedOperatorKind Op) const ;
108- void handleIncrement (CheckerContext &C, const SVal & RetVal, const SVal & Iter,
107+ void handleIncrement (CheckerContext &C, SVal RetVal, SVal Iter,
109108 bool Postfix) const ;
110- void handleDecrement (CheckerContext &C, const SVal & RetVal, const SVal & Iter,
109+ void handleDecrement (CheckerContext &C, SVal RetVal, SVal Iter,
111110 bool Postfix) const ;
112111 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 ;
115114 void handlePtrIncrOrDecr (CheckerContext &C, const Expr *Iterator,
116115 OverloadedOperatorKind OK, SVal Offset) const ;
117116 void handleAdvance (CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
@@ -120,7 +119,7 @@ class IteratorModeling
120119 SVal Amount) const ;
121120 void handleNext (CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
122121 SVal Amount) const ;
123- void assignToContainer (CheckerContext &C, const Expr *CE, const SVal & RetVal,
122+ void assignToContainer (CheckerContext &C, const Expr *CE, SVal RetVal,
124123 const MemRegion *Cont) const ;
125124 bool noChangeInAdvance (CheckerContext &C, SVal Iter, const Expr *CE) const ;
126125 void printState (raw_ostream &Out, ProgramStateRef State, const char *NL,
@@ -160,7 +159,7 @@ class IteratorModeling
160159
161160bool isSimpleComparisonOperator (OverloadedOperatorKind OK);
162161bool isSimpleComparisonOperator (BinaryOperatorKind OK);
163- ProgramStateRef removeIteratorPosition (ProgramStateRef State, const SVal & Val);
162+ ProgramStateRef removeIteratorPosition (ProgramStateRef State, SVal Val);
164163ProgramStateRef relateSymbols (ProgramStateRef State, SymbolRef Sym1,
165164 SymbolRef Sym2, bool Equal);
166165bool isBoundThroughLazyCompoundVal (const Environment &Env,
@@ -283,7 +282,7 @@ void IteratorModeling::checkPostStmt(const BinaryOperator *BO,
283282 // The non-iterator side must have an integral or enumeration type.
284283 if (!AmountExpr->getType ()->isIntegralOrEnumerationType ())
285284 return ;
286- const SVal & AmountVal = IsIterOnLHS ? RVal : LVal;
285+ SVal AmountVal = IsIterOnLHS ? RVal : LVal;
287286 handlePtrIncrOrDecr (C, IterExpr, BinaryOperator::getOverloadedOperator (OK),
288287 AmountVal);
289288 }
@@ -388,8 +387,8 @@ IteratorModeling::handleOverloadedOperator(CheckerContext &C,
388387 const bool IsIterFirst = FirstType->isStructureOrClassType ();
389388 const SVal FirstArg = Call.getArgSVal (0 );
390389 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;
393392
394393 handleRandomIncrOrDecr (C, OrigExpr, Op, Call.getReturnValue (),
395394 Iterator, Amount);
@@ -444,14 +443,13 @@ IteratorModeling::handleAdvanceLikeFunction(CheckerContext &C,
444443}
445444
446445void 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 {
450448 // Record the operands and the operator of the comparison for the next
451449 // evalAssume, if the result is a symbolic expression. If it is a concrete
452450 // value (only one branch is possible), then transfer the state between
453451 // the operands according to the operator and the result
454- auto State = C.getState ();
452+ auto State = C.getState ();
455453 const auto *LPos = getIteratorPosition (State, LVal);
456454 const auto *RPos = getIteratorPosition (State, RVal);
457455 const MemRegion *Cont = nullptr ;
@@ -504,7 +502,7 @@ void IteratorModeling::handleComparison(CheckerContext &C, const Expr *CE,
504502
505503void IteratorModeling::processComparison (CheckerContext &C,
506504 ProgramStateRef State, SymbolRef Sym1,
507- SymbolRef Sym2, const SVal & RetVal,
505+ SymbolRef Sym2, SVal RetVal,
508506 OverloadedOperatorKind Op) const {
509507 if (const auto TruthVal = RetVal.getAs <nonloc::ConcreteInt>()) {
510508 if ((State = relateSymbols (State, Sym1, Sym2,
@@ -532,8 +530,8 @@ void IteratorModeling::processComparison(CheckerContext &C,
532530 }
533531}
534532
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 {
537535 // Increment the symbolic expressions which represents the position of the
538536 // iterator
539537 auto State = C.getState ();
@@ -558,8 +556,8 @@ void IteratorModeling::handleIncrement(CheckerContext &C, const SVal &RetVal,
558556 C.addTransition (State);
559557}
560558
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 {
563561 // Decrement the symbolic expressions which represents the position of the
564562 // iterator
565563 auto State = C.getState ();
@@ -586,9 +584,8 @@ void IteratorModeling::handleDecrement(CheckerContext &C, const SVal &RetVal,
586584
587585void IteratorModeling::handleRandomIncrOrDecr (CheckerContext &C, const Expr *CE,
588586 OverloadedOperatorKind Op,
589- const SVal &RetVal,
590- const SVal &Iterator,
591- const SVal &Amount) const {
587+ SVal RetVal, SVal Iterator,
588+ SVal Amount) const {
592589 // Increment or decrement the symbolic expressions which represents the
593590 // position of the iterator
594591 auto State = C.getState ();
@@ -684,7 +681,7 @@ void IteratorModeling::handleNext(CheckerContext &C, const Expr *CE,
684681}
685682
686683void IteratorModeling::assignToContainer (CheckerContext &C, const Expr *CE,
687- const SVal & RetVal,
684+ SVal RetVal,
688685 const MemRegion *Cont) const {
689686 Cont = Cont->getMostDerivedObjectRegion ();
690687
@@ -772,7 +769,7 @@ bool isSimpleComparisonOperator(BinaryOperatorKind OK) {
772769 return OK == BO_EQ || OK == BO_NE;
773770}
774771
775- ProgramStateRef removeIteratorPosition (ProgramStateRef State, const SVal & Val) {
772+ ProgramStateRef removeIteratorPosition (ProgramStateRef State, SVal Val) {
776773 if (auto Reg = Val.getAsRegion ()) {
777774 Reg = Reg->getMostDerivedObjectRegion ();
778775 return State->remove <IteratorRegionMap>(Reg);
0 commit comments