@@ -67,7 +67,7 @@ void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
6767 },
6868 subvalue);
6969 if (subexpr)
70- mValues [subexpr] = subvalue;
70+ mValues [subexpr] = std::move ( subvalue) ;
7171}
7272const ValueFlow::Value* ProgramMemory::getValue (nonneg int exprid, bool impossible) const
7373{
@@ -183,10 +183,10 @@ bool ProgramMemory::empty() const
183183 return mValues .empty ();
184184}
185185
186- void ProgramMemory::replace (const ProgramMemory & pm)
186+ void ProgramMemory::replace (ProgramMemory pm)
187187{
188188 for (auto && p : pm.mValues ) {
189- mValues [p.first ] = p.second ;
189+ mValues [p.first ] = std::move ( p.second ) ;
190190 }
191191}
192192
@@ -448,12 +448,12 @@ void ProgramMemoryState::insert(const ProgramMemory &pm, const Token* origin)
448448 state.insert (pm);
449449}
450450
451- void ProgramMemoryState::replace (const ProgramMemory & pm, const Token* origin)
451+ void ProgramMemoryState::replace (ProgramMemory pm, const Token* origin)
452452{
453453 if (origin)
454- for (auto & & p : pm)
454+ for (const auto & p : pm)
455455 origins[p.first .getExpressionId ()] = origin;
456- state.replace (pm );
456+ state.replace (std::move (pm) );
457457}
458458
459459static void addVars (ProgramMemory& pm, const ProgramMemory::Map& vars)
@@ -472,7 +472,7 @@ void ProgramMemoryState::addState(const Token* tok, const ProgramMemory::Map& va
472472 ProgramMemory local = pm;
473473 fillProgramMemoryFromAssignments (pm, tok, settings, local, vars);
474474 addVars (pm, vars);
475- replace (pm , tok);
475+ replace (std::move (pm) , tok);
476476}
477477
478478void ProgramMemoryState::assume (const Token* tok, bool b, bool isEmpty)
@@ -495,7 +495,7 @@ void ProgramMemoryState::assume(const Token* tok, bool b, bool isEmpty)
495495
496496void ProgramMemoryState::removeModifiedVars (const Token* tok)
497497{
498- ProgramMemory pm = state;
498+ const ProgramMemory& pm = state;
499499 auto eval = [&](const Token* cond) -> std::vector<MathLib::bigint> {
500500 if (conditionIsTrue (cond, pm, settings))
501501 return {1 };
@@ -1270,9 +1270,10 @@ namespace {
12701270 ValueFlow::Value r = state.execute (tok);
12711271 if (r.isUninitValue ())
12721272 continue ;
1273- result.insert (std::make_pair (tok->exprId (), r));
1273+ const bool brk = b && isTrueOrFalse (r, *b);
1274+ result.emplace (tok->exprId (), std::move (r));
12741275 // Short-circuit evaluation
1275- if (b && isTrueOrFalse (r, *b) )
1276+ if (brk )
12761277 break ;
12771278 }
12781279 return result;
@@ -1496,13 +1497,13 @@ namespace {
14961497 if (expr->isComparisonOp () && (r.isUninitValue () || r.isImpossible ())) {
14971498 if (rhs.isIntValue ()) {
14981499 std::vector<ValueFlow::Value> result =
1499- infer (ValueFlow::makeIntegralInferModel (), expr->str (), expr->astOperand1 ()->values (), {rhs});
1500+ infer (ValueFlow::makeIntegralInferModel (), expr->str (), expr->astOperand1 ()->values (), {std::move ( rhs) });
15001501 if (!result.empty () && result.front ().isKnown ())
15011502 return result.front ();
15021503 }
15031504 if (lhs.isIntValue ()) {
15041505 std::vector<ValueFlow::Value> result =
1505- infer (ValueFlow::makeIntegralInferModel (), expr->str (), {lhs}, expr->astOperand2 ()->values ());
1506+ infer (ValueFlow::makeIntegralInferModel (), expr->str (), {std::move ( lhs) }, expr->astOperand2 ()->values ());
15061507 if (!result.empty () && result.front ().isKnown ())
15071508 return result.front ();
15081509 }
0 commit comments