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
5 changes: 1 addition & 4 deletions lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,
{
std::list<ErrorMessage::FileLocation> locationList;
if (!filename.empty()) {
ErrorMessage::FileLocation fileLoc;
fileLoc.setfile(filename);
fileLoc.line = lineNumber;
locationList.push_back(std::move(fileLoc));
locationList.emplace_back(filename, lineNumber);
}

const ErrorMessage errmsg(locationList, emptyString, Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal);
Expand Down
8 changes: 2 additions & 6 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,7 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo

std::list<ErrorMessage::FileLocation> loclist;
if (!file.empty()) {
ErrorMessage::FileLocation location;
location.setfile(file);
loclist.push_back(std::move(location));
loclist.emplace_back(file);
}

std::ostringstream msg;
Expand Down Expand Up @@ -1514,9 +1512,7 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st

std::list<ErrorMessage::FileLocation> loclist;
if (!file.empty()) {
ErrorMessage::FileLocation location;
location.setfile(file);
loclist.push_back(std::move(location));
loclist.emplace_back(file);
}

ErrorMessage errmsg(loclist,
Expand Down
2 changes: 1 addition & 1 deletion lib/errorlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CPPCHECKLIB ErrorMessage {
FileLocation()
: fileIndex(0), line(0), column(0) {}

FileLocation(const std::string &file, int line, unsigned int column)
explicit FileLocation(const std::string &file, int line = 0, unsigned int column = 0)
: fileIndex(0), line(line), column(column), mOrigFileName(file), mFileName(file) {}

FileLocation(const std::string &file, std::string info, int line, unsigned int column)
Expand Down
2 changes: 1 addition & 1 deletion lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct ForwardTraversal {
std::vector<ForwardTraversal> tryForkScope(Token* endBlock, bool isModified = false) {
if (analyzer->updateScope(endBlock, isModified)) {
ForwardTraversal ft = fork();
return {ft};
return {std::move(ft)};
}
return std::vector<ForwardTraversal> {};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,9 +1645,9 @@ const Library::Container * getLibraryContainer(const Token * tok)
return tok->valueType()->container;
}

Library::TypeCheck Library::getTypeCheck(const std::string &check, const std::string &typeName) const
Library::TypeCheck Library::getTypeCheck(std::string check, std::string typeName) const
{
auto it = mTypeChecks.find(std::pair<std::string, std::string>(check, typeName));
auto it = mTypeChecks.find(std::pair<std::string, std::string>(std::move(check), std::move(typeName)));
return it == mTypeChecks.end() ? TypeCheck::def : it->second;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class CPPCHECKLIB Library {

/** Suppress/check a type */
enum class TypeCheck { def, check, suppress };
TypeCheck getTypeCheck(const std::string &check, const std::string &typeName) const;
TypeCheck getTypeCheck(std::string check, std::string typeName) const;

private:
// load a <function> xml node
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, co
Function* SymbolDatabase::addGlobalFunctionDecl(Scope*& scope, const Token *tok, const Token *argStart, const Token* funcStart)
{
Function function(mTokenizer, tok, scope, funcStart, argStart);
scope->addFunction(function);
scope->addFunction(std::move(function));
return &scope->functionList.back();
}

Expand Down
16 changes: 9 additions & 7 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6389,7 +6389,7 @@ struct SimpleConditionHandler : ConditionHandler {
cond.false_values.emplace_back(tok, 0LL);
cond.vartok = vartok;

return {cond};
return {std::move(cond)};
}
};

Expand Down Expand Up @@ -6574,8 +6574,8 @@ struct SymbolicConditionHandler : SimpleConditionHandler {
setSymbolic(false_value, valuetok);

Condition cond;
cond.true_values = {true_value};
cond.false_values = {false_value};
cond.true_values = {std::move(true_value)};
cond.false_values = {std::move(false_value)};
cond.vartok = vartok;
cond.inverted = inverted;
result.push_back(std::move(cond));
Expand Down Expand Up @@ -7977,7 +7977,7 @@ struct IteratorConditionHandler : SimpleConditionHandler {
cond.false_values = values;
}

return {cond};
return {std::move(cond)};
}
};

Expand Down Expand Up @@ -8308,7 +8308,7 @@ struct ContainerConditionHandler : ConditionHandler {
cond.false_values.emplace_back(std::move(value));
cond.vartok = vartok;
cond.inverted = true;
return {cond};
return {std::move(cond)};
}
// String compare
if (Token::Match(tok, "==|!=")) {
Expand All @@ -8331,7 +8331,7 @@ struct ContainerConditionHandler : ConditionHandler {
cond.true_values.emplace_back(std::move(value));
cond.vartok = vartok;
cond.impossible = false;
return {cond};
return {std::move(cond)};
}
return {};
}
Expand Down Expand Up @@ -8965,6 +8965,7 @@ const ValueFlow::Value* ValueFlow::findValue(const std::list<ValueFlow::Value>&
return ret;
}

// TODO: returns a single value at most - no need for std::vector
static std::vector<ValueFlow::Value> isOutOfBoundsImpl(const ValueFlow::Value& size,
const Token* indexTok,
bool condition)
Expand Down Expand Up @@ -8996,9 +8997,10 @@ static std::vector<ValueFlow::Value> isOutOfBoundsImpl(const ValueFlow::Value& s
return {};
value.intvalue = size.intvalue;
value.bound = ValueFlow::Value::Bound::Lower;
return {value};
return {std::move(value)};
}

// TODO: return single value at most - no need for std::vector
std::vector<ValueFlow::Value> ValueFlow::isOutOfBounds(const Value& size, const Token* indexTok, bool possible)
{
ValueFlow::Value inBoundsValue = inferCondition("<", indexTok, size.intvalue);
Expand Down