Skip to content

Commit 7c863a4

Browse files
committed
programmemory.cpp: avoid unnecessary copy in programMemoryParseCondition()
1 parent 0c79d5b commit 7c863a4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/programmemory.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,13 @@ static void programMemoryParseCondition(ProgramMemory& pm, const Token* tok, con
327327
if (endTok && findExpressionChanged(vartok, tok->next(), endTok, settings))
328328
return;
329329
const bool impossible = (tok->str() == "==" && !then) || (tok->str() == "!=" && then);
330-
const ValueFlow::Value& v = then ? truevalue : falsevalue;
331-
pm.setValue(vartok, impossible ? asImpossible(v) : v);
330+
ValueFlow::Value& v = then ? truevalue : falsevalue;
331+
const auto iv = v.intvalue;
332+
// cppcheck-suppress accessMoved - FP #13628
333+
pm.setValue(vartok, impossible ? asImpossible(std::move(v)) : v);
332334
const Token* containerTok = settings.library.getContainerFromYield(vartok, Library::Container::Yield::SIZE);
333335
if (containerTok)
334-
pm.setContainerSizeValue(containerTok, v.intvalue, !impossible);
336+
pm.setContainerSizeValue(containerTok, iv, !impossible);
335337
} else if (Token::simpleMatch(tok, "!")) {
336338
programMemoryParseCondition(pm, tok->astOperand1(), endTok, settings, !then);
337339
} else if (then && Token::simpleMatch(tok, "&&")) {

0 commit comments

Comments
 (0)