@@ -67,7 +67,7 @@ void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
67
67
},
68
68
subvalue);
69
69
if (subexpr)
70
- mValues [subexpr] = subvalue;
70
+ mValues [subexpr] = std::move ( subvalue) ;
71
71
}
72
72
const ValueFlow::Value* ProgramMemory::getValue (nonneg int exprid, bool impossible) const
73
73
{
@@ -183,10 +183,10 @@ bool ProgramMemory::empty() const
183
183
return mValues .empty ();
184
184
}
185
185
186
- void ProgramMemory::replace (const ProgramMemory & pm)
186
+ void ProgramMemory::replace (ProgramMemory pm)
187
187
{
188
188
for (auto && p : pm.mValues ) {
189
- mValues [p.first ] = p.second ;
189
+ mValues [p.first ] = std::move ( p.second ) ;
190
190
}
191
191
}
192
192
@@ -448,12 +448,12 @@ void ProgramMemoryState::insert(const ProgramMemory &pm, const Token* origin)
448
448
state.insert (pm);
449
449
}
450
450
451
- void ProgramMemoryState::replace (const ProgramMemory & pm, const Token* origin)
451
+ void ProgramMemoryState::replace (ProgramMemory pm, const Token* origin)
452
452
{
453
453
if (origin)
454
- for (auto & & p : pm)
454
+ for (const auto & p : pm)
455
455
origins[p.first .getExpressionId ()] = origin;
456
- state.replace (pm );
456
+ state.replace (std::move (pm) );
457
457
}
458
458
459
459
static void addVars (ProgramMemory& pm, const ProgramMemory::Map& vars)
@@ -472,7 +472,7 @@ void ProgramMemoryState::addState(const Token* tok, const ProgramMemory::Map& va
472
472
ProgramMemory local = pm;
473
473
fillProgramMemoryFromAssignments (pm, tok, settings, local, vars);
474
474
addVars (pm, vars);
475
- replace (pm , tok);
475
+ replace (std::move (pm) , tok);
476
476
}
477
477
478
478
void ProgramMemoryState::assume (const Token* tok, bool b, bool isEmpty)
@@ -495,7 +495,7 @@ void ProgramMemoryState::assume(const Token* tok, bool b, bool isEmpty)
495
495
496
496
void ProgramMemoryState::removeModifiedVars (const Token* tok)
497
497
{
498
- ProgramMemory pm = state;
498
+ const ProgramMemory& pm = state;
499
499
auto eval = [&](const Token* cond) -> std::vector<MathLib::bigint> {
500
500
if (conditionIsTrue (cond, pm, settings))
501
501
return {1 };
@@ -1270,9 +1270,10 @@ namespace {
1270
1270
ValueFlow::Value r = state.execute (tok);
1271
1271
if (r.isUninitValue ())
1272
1272
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));
1274
1275
// Short-circuit evaluation
1275
- if (b && isTrueOrFalse (r, *b) )
1276
+ if (brk )
1276
1277
break ;
1277
1278
}
1278
1279
return result;
@@ -1496,13 +1497,13 @@ namespace {
1496
1497
if (expr->isComparisonOp () && (r.isUninitValue () || r.isImpossible ())) {
1497
1498
if (rhs.isIntValue ()) {
1498
1499
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) });
1500
1501
if (!result.empty () && result.front ().isKnown ())
1501
1502
return result.front ();
1502
1503
}
1503
1504
if (lhs.isIntValue ()) {
1504
1505
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 ());
1506
1507
if (!result.empty () && result.front ().isKnown ())
1507
1508
return result.front ();
1508
1509
}
0 commit comments