Pass arguments that are not modified as const&.
Use clang-tidy's performance-unnecessary-value-param checker to find value parameter declarations of expensive to copy types that are not modified inside the function. Ignore findings in kwsys. After applying the fix-its, manually change `const T&` to `T const&`.
This commit is contained in:
parent
acd8a73044
commit
618fb23fc9
|
@ -50,8 +50,8 @@ int cmCPackDebGenerator::InitializeInternal()
|
|||
return this->Superclass::InitializeInternal();
|
||||
}
|
||||
|
||||
int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
|
||||
std::string packageName)
|
||||
int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
|
||||
std::string const& packageName)
|
||||
{
|
||||
int retval = 1;
|
||||
// Begin the archive for this pack
|
||||
|
|
|
@ -49,7 +49,8 @@ protected:
|
|||
/**
|
||||
* This method factors out the work done in component packaging case.
|
||||
*/
|
||||
int PackageOnePack(std::string initialToplevel, std::string packageName);
|
||||
int PackageOnePack(std::string const& initialToplevel,
|
||||
std::string const& packageName);
|
||||
/**
|
||||
* The method used to package files when component
|
||||
* install is used. This will create one
|
||||
|
|
|
@ -61,8 +61,8 @@ void cmCPackRPMGenerator::AddGeneratedPackageNames()
|
|||
packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
|
||||
}
|
||||
|
||||
int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
|
||||
std::string packageName)
|
||||
int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel,
|
||||
std::string const& packageName)
|
||||
{
|
||||
int retval = 1;
|
||||
// Begin the archive for this pack
|
||||
|
|
|
@ -54,7 +54,8 @@ protected:
|
|||
/**
|
||||
* This method factors out the work done in component packaging case.
|
||||
*/
|
||||
int PackageOnePack(std::string initialToplevel, std::string packageName);
|
||||
int PackageOnePack(std::string const& initialToplevel,
|
||||
std::string const& packageName);
|
||||
/**
|
||||
* The method used to package files when component
|
||||
* install is used. This will create one
|
||||
|
|
|
@ -1759,7 +1759,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
|
|||
}
|
||||
|
||||
std::string cmCTestCoverageHandler::FindFile(
|
||||
cmCTestCoverageHandlerContainer* cont, std::string fileName)
|
||||
cmCTestCoverageHandlerContainer* cont, std::string const& fileName)
|
||||
{
|
||||
std::string fileNameNoE =
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(fileName);
|
||||
|
|
|
@ -119,7 +119,7 @@ private:
|
|||
// Find the source file based on the source and build tree. This is used for
|
||||
// Trace.py mode, since that one does not tell us where the source file is.
|
||||
std::string FindFile(cmCTestCoverageHandlerContainer* cont,
|
||||
std::string fileName);
|
||||
std::string const& fileName);
|
||||
|
||||
std::set<std::string> FindUncoveredFiles(
|
||||
cmCTestCoverageHandlerContainer* cont);
|
||||
|
|
|
@ -500,7 +500,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
|
|||
}
|
||||
}
|
||||
|
||||
int cmCTestMultiProcessHandler::SearchByName(std::string name)
|
||||
int cmCTestMultiProcessHandler::SearchByName(std::string const& name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
void UpdateCostData();
|
||||
void ReadCostData();
|
||||
// Return index of a test based on its name
|
||||
int SearchByName(std::string name);
|
||||
int SearchByName(std::string const& name);
|
||||
|
||||
void CreateTestCostList();
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
return line.substr(begIndex, line.npos);
|
||||
}
|
||||
}
|
||||
bool ParseFile(std::string file)
|
||||
bool ParseFile(std::string const& file)
|
||||
{
|
||||
FileLinesType localCoverageVector;
|
||||
std::string filename;
|
||||
|
@ -138,7 +138,7 @@ bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool cmParseBlanketJSCoverage::ReadJSONFile(std::string file)
|
||||
bool cmParseBlanketJSCoverage::ReadJSONFile(std::string const& file)
|
||||
{
|
||||
cmParseBlanketJSCoverage::JSONParser parser(this->Coverage);
|
||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
cmCTest* ctest);
|
||||
bool LoadCoverageData(std::vector<std::string> files);
|
||||
// Read the JSON output
|
||||
bool ReadJSONFile(std::string file);
|
||||
bool ReadJSONFile(std::string const& file);
|
||||
|
||||
protected:
|
||||
class JSONParser;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
virtual ~HTMLParser() {}
|
||||
|
||||
bool initializeDelphiFile(
|
||||
const std::string filename,
|
||||
std::string const& filename,
|
||||
cmParseDelphiCoverage::HTMLParser::FileLinesType& coverageVector)
|
||||
{
|
||||
std::string line;
|
||||
|
@ -197,7 +197,7 @@ cmParseDelphiCoverage::cmParseDelphiCoverage(
|
|||
}
|
||||
|
||||
bool cmParseDelphiCoverage::LoadCoverageData(
|
||||
const std::vector<std::string> files)
|
||||
std::vector<std::string> const& files)
|
||||
{
|
||||
size_t i;
|
||||
std::string path;
|
||||
|
|
|
@ -28,7 +28,7 @@ class cmParseDelphiCoverage
|
|||
{
|
||||
public:
|
||||
cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
|
||||
bool LoadCoverageData(const std::vector<std::string> files);
|
||||
bool LoadCoverageData(std::vector<std::string> const& files);
|
||||
bool ReadDelphiHTML(const char* file);
|
||||
// Read a single HTML file from output
|
||||
bool ReadHTMLFile(const char* f);
|
||||
|
|
|
@ -85,7 +85,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool FindPackagePath(const std::string fileName)
|
||||
virtual bool FindPackagePath(std::string const& fileName)
|
||||
{
|
||||
// Search for the source file in the source directory.
|
||||
if (this->PackagePathFound(fileName, this->Coverage.SourceDir)) {
|
||||
|
@ -99,8 +99,8 @@ protected:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual bool PackagePathFound(const std::string fileName,
|
||||
const std::string baseDir)
|
||||
virtual bool PackagePathFound(std::string const& fileName,
|
||||
std::string const& baseDir)
|
||||
{
|
||||
// Search for the file in the baseDir and its subdirectories.
|
||||
std::string packageGlob = baseDir;
|
||||
|
@ -149,7 +149,7 @@ cmParseJacocoCoverage::cmParseJacocoCoverage(
|
|||
}
|
||||
|
||||
bool cmParseJacocoCoverage::LoadCoverageData(
|
||||
const std::vector<std::string> files)
|
||||
std::vector<std::string> const& files)
|
||||
{
|
||||
// load all the jacoco.xml files in the source directory
|
||||
cmsys::Directory dir;
|
||||
|
|
|
@ -27,7 +27,7 @@ class cmParseJacocoCoverage
|
|||
{
|
||||
public:
|
||||
cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
|
||||
bool LoadCoverageData(const std::vector<std::string> files);
|
||||
bool LoadCoverageData(std::vector<std::string> const& files);
|
||||
|
||||
std::string PackageName;
|
||||
std::string FileName;
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
std::cerr << __LINE__ << " "; \
|
||||
std::cerr
|
||||
|
||||
struct tm* cmCTest::GetNightlyTime(std::string str, bool tomorrowtag)
|
||||
struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
|
||||
{
|
||||
struct tm* lctime;
|
||||
time_t tctime = time(0);
|
||||
|
@ -170,8 +170,8 @@ static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
|
|||
}
|
||||
|
||||
int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
|
||||
std::string& response, std::string fields,
|
||||
std::string putFile, int timeout)
|
||||
std::string& response, std::string const& fields,
|
||||
std::string const& putFile, int timeout)
|
||||
{
|
||||
CURL* curl;
|
||||
FILE* file;
|
||||
|
@ -1481,7 +1481,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
|
|||
return this->GenerateNotesFile(files);
|
||||
}
|
||||
|
||||
std::string cmCTest::Base64GzipEncodeFile(std::string file)
|
||||
std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
|
||||
{
|
||||
std::string tarFile = file + "_temp.tar.gz";
|
||||
std::vector<std::string> files;
|
||||
|
@ -1499,7 +1499,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
|
|||
return base64;
|
||||
}
|
||||
|
||||
std::string cmCTest::Base64EncodeFile(std::string file)
|
||||
std::string cmCTest::Base64EncodeFile(std::string const& file)
|
||||
{
|
||||
size_t const len = cmSystemTools::FileLength(file);
|
||||
cmsys::ifstream ifs(file.c_str(), std::ios::in
|
||||
|
@ -2208,7 +2208,7 @@ void cmCTest::SetNotesFiles(const char* notes)
|
|||
this->NotesFiles = notes;
|
||||
}
|
||||
|
||||
void cmCTest::SetStopTime(std::string time)
|
||||
void cmCTest::SetStopTime(std::string const& time)
|
||||
{
|
||||
this->StopTime = time;
|
||||
this->DetermineNextDayStop();
|
||||
|
|
|
@ -108,8 +108,8 @@ public:
|
|||
* Perform an HTTP request.
|
||||
*/
|
||||
static int HTTPRequest(std::string url, HTTPMethod method,
|
||||
std::string& response, std::string fields = "",
|
||||
std::string putFile = "", int timeout = 0);
|
||||
std::string& response, std::string const& fields = "",
|
||||
std::string const& putFile = "", int timeout = 0);
|
||||
#endif
|
||||
|
||||
/** Get a testing part id from its string name. Returns PartCount
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
/*
|
||||
* A utility function that returns the nightly time
|
||||
*/
|
||||
struct tm* GetNightlyTime(std::string str, bool tomorrowtag);
|
||||
struct tm* GetNightlyTime(std::string const& str, bool tomorrowtag);
|
||||
|
||||
/*
|
||||
* Is the tomorrow tag set?
|
||||
|
@ -211,9 +211,9 @@ public:
|
|||
std::string CurrentTime();
|
||||
|
||||
//! tar/gzip and then base 64 encode a file
|
||||
std::string Base64GzipEncodeFile(std::string file);
|
||||
std::string Base64GzipEncodeFile(std::string const& file);
|
||||
//! base64 encode a file
|
||||
std::string Base64EncodeFile(std::string file);
|
||||
std::string Base64EncodeFile(std::string const& file);
|
||||
|
||||
/**
|
||||
* Return the time remaining that the script is allowed to run in
|
||||
|
@ -240,7 +240,7 @@ public:
|
|||
std::string GetCDashVersion();
|
||||
|
||||
std::string GetStopTime() { return this->StopTime; }
|
||||
void SetStopTime(std::string time);
|
||||
void SetStopTime(std::string const& time);
|
||||
|
||||
// Used for parallel ctest job scheduling
|
||||
std::string GetScheduleType() { return this->ScheduleType; }
|
||||
|
|
|
@ -2746,7 +2746,7 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
|
|||
}
|
||||
|
||||
void cmGlobalGenerator::SetFilenameTargetDepends(
|
||||
cmSourceFile* sf, std::set<cmGeneratorTarget const*> tgts)
|
||||
cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts)
|
||||
{
|
||||
this->FilenameTargetDepends[sf] = tgts;
|
||||
}
|
||||
|
|
|
@ -348,8 +348,8 @@ public:
|
|||
|
||||
void CreateEvaluationSourceFiles(std::string const& config) const;
|
||||
|
||||
void SetFilenameTargetDepends(cmSourceFile* sf,
|
||||
std::set<const cmGeneratorTarget*> tgts);
|
||||
void SetFilenameTargetDepends(
|
||||
cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
|
||||
const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
|
||||
cmSourceFile* sf) const;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ std::string cmInstallFilesGenerator::GetDestination(
|
|||
}
|
||||
|
||||
void cmInstallFilesGenerator::AddFilesInstallRule(
|
||||
std::ostream& os, const std::string config, Indent const& indent,
|
||||
std::ostream& os, std::string const& config, Indent const& indent,
|
||||
std::vector<std::string> const& files)
|
||||
{
|
||||
// Write code to install the files.
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
virtual void GenerateScriptForConfig(std::ostream& os,
|
||||
const std::string& config,
|
||||
Indent const& indent);
|
||||
void AddFilesInstallRule(std::ostream& os, const std::string config,
|
||||
void AddFilesInstallRule(std::ostream& os, std::string const& config,
|
||||
Indent const& indent,
|
||||
std::vector<std::string> const& files);
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ const std::vector<const cmSourceFile*>& cmSourceGroup::GetSourceFiles() const
|
|||
return this->SourceFiles;
|
||||
}
|
||||
|
||||
void cmSourceGroup::AddChild(cmSourceGroup child)
|
||||
void cmSourceGroup::AddChild(cmSourceGroup const& child)
|
||||
{
|
||||
this->Internal->GroupChildren.push_back(child);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
/**
|
||||
* Add child to this sourcegroup
|
||||
*/
|
||||
void AddChild(cmSourceGroup child);
|
||||
void AddChild(cmSourceGroup const& child);
|
||||
|
||||
/**
|
||||
* Looks up child and returns it
|
||||
|
|
|
@ -1616,7 +1616,7 @@ bool cmState::Snapshot::StrictWeakOrder::operator()(
|
|||
|
||||
void cmState::Directory::SetProperty(const std::string& prop,
|
||||
const char* value,
|
||||
cmListFileBacktrace lfbt)
|
||||
cmListFileBacktrace const& lfbt)
|
||||
{
|
||||
if (prop == "INCLUDE_DIRECTORIES") {
|
||||
if (!value) {
|
||||
|
@ -1648,7 +1648,7 @@ void cmState::Directory::SetProperty(const std::string& prop,
|
|||
|
||||
void cmState::Directory::AppendProperty(const std::string& prop,
|
||||
const char* value, bool asString,
|
||||
cmListFileBacktrace lfbt)
|
||||
cmListFileBacktrace const& lfbt)
|
||||
{
|
||||
if (prop == "INCLUDE_DIRECTORIES") {
|
||||
this->AppendIncludeDirectoriesEntry(value, lfbt);
|
||||
|
|
|
@ -164,9 +164,9 @@ public:
|
|||
void ClearCompileOptions();
|
||||
|
||||
void SetProperty(const std::string& prop, const char* value,
|
||||
cmListFileBacktrace lfbt);
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void AppendProperty(const std::string& prop, const char* value,
|
||||
bool asString, cmListFileBacktrace lfbt);
|
||||
bool asString, cmListFileBacktrace const& lfbt);
|
||||
const char* GetProperty(const std::string& prop) const;
|
||||
const char* GetProperty(const std::string& prop, bool chain) const;
|
||||
bool GetPropertyAsBool(const std::string& prop) const;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
void reportLine(std::ostream& os, bool ret, std::string line, bool eol)
|
||||
void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
|
||||
{
|
||||
if (ret) {
|
||||
os << "\"" << line << "\" (" << (eol ? "with EOL" : "without EOL") << ")";
|
||||
|
|
Loading…
Reference in New Issue