enabled and fixed `modernize-pass-by-value` clang-tidy warnings (#4169)

This commit is contained in:
Oliver Stöneberg 2022-07-28 22:51:45 +02:00 committed by GitHub
parent 304e448749
commit b65b47d3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 137 additions and 118 deletions

View File

@ -1,5 +1,5 @@
--- ---
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness' Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness'
WarningsAsErrors: '*' WarningsAsErrors: '*'
CheckOptions: CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic

View File

@ -18,9 +18,9 @@
#include "application.h" #include "application.h"
Application::Application(const QString &name, const QString &path, Application::Application(QString name, QString path,
const QString &params) QString params)
: mName(name) : mName(std::move(name))
, mPath(path) , mPath(std::move(path))
, mParameters(params) , mParameters(std::move(params))
{} {}

View File

@ -43,7 +43,7 @@
class Application { class Application {
public: public:
Application() {} Application() {}
Application(const QString &name, const QString &path, const QString &params); Application(QString name, QString path, QString params);
/** /**
* @brief Get application name. * @brief Get application name.

View File

@ -19,33 +19,42 @@
#include "codeeditorstyle.h" #include "codeeditorstyle.h"
#include <QSettings> #include <QSettings>
#include <utility>
CodeEditorStyle::CodeEditorStyle( CodeEditorStyle::CodeEditorStyle(
const QColor& CtrlFGColor, const QColor& CtrlBGColor, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& HiLiBGColor, QColor CtrlFGColor, QColor CtrlBGColor,
const QColor& LnNumFGColor, const QColor& LnNumBGColor, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& KeyWdFGColor, const QFont::Weight& KeyWdWeight, QColor HiLiBGColor,
const QColor& ClsFGColor, const QFont::Weight& ClsWeight, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& QteFGColor, const QFont::Weight& QteWeight, QColor LnNumFGColor, QColor LnNumBGColor,
const QColor& CmtFGColor, const QFont::Weight& CmtWeight, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& SymbFGColor, const QColor& SymbBGColor, QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor ClsFGColor, const QFont::Weight& ClsWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor QteFGColor, const QFont::Weight& QteWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor CmtFGColor, const QFont::Weight& CmtWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight) : const QFont::Weight& SymbWeight) :
mSystemTheme(false), mSystemTheme(false),
widgetFGColor(CtrlFGColor), widgetFGColor(std::move(CtrlFGColor)),
widgetBGColor(CtrlBGColor), widgetBGColor(std::move(CtrlBGColor)),
highlightBGColor(HiLiBGColor), highlightBGColor(std::move(HiLiBGColor)),
lineNumFGColor(LnNumFGColor), lineNumFGColor(std::move(LnNumFGColor)),
lineNumBGColor(LnNumBGColor), lineNumBGColor(std::move(LnNumBGColor)),
keywordColor(KeyWdFGColor), keywordColor(std::move(KeyWdFGColor)),
keywordWeight(KeyWdWeight), keywordWeight(KeyWdWeight),
classColor(ClsFGColor), classColor(std::move(ClsFGColor)),
classWeight(ClsWeight), classWeight(ClsWeight),
quoteColor(QteFGColor), quoteColor(std::move(QteFGColor)),
quoteWeight(QteWeight), quoteWeight(QteWeight),
commentColor(CmtFGColor), commentColor(std::move(CmtFGColor)),
commentWeight(CmtWeight), commentWeight(CmtWeight),
symbolFGColor(SymbFGColor), symbolFGColor(std::move(SymbFGColor)),
symbolBGColor(SymbBGColor), symbolBGColor(std::move(SymbBGColor)),
symbolWeight(SymbWeight) symbolWeight(SymbWeight)
{} {}

View File

@ -50,14 +50,22 @@ class QSettings;
class CodeEditorStyle { class CodeEditorStyle {
public: public:
explicit CodeEditorStyle( explicit CodeEditorStyle(
const QColor& CtrlFGColor, const QColor& CtrlBGColor, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& HiLiBGColor, QColor CtrlFGColor, QColor CtrlBGColor,
const QColor& LnNumFGColor, const QColor& LnNumBGColor, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& KeyWdFGColor, const QFont::Weight& KeyWdWeight, QColor HiLiBGColor,
const QColor& ClsFGColor, const QFont::Weight& ClsWeight, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& QteFGColor, const QFont::Weight& QteWeight, QColor LnNumFGColor, QColor LnNumBGColor,
const QColor& CmtFGColor, const QFont::Weight& CmtWeight, // cppcheck-suppress naming-varname - TODO: fix this
const QColor& SymbFGColor, const QColor& SymbBGColor, QColor KeyWdFGColor, const QFont::Weight& KeyWdWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor ClsFGColor, const QFont::Weight& ClsWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor QteFGColor, const QFont::Weight& QteWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor CmtFGColor, const QFont::Weight& CmtWeight,
// cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight); const QFont::Weight& SymbWeight);
~CodeEditorStyle() {} ~CodeEditorStyle() {}

View File

@ -38,9 +38,9 @@ ProjectFile::ProjectFile(QObject *parent) :
clear(); clear();
} }
ProjectFile::ProjectFile(const QString &filename, QObject *parent) : ProjectFile::ProjectFile(QString filename, QObject *parent) :
QObject(parent), QObject(parent),
mFilename(filename) mFilename(std::move(filename))
{ {
clear(); clear();
read(); read();

View File

@ -46,7 +46,7 @@ class ProjectFile : public QObject {
public: public:
explicit ProjectFile(QObject *parent = nullptr); explicit ProjectFile(QObject *parent = nullptr);
explicit ProjectFile(const QString &filename, QObject *parent = nullptr); explicit ProjectFile(QString filename, QObject *parent = nullptr);
~ProjectFile() override { ~ProjectFile() override {
if (this == mActiveProject) mActiveProject = nullptr; if (this == mActiveProject) mActiveProject = nullptr;
} }

View File

@ -18,9 +18,9 @@
#include "report.h" #include "report.h"
Report::Report(const QString &filename) : Report::Report(QString filename) :
QObject(), QObject(),
mFilename(filename) mFilename(std::move(filename))
{} {}
Report::~Report() Report::~Report()

View File

@ -39,7 +39,7 @@ public:
CSV, CSV,
}; };
explicit Report(const QString &filename); explicit Report(QString filename);
~Report() override; ~Report() override;
/** /**

View File

@ -393,7 +393,7 @@ std::string CheckUnusedFunctions::analyzerInfo() const
namespace { namespace {
struct Location { struct Location {
Location() : lineNumber(0) {} Location() : lineNumber(0) {}
Location(const std::string &f, const int l) : fileName(f), lineNumber(l) {} Location(std::string f, const int l) : fileName(std::move(f)), lineNumber(l) {}
std::string fileName; std::string fileName;
int lineNumber; int lineNumber;
}; };

View File

@ -317,8 +317,8 @@ namespace clangimport {
class AstNode { class AstNode {
public: public:
AstNode(const std::string &nodeType, const std::string &ext, Data *data) AstNode(std::string nodeType, const std::string &ext, Data *data)
: nodeType(nodeType), mExtTokens(splitString(ext)), mData(data) : nodeType(std::move(nodeType)), mExtTokens(splitString(ext)), mData(data)
{} {}
std::string nodeType; std::string nodeType;
std::vector<AstNodePtr> children; std::vector<AstNodePtr> children;

View File

@ -351,7 +351,7 @@ CppCheck::CppCheck(ErrorLogger &errorLogger,
, mUseGlobalSuppressions(useGlobalSuppressions) , mUseGlobalSuppressions(useGlobalSuppressions)
, mTooManyConfigs(false) , mTooManyConfigs(false)
, mSimplify(true) , mSimplify(true)
, mExecuteCommand(executeCommand) , mExecuteCommand(std::move(executeCommand))
{} {}
CppCheck::~CppCheck() CppCheck::~CppCheck()

View File

@ -34,41 +34,18 @@
#include <iomanip> #include <iomanip>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include <tinyxml2.h> #include <tinyxml2.h>
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
token(tok), errorMessage(errorMsg), type(type)
{
switch (type) {
case AST:
id = "internalAstError";
break;
case SYNTAX:
id = "syntaxError";
break;
case UNKNOWN_MACRO:
id = "unknownMacro";
break;
case INTERNAL:
id = "cppcheckError";
break;
case LIMIT:
id = "cppcheckLimit";
break;
case INSTANTIATION:
id = "instantiationError";
break;
}
}
ErrorMessage::ErrorMessage() ErrorMessage::ErrorMessage()
: incomplete(false), severity(Severity::none), cwe(0U), certainty(Certainty::normal), hash(0) : incomplete(false), severity(Severity::none), cwe(0U), certainty(Certainty::normal), hash(0)
{} {}
ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, const std::string& file1, Severity::SeverityType severity, const std::string &msg, const std::string &id, Certainty::CertaintyLevel certainty) : ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, Certainty::CertaintyLevel certainty) :
callStack(callStack), // locations for this error message callStack(std::move(callStack)), // locations for this error message
id(id), // set the message id id(std::move(id)), // set the message id
file0(file1), file0(std::move(file1)),
incomplete(false), incomplete(false),
severity(severity), // severity for this error message severity(severity), // severity for this error message
cwe(0U), cwe(0U),
@ -81,10 +58,10 @@ ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, const std::
ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, const std::string& file1, Severity::SeverityType severity, const std::string &msg, const std::string &id, const CWE &cwe, Certainty::CertaintyLevel certainty) : ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, const CWE &cwe, Certainty::CertaintyLevel certainty) :
callStack(callStack), // locations for this error message callStack(std::move(callStack)), // locations for this error message
id(id), // set the message id id(std::move(id)), // set the message id
file0(file1), file0(std::move(file1)),
incomplete(false), incomplete(false),
severity(severity), // severity for this error message severity(severity), // severity for this error message
cwe(cwe.id), cwe(cwe.id),
@ -95,8 +72,8 @@ ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack, const std::
setmsg(msg); setmsg(msg);
} }
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, const std::string& id, const std::string& msg, Certainty::CertaintyLevel certainty) ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, std::string id, const std::string& msg, Certainty::CertaintyLevel certainty)
: id(id), incomplete(false), severity(severity), cwe(0U), certainty(certainty), hash(0) : id(std::move(id)), incomplete(false), severity(severity), cwe(0U), certainty(certainty), hash(0)
{ {
// Format callstack // Format callstack
for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it) { for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it) {
@ -114,8 +91,8 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
} }
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, const std::string& id, const std::string& msg, const CWE &cwe, Certainty::CertaintyLevel certainty) ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, std::string id, const std::string& msg, const CWE &cwe, Certainty::CertaintyLevel certainty)
: id(id), incomplete(false), severity(severity), cwe(cwe.id), certainty(certainty) : id(std::move(id)), incomplete(false), severity(severity), cwe(cwe.id), certainty(certainty)
{ {
// Format callstack // Format callstack
for (const Token *tok: callstack) { for (const Token *tok: callstack) {
@ -651,8 +628,8 @@ ErrorMessage::FileLocation::FileLocation(const Token* tok, const TokenList* toke
: fileIndex(tok->fileIndex()), line(tok->linenr()), column(tok->column()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok)) : fileIndex(tok->fileIndex()), line(tok->linenr()), column(tok->column()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok))
{} {}
ErrorMessage::FileLocation::FileLocation(const Token* tok, const std::string &info, const TokenList* tokenList) ErrorMessage::FileLocation::FileLocation(const Token* tok, std::string info, const TokenList* tokenList)
: fileIndex(tok->fileIndex()), line(tok->linenr()), column(tok->column()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok)), mInfo(info) : fileIndex(tok->fileIndex()), line(tok->linenr()), column(tok->column()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok)), mInfo(std::move(info))
{} {}
std::string ErrorMessage::FileLocation::getfile(bool convert) const std::string ErrorMessage::FileLocation::getfile(bool convert) const

View File

@ -76,7 +76,7 @@ public:
: fileIndex(0), line(line), column(column), mOrigFileName(file), mFileName(file), mInfo(info) {} : fileIndex(0), line(line), column(column), mOrigFileName(file), mFileName(file), mInfo(info) {}
FileLocation(const Token* tok, const TokenList* tokenList); FileLocation(const Token* tok, const TokenList* tokenList);
FileLocation(const Token* tok, const std::string &info, const TokenList* tokenList); FileLocation(const Token* tok, std::string info, const TokenList* tokenList);
/** /**
* Return the filename. * Return the filename.
@ -120,28 +120,28 @@ public:
std::string mInfo; std::string mInfo;
}; };
ErrorMessage(const std::list<FileLocation> &callStack, ErrorMessage(std::list<FileLocation> callStack,
const std::string& file1, std::string file1,
Severity::SeverityType severity, Severity::SeverityType severity,
const std::string &msg, const std::string &msg,
const std::string &id, Certainty::CertaintyLevel certainty); std::string id, Certainty::CertaintyLevel certainty);
ErrorMessage(const std::list<FileLocation> &callStack, ErrorMessage(std::list<FileLocation> callStack,
const std::string& file1, std::string file1,
Severity::SeverityType severity, Severity::SeverityType severity,
const std::string &msg, const std::string &msg,
const std::string &id, std::string id,
const CWE &cwe, const CWE &cwe,
Certainty::CertaintyLevel certainty); Certainty::CertaintyLevel certainty);
ErrorMessage(const std::list<const Token*>& callstack, ErrorMessage(const std::list<const Token*>& callstack,
const TokenList* list, const TokenList* list,
Severity::SeverityType severity, Severity::SeverityType severity,
const std::string& id, std::string id,
const std::string& msg, const std::string& msg,
Certainty::CertaintyLevel certainty); Certainty::CertaintyLevel certainty);
ErrorMessage(const std::list<const Token*>& callstack, ErrorMessage(const std::list<const Token*>& callstack,
const TokenList* list, const TokenList* list,
Severity::SeverityType severity, Severity::SeverityType severity,
const std::string& id, std::string id,
const std::string& msg, const std::string& msg,
const CWE &cwe, const CWE &cwe,
Certainty::CertaintyLevel certainty); Certainty::CertaintyLevel certainty);

View File

@ -18,6 +18,31 @@
#include "errortypes.h" #include "errortypes.h"
InternalError::InternalError(const Token *tok, std::string errorMsg, Type type) :
token(tok), errorMessage(std::move(errorMsg)), type(type)
{
switch (type) {
case AST:
id = "internalAstError";
break;
case SYNTAX:
id = "syntaxError";
break;
case UNKNOWN_MACRO:
id = "unknownMacro";
break;
case INTERNAL:
id = "cppcheckError";
break;
case LIMIT:
id = "cppcheckLimit";
break;
case INSTANTIATION:
id = "instantiationError";
break;
}
}
std::string Severity::toString(Severity::SeverityType severity) std::string Severity::toString(Severity::SeverityType severity)
{ {
switch (severity) { switch (severity) {

View File

@ -34,7 +34,7 @@ class Token;
/** @brief Simple container to be thrown when internal error is detected. */ /** @brief Simple container to be thrown when internal error is detected. */
struct InternalError { struct InternalError {
enum Type {AST, SYNTAX, UNKNOWN_MACRO, INTERNAL, LIMIT, INSTANTIATION}; enum Type {AST, SYNTAX, UNKNOWN_MACRO, INTERNAL, LIMIT, INSTANTIATION};
InternalError(const Token *tok, const std::string &errorMsg, Type type = INTERNAL); InternalError(const Token *tok, std::string errorMsg, Type type = INTERNAL);
const Token *token; const Token *token;
std::string errorMessage; std::string errorMessage;
Type type; Type type;

View File

@ -528,7 +528,7 @@ namespace {
}; };
struct ItemDefinitionGroup { struct ItemDefinitionGroup {
explicit ItemDefinitionGroup(const tinyxml2::XMLElement *idg, const std::string &includePaths) : additionalIncludePaths(includePaths) { explicit ItemDefinitionGroup(const tinyxml2::XMLElement *idg, std::string includePaths) : additionalIncludePaths(std::move(includePaths)) {
const char *condAttr = idg->Attribute("Condition"); const char *condAttr = idg->Attribute("Condition");
if (condAttr) if (condAttr)
condition = condAttr; condition = condAttr;

View File

@ -23,8 +23,8 @@
#include <cstddef> #include <cstddef>
PathMatch::PathMatch(const std::vector<std::string> &excludedPaths, bool caseSensitive) PathMatch::PathMatch(std::vector<std::string> excludedPaths, bool caseSensitive)
: mExcludedPaths(excludedPaths), mCaseSensitive(caseSensitive) : mExcludedPaths(std::move(excludedPaths)), mCaseSensitive(caseSensitive)
{ {
if (!mCaseSensitive) if (!mCaseSensitive)
for (std::string& excludedPath : mExcludedPaths) for (std::string& excludedPath : mExcludedPaths)

View File

@ -39,7 +39,7 @@ public:
* @param caseSensitive Match the case of the characters when * @param caseSensitive Match the case of the characters when
* matching paths? * matching paths?
*/ */
explicit PathMatch(const std::vector<std::string> &excludedPaths, bool caseSensitive = true); explicit PathMatch(std::vector<std::string> excludedPaths, bool caseSensitive = true);
/** /**
* @brief Match path against list of masks. * @brief Match path against list of masks.

View File

@ -56,8 +56,8 @@ static std::string trim(const std::string& s)
return s.substr(beg, end - beg + 1); return s.substr(beg, end - beg + 1);
} }
Directive::Directive(const std::string &_file, const int _linenr, const std::string &_str) : Directive::Directive(std::string _file, const int _linenr, const std::string &_str) :
file(_file), file(std::move(_file)),
linenr(_linenr), linenr(_linenr),
str(trim(_str)) str(trim(_str))
{} {}
@ -78,7 +78,7 @@ Preprocessor::~Preprocessor()
namespace { namespace {
struct BadInlineSuppression { struct BadInlineSuppression {
BadInlineSuppression(const simplecpp::Location &l, const std::string &msg) : location(l), errmsg(msg) {} BadInlineSuppression(const simplecpp::Location &l, std::string msg) : location(l), errmsg(std::move(msg)) {}
simplecpp::Location location; simplecpp::Location location;
std::string errmsg; std::string errmsg;
}; };

View File

@ -56,7 +56,7 @@ public:
std::string str; std::string str;
/** record a directive (possibly filtering src) */ /** record a directive (possibly filtering src) */
Directive(const std::string &_file, const int _linenr, const std::string &_str); Directive(std::string _file, const int _linenr, const std::string &_str);
}; };
/// @addtogroup Core /// @addtogroup Core

View File

@ -74,7 +74,7 @@ namespace {
class FindName { class FindName {
public: public:
explicit FindName(const std::string &name) : mName(name) {} explicit FindName(std::string name) : mName(std::move(name)) {}
bool operator()(const TemplateSimplifier::TokenAndName &tokenAndName) const { bool operator()(const TemplateSimplifier::TokenAndName &tokenAndName) const {
return tokenAndName.name() == mName; return tokenAndName.name() == mName;
} }
@ -84,7 +84,7 @@ namespace {
class FindFullName { class FindFullName {
public: public:
explicit FindFullName(const std::string &fullName) : mFullName(fullName) {} explicit FindFullName(std::string fullName) : mFullName(std::move(fullName)) {}
bool operator()(const TemplateSimplifier::TokenAndName &tokenAndName) const { bool operator()(const TemplateSimplifier::TokenAndName &tokenAndName) const {
return tokenAndName.fullName() == mFullName; return tokenAndName.fullName() == mFullName;
} }
@ -93,8 +93,8 @@ namespace {
}; };
} }
TemplateSimplifier::TokenAndName::TokenAndName(Token *token, const std::string &scope) : TemplateSimplifier::TokenAndName::TokenAndName(Token *token, std::string scope) :
mToken(token), mScope(scope), mName(mToken ? mToken->str() : ""), mToken(token), mScope(std::move(scope)), mName(mToken ? mToken->str() : ""),
mFullName(mScope.empty() ? mName : (mScope + " :: " + mName)), mFullName(mScope.empty() ? mName : (mScope + " :: " + mName)),
mNameToken(nullptr), mParamEnd(nullptr), mFlags(0) mNameToken(nullptr), mParamEnd(nullptr), mFlags(0)
{ {
@ -109,8 +109,8 @@ TemplateSimplifier::TokenAndName::TokenAndName(Token *token, const std::string &
} }
} }
TemplateSimplifier::TokenAndName::TokenAndName(Token *token, const std::string &scope, const Token *nameToken, const Token *paramEnd) : TemplateSimplifier::TokenAndName::TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd) :
mToken(token), mScope(scope), mName(nameToken->str()), mToken(token), mScope(std::move(scope)), mName(nameToken->str()),
mFullName(mScope.empty() ? mName : (mScope + " :: " + mName)), mFullName(mScope.empty() ? mName : (mScope + " :: " + mName)),
mNameToken(nameToken), mParamEnd(paramEnd), mFlags(0) mNameToken(nameToken), mParamEnd(paramEnd), mFlags(0)
{ {
@ -1588,7 +1588,7 @@ void TemplateSimplifier::expandTemplate(
const bool isSpecialization = templateDeclaration.isSpecialization(); const bool isSpecialization = templateDeclaration.isSpecialization();
const bool isVariable = templateDeclaration.isVariable(); const bool isVariable = templateDeclaration.isVariable();
struct newInstantiation { struct newInstantiation {
newInstantiation(Token *t, const std::string &s) : token(t), scope(s) {} newInstantiation(Token *t, std::string s) : token(t), scope(std::move(s)) {}
Token *token; Token *token;
std::string scope; std::string scope;
}; };

View File

@ -138,7 +138,7 @@ public:
* \param token template instantiation name token "name<...>" * \param token template instantiation name token "name<...>"
* \param scope full qualification of template(scope) * \param scope full qualification of template(scope)
*/ */
TokenAndName(Token *token, const std::string &scope); TokenAndName(Token *token, std::string scope);
/** /**
* Constructor used for declarations. * Constructor used for declarations.
* \param token template declaration token "template < ... >" * \param token template declaration token "template < ... >"
@ -146,7 +146,7 @@ public:
* \param nameToken template name token "template < ... > class name" * \param nameToken template name token "template < ... > class name"
* \param paramEnd template parameter end token ">" * \param paramEnd template parameter end token ">"
*/ */
TokenAndName(Token *token, const std::string &scope, const Token *nameToken, const Token *paramEnd); TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd);
TokenAndName(const TokenAndName& other); TokenAndName(const TokenAndName& other);
~TokenAndName(); ~TokenAndName();

View File

@ -71,8 +71,8 @@ void TimerResults::addResults(const std::string& str, std::clock_t clocks)
mResults[str].mNumberOfResults++; mResults[str].mNumberOfResults++;
} }
Timer::Timer(const std::string& str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* timerResults) Timer::Timer(std::string str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* timerResults)
: mStr(str) : mStr(std::move(str))
, mTimerResults(timerResults) , mTimerResults(timerResults)
, mStart(0) , mStart(0)
, mShowTimeMode(showtimeMode) , mShowTimeMode(showtimeMode)

View File

@ -67,7 +67,7 @@ private:
class CPPCHECKLIB Timer { class CPPCHECKLIB Timer {
public: public:
Timer(const std::string& str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* timerResults = nullptr); Timer(std::string str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* timerResults = nullptr);
~Timer(); ~Timer();
Timer(const Timer&) = delete; Timer(const Timer&) = delete;

View File

@ -1835,8 +1835,8 @@ namespace {
struct ScopeInfo3 { struct ScopeInfo3 {
enum Type { Global, Namespace, Record, MemberFunction, Other }; enum Type { Global, Namespace, Record, MemberFunction, Other };
ScopeInfo3() : parent(nullptr), type(Global), bodyStart(nullptr), bodyEnd(nullptr) {} ScopeInfo3() : parent(nullptr), type(Global), bodyStart(nullptr), bodyEnd(nullptr) {}
ScopeInfo3(ScopeInfo3 *parent_, Type type_, const std::string &name_, const Token *bodyStart_, const Token *bodyEnd_) ScopeInfo3(ScopeInfo3 *parent_, Type type_, std::string name_, const Token *bodyStart_, const Token *bodyEnd_)
: parent(parent_), type(type_), name(name_), bodyStart(bodyStart_), bodyEnd(bodyEnd_) { : parent(parent_), type(type_), name(std::move(name_)), bodyStart(bodyStart_), bodyEnd(bodyEnd_) {
if (name.empty()) if (name.empty())
return; return;
fullName = name; fullName = name;
@ -4182,7 +4182,7 @@ void Tokenizer::setVarIdPass1()
namespace { namespace {
struct Member { struct Member {
Member(const std::list<std::string> &s, const std::list<const Token *> &ns, Token *t) : usingnamespaces(ns), scope(s), tok(t) {} Member(std::list<std::string> s, std::list<const Token *> ns, Token *t) : usingnamespaces(std::move(ns)), scope(std::move(s)), tok(t) {}
std::list<const Token *> usingnamespaces; std::list<const Token *> usingnamespaces;
std::list<std::string> scope; std::list<std::string> scope;
Token *tok; Token *tok;

View File

@ -2880,7 +2880,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
SingleValueFlowAnalyzer() : ValueFlowAnalyzer() {} SingleValueFlowAnalyzer() : ValueFlowAnalyzer() {}
SingleValueFlowAnalyzer(const ValueFlow::Value& v, const TokenList* t) : ValueFlowAnalyzer(t), value(v) {} SingleValueFlowAnalyzer(ValueFlow::Value v, const TokenList* t) : ValueFlowAnalyzer(t), value(std::move(v)) {}
const std::unordered_map<nonneg int, const Variable*>& getVars() const { const std::unordered_map<nonneg int, const Variable*>& getVars() const {
return varids; return varids;
@ -3798,11 +3798,11 @@ struct LifetimeStore {
{} {}
LifetimeStore(const Token* argtok, LifetimeStore(const Token* argtok,
const std::string& message, std::string message,
ValueFlow::Value::LifetimeKind type = ValueFlow::Value::LifetimeKind::Object, ValueFlow::Value::LifetimeKind type = ValueFlow::Value::LifetimeKind::Object,
bool inconclusive = false) bool inconclusive = false)
: argtok(argtok), : argtok(argtok),
message(message), message(std::move(message)),
type(type), type(type),
errorPath(), errorPath(),
inconclusive(inconclusive), inconclusive(inconclusive),