Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReferenceToken> followAllReferences(const Token* tok,
Expand Down
4 changes: 2 additions & 2 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3089,7 +3089,7 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
}
nameLoc.hash = std::hash<std::string> {}(def);

classDefinitions.push_back(nameLoc);
classDefinitions.push_back(std::move(nameLoc));
}

if (classDefinitions.empty())
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,9 +1607,9 @@ void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f)
AstNodePtr newNode = std::make_shared<AstNode>(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())
Expand Down
12 changes: 6 additions & 6 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static bool reportClangErrors(std::istream &is, std::function<void(const ErrorMe
Certainty::normal);

if (line.compare(pos3, 10, ": warning:") == 0) {
warnings->push_back(errmsg);
warnings->push_back(std::move(errmsg));
continue;
}

Expand Down Expand Up @@ -909,13 +909,13 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
std::list<ErrorMessage::FileLocation> 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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions lib/ctu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ std::list<CTU::FileInfo::UnsafeUsage> 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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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()) {
Expand All @@ -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* {
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -580,12 +580,12 @@ std::list<ErrorMessage::FileLocation> 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;
}
2 changes: 1 addition & 1 deletion lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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, " ");
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -444,7 +444,7 @@ bool ImportProject::importCompileCommands(std::istream &istr)
fs.parseCommand(command); // read settings; -D, -I, -U, -std, -m*, -f*
std::map<std::string, std::string, cppcheck::stricmp> variables;
fs.setIncludePaths(directory, fs.includePaths, variables);
fileSettings.push_back(fs);
fileSettings.push_back(std::move(fs));
}

return true;
Expand Down Expand Up @@ -804,7 +804,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map<std::str
}
fs.setDefines(fs.defines);
fs.setIncludePaths(Path::getPathFromFilename(filename), toStringList(includePath + ';' + additionalIncludePaths), variables);
fileSettings.push_back(fs);
fileSettings.push_back(std::move(fs));
}
}

Expand Down Expand Up @@ -1071,7 +1071,7 @@ bool ImportProject::importBcb6Prj(const std::string &projectFilename)
fs.setIncludePaths(projectDir, toStringList(includePath), variables);
fs.setDefines(cppMode ? cppDefines : defines);
fs.filename = Path::simplifyPath(Path::isAbsolute(c) ? c : projectDir + c);
fileSettings.push_back(fs);
fileSettings.push_back(std::move(fs));
}

return true;
Expand Down Expand Up @@ -1180,7 +1180,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
s.lineNumber = child->IntAttribute("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);
Expand Down
12 changes: 6 additions & 6 deletions lib/infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,21 @@ std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& 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()) {
Expand All @@ -344,7 +344,7 @@ std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& 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<const ValueFlow::Value*> refs;
if (lhs.isScalar() && inferNotEqual(rhsValues, lhs.getScalar()))
Expand All @@ -355,7 +355,7 @@ std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& model,
ValueFlow::Value value(op == "!=");
addToErrorPath(value, refs);
setValueKind(value, refs);
result.push_back(value);
result.push_back(std::move(value));
}
}
} else {
Expand All @@ -365,7 +365,7 @@ std::vector<ValueFlow::Value> infer(const ValuePtr<InferModel>& model,
ValueFlow::Value value(r.front());
addToErrorPath(value, refs);
setValueKind(value, refs);
result.push_back(value);
result.push_back(std::move(value));
}
}

Expand Down
16 changes: 8 additions & 8 deletions lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
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());
Expand Down Expand Up @@ -588,7 +588,7 @@ static void splitcfg(const std::string &cfg, std::list<std::string> &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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) ?
Expand Down
2 changes: 1 addition & 1 deletion lib/summaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static std::vector<std::string> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(c
}
}

suppressions.push_back(s);
suppressions.push_back(std::move(s));
}

return suppressions;
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading