From d46ea7ba86e2bc282f31962b5ff687944af7bec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 8 Sep 2022 09:21:35 +0200 Subject: [PATCH] avoid unnecessary copies with `push_back()` and `push_front()` (#4451) --- lib/astutils.cpp | 2 +- lib/checkclass.cpp | 4 ++-- lib/checkunusedfunctions.cpp | 2 +- lib/clangimport.cpp | 4 ++-- lib/cppcheck.cpp | 12 ++++++------ lib/ctu.cpp | 22 +++++++++++----------- lib/errorlogger.cpp | 2 +- lib/importproject.cpp | 16 ++++++++-------- lib/infer.cpp | 12 ++++++------ lib/preprocessor.cpp | 16 ++++++++-------- lib/summaries.cpp | 2 +- lib/suppressions.cpp | 2 +- lib/symboldatabase.cpp | 2 +- lib/symboldatabase.h | 4 ++-- lib/token.cpp | 4 ++-- lib/tokenize.cpp | 6 +++--- lib/tokenlist.cpp | 4 ++-- lib/tokenlist.h | 2 +- lib/valueflow.cpp | 20 ++++++++++---------- 19 files changed, 69 insertions(+), 69 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 982c1d49d..4fdf93a57 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1135,7 +1135,7 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2, ErrorPathItem item = std::make_pair(tok2, "'" + tok1->str() + "' is assigned value '" + tok2->expressionString() + "' here."); if (std::find(errors->begin(), errors->end(), item) != errors->end()) return; - errors->push_back(item); + errors->push_back(std::move(item)); } std::vector followAllReferences(const Token* tok, diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1174bfa19..178d0c0fd 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3089,7 +3089,7 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti } nameLoc.hash = std::hash {}(def); - classDefinitions.push_back(nameLoc); + classDefinitions.push_back(std::move(nameLoc)); } if (classDefinitions.empty()) @@ -3132,7 +3132,7 @@ Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xm nameLoc.lineNumber = std::atoi(line); nameLoc.column = std::atoi(col); nameLoc.hash = MathLib::toULongNumber(hash); - fileInfo->classDefinitions.push_back(nameLoc); + fileInfo->classDefinitions.push_back(std::move(nameLoc)); } } if (fileInfo->classDefinitions.empty()) { diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index aac2de59c..ce201750c 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -346,7 +346,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger, ErrorMessage::FileLocation fileLoc; fileLoc.setfile(filename); fileLoc.line = lineNumber; - locationList.push_back(fileLoc); + locationList.push_back(std::move(fileLoc)); } const ErrorMessage errmsg(locationList, emptyString, Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal); diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 364d2f82a..1462eed72 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -1607,9 +1607,9 @@ void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f) AstNodePtr newNode = std::make_shared(nodeType, ext, &data); tree[level - 1]->children.push_back(newNode); if (level >= tree.size()) - tree.push_back(newNode); + tree.push_back(std::move(newNode)); else - tree[level] = newNode; + tree[level] = std::move(newNode); } if (!tree.empty()) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index bfc7bb310..e6696bd99 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -417,7 +417,7 @@ static bool reportClangErrors(std::istream &is, std::functionpush_back(errmsg); + warnings->push_back(std::move(errmsg)); continue; } @@ -909,13 +909,13 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string std::list locationList; if (e.token) { ErrorMessage::FileLocation loc(e.token, &tokenizer.list); - locationList.push_back(loc); + locationList.push_back(std::move(loc)); } else { ErrorMessage::FileLocation loc2(filename, 0, 0); - locationList.push_back(loc2); + locationList.push_back(std::move(loc2)); if (filename != tokenizer.list.getSourceFilePath()) { ErrorMessage::FileLocation loc(tokenizer.list.getSourceFilePath(), 0, 0); - locationList.push_back(loc); + locationList.push_back(std::move(loc)); } } ErrorMessage errmsg(std::move(locationList), @@ -1463,7 +1463,7 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo if (!file.empty()) { ErrorMessage::FileLocation location; location.setfile(file); - loclist.push_back(location); + loclist.push_back(std::move(location)); } std::ostringstream msg; @@ -1501,7 +1501,7 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st if (!file.empty()) { ErrorMessage::FileLocation location; location.setfile(file); - loclist.push_back(location); + loclist.push_back(std::move(location)); } ErrorMessage errmsg(loclist, diff --git a/lib/ctu.cpp b/lib/ctu.cpp index 5ef5dc41c..d569d51f7 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -237,11 +237,11 @@ void CTU::FileInfo::loadFromXml(const tinyxml2::XMLElement *xmlElement) if (std::strcmp(e->Name(), "function-call") == 0) { FunctionCall functionCall; if (functionCall.loadFromXml(e)) - functionCalls.push_back(functionCall); + functionCalls.push_back(std::move(functionCall)); } else if (std::strcmp(e->Name(), "nested-call") == 0) { NestedCall nestedCall; if (nestedCall.loadFromXml(e)) - nestedCalls.push_back(nestedCall); + nestedCalls.push_back(std::move(nestedCall)); } } } @@ -273,7 +273,7 @@ std::list CTU::loadUnsafeUsageListFromXml(const tiny unsafeUsage.value = readAttrInt(e, ATTR_VALUE, &error); if (!error) - ret.push_back(unsafeUsage); + ret.push_back(std::move(unsafeUsage)); } return ret; } @@ -353,9 +353,9 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer) loc.line = i.first->linenr(); loc.column = i.first->column(); loc.setinfo(i.second); - functionCall.callValuePath.push_back(loc); + functionCall.callValuePath.push_back(std::move(loc)); } - fileInfo->functionCalls.push_back(functionCall); + fileInfo->functionCalls.push_back(std::move(functionCall)); } // array if (argtok->variable() && argtok->variable()->isArray() && argtok->variable()->dimensions().size() == 1) { @@ -368,7 +368,7 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer) functionCall.callArgumentExpression = argtok->expressionString(); functionCall.callArgValue = argtok->variable()->dimension(0) * argtok->valueType()->typeSize(*tokenizer->getSettings()); functionCall.warning = false; - fileInfo->functionCalls.push_back(functionCall); + fileInfo->functionCalls.push_back(std::move(functionCall)); } // &var => buffer if (argtok->isUnaryOp("&") && argtok->astOperand1()->variable() && argtok->astOperand1()->valueType() && !argtok->astOperand1()->variable()->isArray()) { @@ -381,7 +381,7 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer) functionCall.callArgumentExpression = argtok->expressionString(); functionCall.callArgValue = argtok->astOperand1()->valueType()->typeSize(*tokenizer->getSettings()); functionCall.warning = false; - fileInfo->functionCalls.push_back(functionCall); + fileInfo->functionCalls.push_back(std::move(functionCall)); } // pointer/reference to uninitialized data auto isAddressOfArg = [](const Token* argtok) -> const Token* { @@ -414,7 +414,7 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer) functionCall.callArgValue = 0; functionCall.callArgumentExpression = argtok->expressionString(); functionCall.warning = false; - fileInfo->functionCalls.push_back(functionCall); + fileInfo->functionCalls.push_back(std::move(functionCall)); continue; } } @@ -428,7 +428,7 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer) FileInfo::NestedCall nestedCall(tokenizer, scopeFunction, tok); nestedCall.myArgNr = argnr + 1; nestedCall.callArgNr = argnr2; - fileInfo->nestedCalls.push_back(nestedCall); + fileInfo->nestedCalls.push_back(std::move(nestedCall)); } } } @@ -580,12 +580,12 @@ std::list CTU::FileInfo::getErrorPath(InvalidValueTy ErrorMessage::FileLocation fileLoc(path[index]->location.fileName, path[index]->location.lineNumber, path[index]->location.column); fileLoc.setinfo("Calling function " + path[index]->callFunctionName + ", " + MathLib::toString(path[index]->callArgNr) + getOrdinalText(path[index]->callArgNr) + " argument is " + value1); - locationList.push_back(fileLoc); + locationList.push_back(std::move(fileLoc)); } ErrorMessage::FileLocation fileLoc2(unsafeUsage.location.fileName, unsafeUsage.location.lineNumber, unsafeUsage.location.column); fileLoc2.setinfo(replaceStr(info, "ARG", unsafeUsage.myArgumentName)); - locationList.push_back(fileLoc2); + locationList.push_back(std::move(fileLoc2)); return locationList; } diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 16a487448..e6124ed9f 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -334,7 +334,7 @@ bool ErrorMessage::deserialize(const std::string &data) if (substrings.size() == 5) loc.setinfo(substrings[4]); - callStack.push_back(loc); + callStack.push_back(std::move(loc)); if (callStack.size() >= stackSize) break; diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 4922f014b..76ebb0aa6 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -164,7 +164,7 @@ void ImportProject::FileSettings::setIncludePaths(const std::string &basepath, c if (s[0] == '/' || (s.size() > 1U && s.compare(1,2,":/") == 0)) { if (!endsWith(s,'/')) s += '/'; - includePaths.push_back(s); + includePaths.push_back(std::move(s)); continue; } @@ -312,7 +312,7 @@ void ImportProject::FileSettings::parseCommand(std::string command) if (i.size() > 1 && i[0] == '\"' && i.back() == '\"') i = unescape(i.substr(1, i.size() - 2)); if (std::find(includePaths.begin(), includePaths.end(), i) == includePaths.end()) - includePaths.push_back(i); + includePaths.push_back(std::move(i)); } else if (F=='s' && fval.compare(0,2,"td") == 0) { ++pos; const std::string stdval = readUntil(command, &pos, " "); @@ -341,8 +341,8 @@ void ImportProject::FileSettings::parseCommand(std::string command) } } else if (F == 'i' && fval == "system") { ++pos; - const std::string isystem = readUntil(command, &pos, " "); - systemIncludePaths.push_back(isystem); + std::string isystem = readUntil(command, &pos, " "); + systemIncludePaths.push_back(std::move(isystem)); } else if (F=='m') { if (fval == "unicode") { defs += "UNICODE"; @@ -444,7 +444,7 @@ bool ImportProject::importCompileCommands(std::istream &istr) fs.parseCommand(command); // read settings; -D, -I, -U, -std, -m*, -f* std::map variables; fs.setIncludePaths(directory, fs.includePaths, variables); - fileSettings.push_back(fs); + fileSettings.push_back(std::move(fs)); } return true; @@ -804,7 +804,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::mapIntAttribute("lineNumber", Suppressions::Suppression::NO_LINE); s.symbolName = read(child->Attribute("symbolName"), ""); std::istringstream(read(child->Attribute("hash"), "0")) >> s.hash; - suppressions.push_back(s); + suppressions.push_back(std::move(s)); } } else if (strcmp(node->Name(), CppcheckXml::VSConfigurationElementName) == 0) guiProject.checkVsConfigs = readXmlStringList(node, emptyString, CppcheckXml::VSConfigurationName, nullptr); diff --git a/lib/infer.cpp b/lib/infer.cpp index 70a5e4c06..7da29c48e 100644 --- a/lib/infer.cpp +++ b/lib/infer.cpp @@ -321,21 +321,21 @@ std::vector infer(const ValuePtr& model, ValueFlow::Value value(diff.getScalar()); addToErrorPath(value, refs); setValueKind(value, refs); - result.push_back(value); + result.push_back(std::move(value)); } else { if (!diff.minvalue.empty()) { ValueFlow::Value value(diff.minvalue.front() - 1); value.setImpossible(); value.bound = ValueFlow::Value::Bound::Upper; addToErrorPath(value, diff.minRef); - result.push_back(value); + result.push_back(std::move(value)); } if (!diff.maxvalue.empty()) { ValueFlow::Value value(diff.maxvalue.front() + 1); value.setImpossible(); value.bound = ValueFlow::Value::Bound::Lower; addToErrorPath(value, diff.maxRef); - result.push_back(value); + result.push_back(std::move(value)); } } } else if ((op == "!=" || op == "==") && lhs.isScalarOrEmpty() && rhs.isScalarOrEmpty()) { @@ -344,7 +344,7 @@ std::vector infer(const ValuePtr& model, ValueFlow::Value value(calculate(op, lhs.getScalar(), rhs.getScalar())); addToErrorPath(value, refs); setValueKind(value, refs); - result.push_back(value); + result.push_back(std::move(value)); } else { std::vector refs; if (lhs.isScalar() && inferNotEqual(rhsValues, lhs.getScalar())) @@ -355,7 +355,7 @@ std::vector infer(const ValuePtr& model, ValueFlow::Value value(op == "!="); addToErrorPath(value, refs); setValueKind(value, refs); - result.push_back(value); + result.push_back(std::move(value)); } } } else { @@ -365,7 +365,7 @@ std::vector infer(const ValuePtr& model, ValueFlow::Value value(r.front()); addToErrorPath(value, refs); setValueKind(value, refs); - result.push_back(value); + result.push_back(std::move(value)); } } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 6c4d8ec98..d9d47546e 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -123,7 +123,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std: return false; if (!s.errorId.empty()) - inlineSuppressions.push_back(s); + inlineSuppressions.push_back(std::move(s)); if (!errmsg.empty()) bad->emplace_back(tok->location, errmsg); @@ -231,7 +231,7 @@ void Preprocessor::setDirectives(const simplecpp::TokenList &tokens) else directive.str += tok2->str(); } - mDirectives.push_back(directive); + mDirectives.push_back(std::move(directive)); } } } @@ -474,7 +474,7 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set std::string config = readcondition(cmdtok, defined, undefined); if (isUndefined(config,undefined)) config.clear(); - configs_if.push_back(config); + configs_if.push_back(std::move(config)); ret.insert(cfg(configs_if, userDefines)); } else if (!configs_ifndef.empty()) { configs_if.push_back(configs_ifndef.back()); @@ -588,7 +588,7 @@ static void splitcfg(const std::string &cfg, std::list &defines, co std::string def = (defineEndPos == std::string::npos) ? cfg.substr(defineStartPos) : cfg.substr(defineStartPos, defineEndPos - defineStartPos); if (!defaultValue.empty() && def.find('=') == std::string::npos) def += '=' + defaultValue; - defines.push_back(def); + defines.push_back(std::move(def)); if (defineEndPos == std::string::npos) break; defineStartPos = defineEndPos + 1U; @@ -615,7 +615,7 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf } else { s[s.find(')')+1] = '='; } - dui.defines.push_back(s); + dui.defines.push_back(std::move(s)); } dui.undefined = mSettings.userUndefs; // -U @@ -825,8 +825,8 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const if (mSettings.relativePaths) file = Path::getRelativePath(file, mSettings.basePaths); - const ErrorMessage::FileLocation loc(file, linenr, 0); - locationList.push_back(loc); + ErrorMessage::FileLocation loc(file, linenr, 0); + locationList.push_back(std::move(loc)); } mErrorLogger->reportErr(ErrorMessage(locationList, mFile0, @@ -865,7 +865,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line ErrorMessage::FileLocation loc; loc.line = linenr; loc.setfile(Path::toNativeSeparators(filename)); - locationList.push_back(loc); + locationList.push_back(std::move(loc)); } ErrorMessage errmsg(locationList, mFile0, Severity::information, (headerType==SystemHeader) ? diff --git a/lib/summaries.cpp b/lib/summaries.cpp index b793908d8..3f847c94f 100644 --- a/lib/summaries.cpp +++ b/lib/summaries.cpp @@ -110,7 +110,7 @@ static std::vector getSummaryFiles(const std::string &filename) continue; std::string f = line.substr(0,colon); f[dotA + 1] = 's'; - ret.push_back(f); + ret.push_back(std::move(f)); } return ret; } diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 69d110346..e721807f3 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -166,7 +166,7 @@ std::vector Suppressions::parseMultiSuppressComment(c } } - suppressions.push_back(s); + suppressions.push_back(std::move(s)); } return suppressions; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 46056bc8d..2ff258f8c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3319,7 +3319,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1) base.type = baseType; // save pattern for base class name - derivedFrom.push_back(base); + derivedFrom.push_back(std::move(base)); } else tok2 = tok2->next(); } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 39df19aa6..63a76b325 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1164,8 +1164,8 @@ public: const Function *getDestructor() const; - void addFunction(const Function & func) { - functionList.push_back(func); + void addFunction(Function func) { + functionList.push_back(std::move(func)); const Function * back = &functionList.back(); diff --git a/lib/token.cpp b/lib/token.cpp index 63875adb5..c0362a35e 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2146,9 +2146,9 @@ bool Token::addValue(const ValueFlow::Value &value) if (v.varId == 0) v.varId = mImpl->mVarId; if (v.isKnown() && v.isIntValue()) - mImpl->mValues->push_front(v); + mImpl->mValues->push_front(std::move(v)); else - mImpl->mValues->push_back(v); + mImpl->mValues->push_back(std::move(v)); } } else { ValueFlow::Value v(value); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5ef3f9496..8e37695ea 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -656,7 +656,7 @@ void Tokenizer::simplifyTypedef() info.className = className; info.bodyEnd = tok->link(); info.bodyEnd2 = tok->link(); - spaceInfo.push_back(info); + spaceInfo.push_back(std::move(info)); hasClass = false; } else if (spaceInfo.size() > 1 && tok->str() == "}" && spaceInfo.back().bodyEnd == tok) { @@ -1070,7 +1070,7 @@ void Tokenizer::simplifyTypedef() typedefInfo.lineNumber = typeName->linenr(); typedefInfo.column = typeName->column(); typedefInfo.used = false; - mTypedefInfo.push_back(typedefInfo); + mTypedefInfo.push_back(std::move(typedefInfo)); while (!done) { std::string pattern = typeName->str(); @@ -9389,7 +9389,7 @@ void Tokenizer::removeUnnecessaryQualification() if (!tok) return; info.bodyEnd = tok->link(); - classInfo.push_back(info); + classInfo.push_back(std::move(info)); } else if (!classInfo.empty()) { if (tok == classInfo.back().bodyEnd) classInfo.pop_back(); diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index c258cbec2..1d90e230c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -178,7 +178,7 @@ void TokenList::determineCppC() } } -int TokenList::appendFileIfNew(const std::string &fileName) +int TokenList::appendFileIfNew(std::string fileName) { // Has this file been tokenized already? for (int i = 0; i < mFiles.size(); ++i) @@ -186,7 +186,7 @@ int TokenList::appendFileIfNew(const std::string &fileName) return i; // The "mFiles" vector remembers what files have been tokenized.. - mFiles.push_back(fileName); + mFiles.push_back(std::move(fileName)); // Update mIsC and mIsCpp properties if (mFiles.size() == 1) { // Update only useful if first file added to _files diff --git a/lib/tokenlist.h b/lib/tokenlist.h index c51e65a8f..16164ae78 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -110,7 +110,7 @@ public: void deallocateTokens(); /** append file name if seen the first time; return its index in any case */ - int appendFileIfNew(const std::string &fileName); + int appendFileIfNew(std::string fileName); /** get first token of list */ const Token *front() const { diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 078b65706..4a1739384 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5646,7 +5646,7 @@ static void insertNegateKnown(std::list& values, const std::li continue; value.intvalue = !value.intvalue; value.setKnown(); - values.push_back(value); + values.push_back(std::move(value)); } } @@ -6258,10 +6258,10 @@ struct SimpleConditionHandler : ConditionHandler { if (vartok->str() == "=" && vartok->astOperand1() && vartok->astOperand2()) vartok = vartok->astOperand1(); Condition cond; - cond.true_values.push_back(true_value); - cond.false_values.push_back(false_value); + cond.true_values.push_back(std::move(true_value)); + cond.false_values.push_back(std::move(false_value)); cond.vartok = vartok; - conds.push_back(cond); + conds.push_back(std::move(cond)); }); if (!conds.empty()) return conds; @@ -6475,7 +6475,7 @@ struct SymbolicConditionHandler : SimpleConditionHandler { cond.false_values = {false_value}; cond.vartok = vartok; cond.inverted = inverted; - result.push_back(cond); + result.push_back(std::move(cond)); } }; addCond(tok->astOperand1(), tok->astOperand2(), false); @@ -6920,7 +6920,7 @@ bool productParams(const std::unordered_map>& v } } arg[p.first] = value; - new_args.push_back(arg); + new_args.push_back(std::move(arg)); } std::copy(new_args.begin(), new_args.end(), std::back_inserter(args)); }); @@ -7224,7 +7224,7 @@ static void valueFlowFunctionDefaultParameter(TokenList* tokenlist, SymbolDataba v.defaultArg = true; v.changeKnownToPossible(); if (v.isPossible()) - argvalues.push_back(v); + argvalues.push_back(std::move(v)); } if (!argvalues.empty()) valueFlowInjectParameter(tokenlist, var, scope, argvalues); @@ -8158,10 +8158,10 @@ struct ContainerConditionHandler : ConditionHandler { true_value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE; false_value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE; Condition cond; - cond.true_values.push_back(true_value); - cond.false_values.push_back(false_value); + cond.true_values.push_back(std::move(true_value)); + cond.false_values.push_back(std::move(false_value)); cond.vartok = vartok; - conds.push_back(cond); + conds.push_back(std::move(cond)); }); if (!conds.empty()) return conds;