From d8f8fa41fbe891f9398bd5c6801a8f8518aef7fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 12 Feb 2024 19:10:14 +0100 Subject: [PATCH] fixed even more `COPY_INSTEAD_OF_MOVE` Coverity warnings (#5977) --- lib/checkother.cpp | 2 +- lib/settings.cpp | 4 ++-- lib/valueflow.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 8f0d7b1f52b..af2ca4ea432 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2535,7 +2535,7 @@ void CheckOther::checkDuplicateExpression() &errorPath) && !Token::Match(tok, "=|-|-=|/|/=") && isWithoutSideEffects(cpp, tok->astOperand1())) { - oppositeExpressionError(tok, errorPath); + oppositeExpressionError(tok, std::move(errorPath)); } else if (!Token::Match(tok, "[-/%]")) { // These operators are not associative if (styleEnabled && tok->astOperand2() && tok->str() == tok->astOperand1()->str() && isSameExpression(cpp, diff --git a/lib/settings.cpp b/lib/settings.cpp index dd3f057c7ad..0488785edf3 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -560,7 +560,7 @@ void Settings::setMisraRuleTexts(const ExecuteCmdFn& executeCommand) else arg = "--misra-c-2012-rule-texts"; std::string output; - executeCommand(it->executable, {arg}, "2>&1", output); + executeCommand(it->executable, {std::move(arg)}, "2>&1", output); setMisraRuleTexts(output); } } @@ -579,7 +579,7 @@ void Settings::setMisraRuleTexts(const std::string& data) std::string text = line.substr(pos + 1); if (id.empty() || text.empty()) continue; - mMisraRuleTexts[id] = text; + mMisraRuleTexts[id] = std::move(text); } } diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index f45d6ffbe42..d9d6d5d63f3 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -771,7 +771,7 @@ static void setTokenValue(Token* tok, } else if (parent->str() == ":") { - setTokenValue(parent,value,settings); + setTokenValue(parent,std::move(value),settings); } else if (parent->str() == "?" && tok->str() == ":" && tok == parent->astOperand2() && parent->astOperand1()) { @@ -1619,7 +1619,7 @@ static void valueFlowArrayElement(TokenList& tokenlist, const Settings& settings const std::string s = arrayValue.tokvalue->strValue(); if (index == s.size()) { result.intvalue = 0; - setTokenValue(tok, result, settings); + setTokenValue(tok, std::move(result), settings); } else if (index >= 0 && index < s.size()) { result.intvalue = s[index]; setTokenValue(tok, std::move(result), settings); @@ -4009,7 +4009,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList &tokenlist, ErrorLog const Token* parentLifetime = getParentLifetime(tokenlist.isCPP(), parent->astOperand1()->astOperand2(), &settings.library); if (parentLifetime && parentLifetime->exprId() > 0) { - valueFlowForward(nextExpression, endOfVarScope, parentLifetime, values, tokenlist, errorLogger, settings); + valueFlowForward(nextExpression, endOfVarScope, parentLifetime, std::move(values), tokenlist, errorLogger, settings); } } } @@ -8472,7 +8472,7 @@ static void valueFlowSmartPointer(TokenList &tokenlist, ErrorLogger * errorLogge if (Token::simpleMatch(ftok, "( )")) { ValueFlow::Value v(0); v.setKnown(); - valueFlowForwardAssign(ftok, tok, vars, {std::move(v)}, false, tokenlist, errorLogger, settings); + valueFlowForwardAssign(ftok, tok, std::move(vars), {std::move(v)}, false, tokenlist, errorLogger, settings); } else { tok->removeValues(std::mem_fn(&ValueFlow::Value::isIntValue)); Token* inTok = ftok->astOperand2(); @@ -8927,7 +8927,7 @@ static void valueFlowContainerSize(TokenList& tokenlist, ValueFlow::Value value(0); value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE; value.setImpossible(); - valueFlowForward(tok->linkAt(2), containerTok, value, tokenlist, errorLogger, settings); + valueFlowForward(tok->linkAt(2), containerTok, std::move(value), tokenlist, errorLogger, settings); } } else if (Token::simpleMatch(tok, "+=") && astIsContainer(tok->astOperand1())) { const Token* containerTok = tok->astOperand1();