Skip to content

Commit d449ee6

Browse files
authored
fixed more COPY_INSTEAD_OF_MOVE Coverity warnings (#5949)
1 parent ed2032d commit d449ee6

11 files changed

Lines changed: 26 additions & 24 deletions

lib/checkclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3605,7 +3605,7 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<C
36053605
locationList.emplace_back(nameLoc.fileName, nameLoc.lineNumber, nameLoc.column);
36063606
locationList.emplace_back(it->second.fileName, it->second.lineNumber, it->second.column);
36073607

3608-
const ErrorMessage errmsg(locationList,
3608+
const ErrorMessage errmsg(std::move(locationList),
36093609
emptyString,
36103610
Severity::error,
36113611
"$symbol:" + nameLoc.className +

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ void CheckOther::checkDuplicateExpression()
25102510
continue;
25112511
}
25122512
}
2513-
duplicateExpressionError(tok->astOperand1(), tok->astOperand2(), tok, errorPath);
2513+
duplicateExpressionError(tok->astOperand1(), tok->astOperand2(), tok, std::move(errorPath));
25142514
}
25152515
}
25162516
}

lib/checkstl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void CheckStl::outOfBoundsError(const Token *tok, const std::string &containerNa
262262
if (errorPath1.size() <= 1)
263263
errorPath = std::move(errorPath2);
264264
else if (errorPath2.size() <= 1)
265-
errorPath = errorPath1;
265+
errorPath = std::move(errorPath1);
266266
else {
267267
errorPath = std::move(errorPath1);
268268
errorPath.splice(errorPath.end(), errorPath2);
@@ -1155,7 +1155,7 @@ void CheckStl::invalidContainer()
11551155
if (var->isArgument() ||
11561156
(!var->isReference() && !var->isRValueReference() && !isVariableDecl(tok) &&
11571157
reaches(var->nameToken(), tok, library, &ep))) {
1158-
errorPath = ep;
1158+
errorPath = std::move(ep);
11591159
return true;
11601160
}
11611161
}
@@ -1175,7 +1175,7 @@ void CheckStl::invalidContainer()
11751175
errorPath.insert(errorPath.end(), info.errorPath.cbegin(), info.errorPath.cend());
11761176
errorPath.insert(errorPath.end(), r.errorPath.cbegin(), r.errorPath.cend());
11771177
if (v) {
1178-
invalidContainerError(info.tok, r.tok, v, errorPath);
1178+
invalidContainerError(info.tok, r.tok, v, std::move(errorPath));
11791179
} else {
11801180
invalidContainerReferenceError(info.tok, r.tok, std::move(errorPath));
11811181
}

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
957957
const ErrorMessage::FileLocation loc1(file, o.location.line, o.location.col);
958958
std::list<ErrorMessage::FileLocation> callstack(1, loc1);
959959

960-
ErrorMessage errmsg(callstack,
960+
ErrorMessage errmsg(std::move(callstack),
961961
filename,
962962
Severity::error,
963963
o.msg,

lib/importproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool ImportProject::importCompileCommands(std::istream &istr)
358358
if (!endsWith(dirpath, '/'))
359359
dirpath += '/';
360360

361-
const std::string directory = dirpath;
361+
const std::string directory = std::move(dirpath);
362362

363363
std::string command;
364364
if (obj.count("arguments")) {

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
721721
if (const char *unknownReturnValues = functionnode->Attribute("unknownValues")) {
722722
if (std::strcmp(unknownReturnValues, "all") == 0) {
723723
std::vector<MathLib::bigint> values{LLONG_MIN, LLONG_MAX};
724-
mUnknownReturnValues[name] = values;
724+
mUnknownReturnValues[name] = std::move(values);
725725
}
726726
}
727727
} else if (functionnodename == "arg") {

lib/pathanalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ PathAnalysis::Progress PathAnalysis::forwardRange(const Token* startToken, const
150150
if (Token::simpleMatch(endBlock, "} else {")) {
151151
if (checkElse) {
152152
i.errorPath.back().second = "Assuming condition is false.";
153-
const Progress result = forwardRange(endCond->next(), endBlock, i, f);
153+
const Progress result = forwardRange(endCond->next(), endBlock, std::move(i), f);
154154
if (result == Progress::Break)
155155
return Progress::Break;
156156
}
@@ -179,7 +179,7 @@ void PathAnalysis::forward(const std::function<Progress(const Info&)>& f) const
179179
return;
180180
const Token * endToken = endScope->bodyEnd;
181181
Info info{start, ErrorPath{}, true};
182-
forwardRange(start, endToken, info, f);
182+
forwardRange(start, endToken, std::move(info), f);
183183
}
184184

185185
bool reaches(const Token * start, const Token * dest, const Library& library, ErrorPath* errorPath)

lib/preprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ simplecpp::TokenList Preprocessor::preprocess(const simplecpp::TokenList &tokens
832832
simplecpp::TokenList tokens2(files);
833833
simplecpp::preprocess(tokens2, tokens1, files, mTokenLists, dui, &outputList, &macroUsage, &ifCond);
834834
mMacroUsage = std::move(macroUsage);
835-
mIfCond = ifCond;
835+
mIfCond = std::move(ifCond);
836836

837837
handleErrors(outputList, throwError);
838838

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void ProgramMemoryState::assume(const Token* tok, bool b, bool isEmpty)
490490
origin = origin->link();
491491
}
492492
}
493-
replace(pm, origin);
493+
replace(std::move(pm), origin);
494494
}
495495

496496
void ProgramMemoryState::removeModifiedVars(const Token* tok)

lib/symboldatabase.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8033,7 +8033,9 @@ std::string ValueType::str() const
80338033
ret += " &";
80348034
else if (reference == Reference::RValue)
80358035
ret += " &&";
8036-
return ret.empty() ? ret : ret.substr(1);
8036+
if (ret.empty())
8037+
return ret;
8038+
return ret.substr(1);
80378039
}
80388040

80398041
void ValueType::setDebugPath(const Token* tok, SourceLocation ctx, SourceLocation local)

0 commit comments

Comments
 (0)