Skip to content

Commit

Permalink
fixed even more COPY_INSTEAD_OF_MOVE Coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Feb 12, 2024
1 parent 40552e2 commit 313f2c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -8462,7 +8462,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();
Expand Down Expand Up @@ -8917,7 +8917,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();
Expand Down

0 comments on commit 313f2c1

Please sign in to comment.