Commit 5a0784dd authored by wahikihiki's avatar wahikihiki Committed by Brad King

clang-tidy: Pass by value

parent bcc9ea2b
...@@ -11,7 +11,6 @@ misc-*,\ ...@@ -11,7 +11,6 @@ misc-*,\
-misc-static-assert,\ -misc-static-assert,\
modernize-*,\ modernize-*,\
-modernize-deprecated-headers,\ -modernize-deprecated-headers,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\ -modernize-raw-string-literal,\
-modernize-return-braced-init-list,\ -modernize-return-braced-init-list,\
-modernize-use-auto,\ -modernize-use-auto,\
......
...@@ -23,17 +23,15 @@ namespace { ...@@ -23,17 +23,15 @@ namespace {
class DebGenerator class DebGenerator
{ {
public: public:
DebGenerator(cmCPackLog* logger, std::string const& outputName, DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir,
std::string const& workDir, std::string const& topLevelDir, std::string topLevelDir, std::string temporaryDir,
std::string const& temporaryDir,
const char* debianCompressionType, const char* debianCompressionType,
const char* debianArchiveType, const char* debianArchiveType,
std::map<std::string, std::string> const& controlValues, std::map<std::string, std::string> controlValues,
bool genShLibs, std::string const& shLibsFilename, bool genShLibs, std::string shLibsFilename, bool genPostInst,
bool genPostInst, std::string const& postInst, bool genPostRm, std::string postInst, bool genPostRm, std::string postRm,
std::string const& postRm, const char* controlExtra, const char* controlExtra, bool permissionStrctPolicy,
bool permissionStrctPolicy, std::vector<std::string> packageFiles);
std::vector<std::string> const& packageFiles);
bool generate() const; bool generate() const;
...@@ -66,31 +64,29 @@ private: ...@@ -66,31 +64,29 @@ private:
}; };
DebGenerator::DebGenerator( DebGenerator::DebGenerator(
cmCPackLog* logger, std::string const& outputName, cmCPackLog* logger, std::string outputName, std::string workDir,
std::string const& workDir, std::string const& topLevelDir, std::string topLevelDir, std::string temporaryDir,
std::string const& temporaryDir, const char* debianCompressionType, const char* debianCompressionType, const char* debianArchiveType,
const char* debianArchiveType, std::map<std::string, std::string> controlValues, bool genShLibs,
std::map<std::string, std::string> const& controlValues, bool genShLibs, std::string shLibsFilename, bool genPostInst, std::string postInst,
std::string const& shLibsFilename, bool genPostInst, bool genPostRm, std::string postRm, const char* controlExtra,
std::string const& postInst, bool genPostRm, std::string const& postRm, bool permissionStrictPolicy, std::vector<std::string> packageFiles)
const char* controlExtra, bool permissionStrictPolicy,
std::vector<std::string> const& packageFiles)
: Logger(logger) : Logger(logger)
, OutputName(outputName) , OutputName(std::move(outputName))
, WorkDir(workDir) , WorkDir(std::move(workDir))
, TopLevelDir(topLevelDir) , TopLevelDir(std::move(topLevelDir))
, TemporaryDir(temporaryDir) , TemporaryDir(std::move(temporaryDir))
, DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar") , DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar")
, ControlValues(controlValues) , ControlValues(std::move(controlValues))
, GenShLibs(genShLibs) , GenShLibs(genShLibs)
, ShLibsFilename(shLibsFilename) , ShLibsFilename(std::move(shLibsFilename))
, GenPostInst(genPostInst) , GenPostInst(genPostInst)
, PostInst(postInst) , PostInst(std::move(postInst))
, GenPostRm(genPostRm) , GenPostRm(genPostRm)
, PostRm(postRm) , PostRm(std::move(postRm))
, ControlExtra(controlExtra) , ControlExtra(controlExtra)
, PermissionStrictPolicy(permissionStrictPolicy) , PermissionStrictPolicy(permissionStrictPolicy)
, PackageFiles(packageFiles) , PackageFiles(std::move(packageFiles))
{ {
if (!debianCompressionType) { if (!debianCompressionType) {
debianCompressionType = "gzip"; debianCompressionType = "gzip";
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <pkg.h> #include <pkg.h>
#include <algorithm> #include <algorithm>
#include <utility>
cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
: cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr") : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
...@@ -97,8 +98,8 @@ class ManifestKey ...@@ -97,8 +98,8 @@ class ManifestKey
public: public:
std::string key; std::string key;
ManifestKey(const std::string& k) ManifestKey(std::string k)
: key(k) : key(std::move(k))
{ {
} }
...@@ -115,9 +116,9 @@ class ManifestKeyValue : public ManifestKey ...@@ -115,9 +116,9 @@ class ManifestKeyValue : public ManifestKey
public: public:
std::string value; std::string value;
ManifestKeyValue(const std::string& k, const std::string& v) ManifestKeyValue(const std::string& k, std::string v)
: ManifestKey(k) : ManifestKey(k)
, value(v) , value(std::move(v))
{ {
} }
......
...@@ -20,15 +20,16 @@ ...@@ -20,15 +20,16 @@
#include <algorithm> #include <algorithm>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <utility>
inline int ctrl(int z) inline int ctrl(int z)
{ {
return (z & 037); return (z & 037);
} }
cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
int initWidth) int initWidth)
: Args(args) : Args(std::move(args))
, InitialWidth(initWidth) , InitialWidth(initWidth)
{ {
this->NumberOfPages = 0; this->NumberOfPages = 0;
......
...@@ -26,7 +26,7 @@ class cmCursesMainForm : public cmCursesForm ...@@ -26,7 +26,7 @@ class cmCursesMainForm : public cmCursesForm
CM_DISABLE_COPY(cmCursesMainForm) CM_DISABLE_COPY(cmCursesMainForm)
public: public:
cmCursesMainForm(std::vector<std::string> const& args, int initwidth); cmCursesMainForm(std::vector<std::string> args, int initwidth);
~cmCursesMainForm() override; ~cmCursesMainForm() override;
/** /**
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#include <QFileInfo> #include <QFileInfo>
#include <QResizeEvent> #include <QResizeEvent>
#include <QToolButton> #include <QToolButton>
#include <utility>
QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var) QCMakeFileEditor::QCMakeFileEditor(QWidget* p, QString var)
: QLineEdit(p) : QLineEdit(p)
, Variable(var) , Variable(std::move(var))
{ {
this->ToolButton = new QToolButton(this); this->ToolButton = new QToolButton(this);
this->ToolButton->setText("..."); this->ToolButton->setText("...");
......
...@@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit ...@@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
QCMakeFileEditor(QWidget* p, const QString& var); QCMakeFileEditor(QWidget* p, QString var);
protected slots: protected slots:
virtual void chooseFile() = 0; virtual void chooseFile() = 0;
signals: signals:
......
...@@ -61,8 +61,8 @@ struct cmStrCmp ...@@ -61,8 +61,8 @@ struct cmStrCmp
: m_test(test) : m_test(test)
{ {
} }
cmStrCmp(const std::string& test) cmStrCmp(std::string test)
: m_test(test) : m_test(std::move(test))
{ {
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <iosfwd> #include <iosfwd>
#include <set> #include <set>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
class cmGeneratorTarget; class cmGeneratorTarget;
...@@ -31,9 +32,8 @@ public: ...@@ -31,9 +32,8 @@ public:
struct Item struct Item
{ {
Item() {} Item() {}
Item(std::string const& v, bool p, Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr)
cmGeneratorTarget const* target = nullptr) : Value(std::move(v))
: Value(v)
, IsPath(p) , IsPath(p)
, Target(target) , Target(target)
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <utility>
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmMakefile.h" #include "cmMakefile.h"
...@@ -53,11 +54,11 @@ static std::string const keyVERSION_LESS = "VERSION_LESS"; ...@@ -53,11 +54,11 @@ static std::string const keyVERSION_LESS = "VERSION_LESS";
static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL"; static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL";
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
const cmListFileContext& context, cmListFileContext context,
const cmListFileBacktrace& bt) cmListFileBacktrace bt)
: Makefile(makefile) : Makefile(makefile)
, ExecutionContext(context) , ExecutionContext(std::move(context))
, Backtrace(bt) , Backtrace(std::move(bt))
, Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)) , Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
, Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)) , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
, Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057))
......
...@@ -21,8 +21,8 @@ class cmConditionEvaluator ...@@ -21,8 +21,8 @@ class cmConditionEvaluator
public: public:
typedef std::list<cmExpandedCommandArgument> cmArgumentList; typedef std::list<cmExpandedCommandArgument> cmArgumentList;
cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context, cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context,
cmListFileBacktrace const& bt); cmListFileBacktrace bt);
// this is a shared function for both If and Else to determine if the // this is a shared function for both If and Else to determine if the
// arguments were valid, and if so, was the response true. If there is // arguments were valid, and if so, was the response true. If there is
......
...@@ -4,17 +4,19 @@ ...@@ -4,17 +4,19 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include <utility>
cmCustomCommand::cmCustomCommand(cmMakefile const* mf, cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
const std::vector<std::string>& outputs, std::vector<std::string> outputs,
const std::vector<std::string>& byproducts, std::vector<std::string> byproducts,
const std::vector<std::string>& depends, std::vector<std::string> depends,
const cmCustomCommandLines& commandLines, cmCustomCommandLines commandLines,
const char* comment, const char* comment,
const char* workingDirectory) const char* workingDirectory)
: Outputs(outputs) : Outputs(std::move(outputs))
, Byproducts(byproducts) , Byproducts(std::move(byproducts))
, Depends(depends) , Depends(std::move(depends))
, CommandLines(commandLines) , CommandLines(std::move(commandLines))
, Comment(comment ? comment : "") , Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "") , WorkingDirectory(workingDirectory ? workingDirectory : "")
, HaveComment(comment != nullptr) , HaveComment(comment != nullptr)
......
...@@ -23,12 +23,11 @@ class cmCustomCommand ...@@ -23,12 +23,11 @@ class cmCustomCommand
{ {
public: public:
/** Main constructor specifies all information for the command. */ /** Main constructor specifies all information for the command. */
cmCustomCommand(cmMakefile const* mf, cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs,
const std::vector<std::string>& outputs, std::vector<std::string> byproducts,
const std::vector<std::string>& byproducts, std::vector<std::string> depends,
const std::vector<std::string>& depends, cmCustomCommandLines commandLines, const char* comment,
const cmCustomCommandLines& commandLines, const char* workingDirectory);
const char* comment, const char* workingDirectory);
/** Get the output file produced by the command. */ /** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const; const std::vector<std::string>& GetOutputs() const;
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#include <utility> #include <utility>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
const std::string& config, std::string config,
cmLocalGenerator* lg) cmLocalGenerator* lg)
: CC(cc) : CC(cc)
, Config(config) , Config(std::move(config))
, LG(lg) , LG(lg)
, OldStyle(cc.GetEscapeOldStyle()) , OldStyle(cc.GetEscapeOldStyle())
, MakeVars(cc.GetEscapeAllowMakeVars()) , MakeVars(cc.GetEscapeAllowMakeVars())
......
...@@ -29,8 +29,8 @@ class cmCustomCommandGenerator ...@@ -29,8 +29,8 @@ class cmCustomCommandGenerator
const char* GetArgv0Location(unsigned int c) const; const char* GetArgv0Location(unsigned int c) const;
public: public:
cmCustomCommandGenerator(cmCustomCommand const& cc, cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config,
const std::string& config, cmLocalGenerator* lg); cmLocalGenerator* lg);
~cmCustomCommandGenerator(); ~cmCustomCommandGenerator();
cmCustomCommand const& GetCC() const { return this->CC; } cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const; unsigned int GetNumberOfCommands() const;
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include <string.h> #include <string.h>
#include <utility> #include <utility>
cmDepends::cmDepends(cmLocalGenerator* lg, const std::string& targetDir) cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir)
: LocalGenerator(lg) : LocalGenerator(lg)
, TargetDirectory(targetDir) , TargetDirectory(std::move(targetDir))
, Dependee(new char[MaxPath]) , Dependee(new char[MaxPath])
, Depender(new char[MaxPath]) , Depender(new char[MaxPath])
{ {
......
...@@ -29,7 +29,7 @@ class cmDepends ...@@ -29,7 +29,7 @@ class cmDepends
public: public:
/** Instances need to know the build directory name and the relative /** Instances need to know the build directory name and the relative
path from the build directory to the target file. */ path from the build directory to the target file. */
cmDepends(cmLocalGenerator* lg = nullptr, const std::string& targetDir = ""); cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = "");
/** Set the local generator for the directory in which we are /** Set the local generator for the directory in which we are
scanning dependencies. This is not a full local generator; it scanning dependencies. This is not a full local generator; it
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExpandedCommandArgument.h" #include "cmExpandedCommandArgument.h"
#include <utility>
cmExpandedCommandArgument::cmExpandedCommandArgument() cmExpandedCommandArgument::cmExpandedCommandArgument()
{ {
} }
cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value, cmExpandedCommandArgument::cmExpandedCommandArgument(std::string value,
bool quoted) bool quoted)
: Value(value) : Value(std::move(value))
, Quoted(quoted) , Quoted(quoted)
{ {
} }
......
...@@ -18,7 +18,7 @@ class cmExpandedCommandArgument ...@@ -18,7 +18,7 @@ class cmExpandedCommandArgument
{ {
public: public:
cmExpandedCommandArgument(); cmExpandedCommandArgument();
cmExpandedCommandArgument(std::string const& value, bool quoted); cmExpandedCommandArgument(std::string value, bool quoted);
std::string const& GetValue() const; std::string const& GetValue() const;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep #include "cmConfigure.h" // IWYU pragma: keep
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
class cmInstallExportGenerator; class cmInstallExportGenerator;
...@@ -17,8 +18,8 @@ class cmExportSet ...@@ -17,8 +18,8 @@ class cmExportSet
{ {
public: public:
/// Construct an empty export set named \a name /// Construct an empty export set named \a name
cmExportSet(const std::string& name) cmExportSet(std::string name)
: Name(name) : Name(std::move(name))
{ {
} }
/// Destructor /// Destructor
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExternalMakefileProjectGenerator.h" #include "cmExternalMakefileProjectGenerator.h"
#include <utility>
class cmMakefile; class cmMakefile;
void cmExternalMakefileProjectGenerator::EnableLanguage( void cmExternalMakefileProjectGenerator::EnableLanguage(
...@@ -32,10 +34,9 @@ bool cmExternalMakefileProjectGenerator::Open( ...@@ -32,10 +34,9 @@ bool cmExternalMakefileProjectGenerator::Open(
} }
cmExternalMakefileProjectGeneratorFactory:: cmExternalMakefileProjectGeneratorFactory::
cmExternalMakefileProjectGeneratorFactory(const std::string& n, cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc)
const std::string& doc) : Name(std::move(n))
: Name(n) , Documentation(std::move(doc))
, Documentation(doc)
{ {
} }
......
...@@ -70,8 +70,7 @@ protected: ...@@ -70,8 +70,7 @@ protected:
class cmExternalMakefileProjectGeneratorFactory class cmExternalMakefileProjectGeneratorFactory
{ {
public: public:
cmExternalMakefileProjectGeneratorFactory(const std::string& n, cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc);
const std::string& doc);
virtual ~cmExternalMakefileProjectGeneratorFactory(); virtual ~cmExternalMakefileProjectGeneratorFactory();
std::string GetName() const; std::string GetName() const;
......
...@@ -166,13 +166,13 @@ class BacktraceData ...@@ -166,13 +166,13 @@ class BacktraceData
} }
public: public:
BacktraceData(std::string const& topSource); BacktraceData(std::string topSource);
bool Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index); bool Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index);
Json::Value Dump(); Json::Value Dump();
}; };
BacktraceData::BacktraceData(std::string const& topSource) BacktraceData::BacktraceData(std::string topSource)
: TopSource(topSource) : TopSource(std::move(topSource))
{ {
} }
......
...@@ -1760,8 +1760,8 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath, ...@@ -1760,8 +1760,8 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
class cmFileListGeneratorFixed : public cmFileListGeneratorBase class cmFileListGeneratorFixed : public cmFileListGeneratorBase
{ {
public: public:
cmFileListGeneratorFixed(std::string const& str) cmFileListGeneratorFixed(std::string str)
: String(str) : String(std::move(str))
{ {
} }
cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r) cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r)
...@@ -1940,8 +1940,8 @@ private: ...@@ -1940,8 +1940,8 @@ private:
class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase
{ {
public: public:
cmFileListGeneratorCaseInsensitive(std::string const& str) cmFileListGeneratorCaseInsensitive(std::string str)
: String(str) : String(std::move(str))
{ {
} }
cmFileListGeneratorCaseInsensitive( cmFileListGeneratorCaseInsensitive(
...@@ -1982,8 +1982,8 @@ private: ...@@ -1982,8 +1982,8 @@ private:
class cmFileListGeneratorGlob : public cmFileListGeneratorBase class cmFileListGeneratorGlob : public cmFileListGeneratorBase
{ {
public: public:
cmFileListGeneratorGlob(std::string const& str) cmFileListGeneratorGlob(std::string str)
: Pattern(str) : Pattern(std::move(str))
{ {
} }
cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r) cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# include <set> # include <set>
# include <string> # include <string>
# include <utility>
# include <vector> # include <vector>
#endif #endif
...@@ -114,10 +115,10 @@ int cmFortran_yyparse(yyscan_t); ...@@ -114,10 +115,10 @@ int cmFortran_yyparse(yyscan_t);
// Define parser object internal structure. // Define parser object internal structure.
struct cmFortranFile struct cmFortranFile
{ {
cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, const std::string& dir) cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, std::string dir)
: File(file) : File(file)
, Buffer(buffer) , Buffer(buffer)
, Directory(dir) , Directory(std::move(dir))
, LastCharWasNewline(false) , LastCharWasNewline(false)
{ {
} }
...@@ -129,9 +130,8 @@ struct cmFortranFile ...@@ -129,9 +130,8 @@ struct cmFortranFile
struct cmFortranParser_s struct cmFortranParser_s
{ {
cmFortranParser_s(std::vector<std::string> const& includes, cmFortranParser_s(std::vector<std::string> includes,
std::set<std::string> const& defines, std::set<std::string> defines, cmFortranSourceInfo& info);
cmFortranSourceInfo& info);
~cmFortranParser_s(); ~cmFortranParser_s();
bool FindIncludeFile(const char* dir, const char* includeName, bool FindIncludeFile(const char* dir, const char* includeName,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stack> #include <stack>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
bool cmFortranParser_s::FindIncludeFile(const char* dir,