Remove unnecessary local copies.
Use clang-tidy's performance-unnecessary-copy-initialization checker. After applying the fix-its (which turns the copies into const&), revise the changes and see whether the copies can be removed entirely by using the original instead.
This commit is contained in:
parent
618fb23fc9
commit
27ead96305
|
@ -1356,7 +1356,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
|
|||
return 0;
|
||||
}
|
||||
std::string testingDir = this->CTest->GetBinaryDir();
|
||||
std::string tempDir = testingDir;
|
||||
std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
|
||||
std::set<std::string> missingFiles;
|
||||
|
|
|
@ -219,12 +219,11 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
|
|||
}
|
||||
|
||||
if (this->ArgumentDoing == ArgumentDoingFiles) {
|
||||
std::string filename(arg);
|
||||
if (cmSystemTools::FileExists(filename.c_str())) {
|
||||
this->Files.insert(filename);
|
||||
if (cmSystemTools::FileExists(arg.c_str())) {
|
||||
this->Files.insert(arg);
|
||||
} else {
|
||||
std::ostringstream e;
|
||||
e << "File \"" << filename << "\" does not exist. Cannot submit "
|
||||
e << "File \"" << arg << "\" does not exist. Cannot submit "
|
||||
<< "a non-existent file.";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
this->ArgumentDoing = ArgumentDoingError;
|
||||
|
|
|
@ -46,13 +46,12 @@ bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
|
|||
bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
|
||||
{
|
||||
if (this->ArgumentDoing == ArgumentDoingFiles) {
|
||||
std::string filename(arg);
|
||||
if (cmSystemTools::FileExists(filename.c_str())) {
|
||||
this->Files.insert(filename);
|
||||
if (cmSystemTools::FileExists(arg.c_str())) {
|
||||
this->Files.insert(arg);
|
||||
return true;
|
||||
} else {
|
||||
std::ostringstream e;
|
||||
e << "File \"" << filename << "\" does not exist. Cannot submit "
|
||||
e << "File \"" << arg << "\" does not exist. Cannot submit "
|
||||
<< "a non-existent file.";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
this->ArgumentDoing = ArgumentDoingError;
|
||||
|
|
|
@ -43,9 +43,8 @@ std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string currentName = fullName;
|
||||
// if we get only the short name, take the first global generator as default
|
||||
if (currentName == this->GetName()) {
|
||||
if (fullName == this->GetName()) {
|
||||
return this->SupportedGlobalGenerators[0];
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
|
|||
for (std::vector<std::string>::const_iterator it =
|
||||
this->SupportedGlobalGenerators.begin();
|
||||
it != this->SupportedGlobalGenerators.end(); ++it) {
|
||||
if (this->CreateFullGeneratorName(*it, this->GetName()) == currentName) {
|
||||
if (this->CreateFullGeneratorName(*it, this->GetName()) == fullName) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,15 +46,14 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
|
|||
if (comment.empty())
|
||||
return;
|
||||
|
||||
std::string replace = comment;
|
||||
std::string::size_type lpos = 0;
|
||||
std::string::size_type rpos;
|
||||
os << "\n#############################################\n";
|
||||
while ((rpos = replace.find('\n', lpos)) != std::string::npos) {
|
||||
os << "# " << replace.substr(lpos, rpos - lpos) << "\n";
|
||||
while ((rpos = comment.find('\n', lpos)) != std::string::npos) {
|
||||
os << "# " << comment.substr(lpos, rpos - lpos) << "\n";
|
||||
lpos = rpos + 1;
|
||||
}
|
||||
os << "# " << replace.substr(lpos) << "\n\n";
|
||||
os << "# " << comment.substr(lpos) << "\n\n";
|
||||
}
|
||||
|
||||
std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
|
||||
|
|
|
@ -1766,13 +1766,12 @@ static void AddVisibilityCompileOption(std::string& flags,
|
|||
const std::string& lang,
|
||||
std::string* warnCMP0063)
|
||||
{
|
||||
std::string l(lang);
|
||||
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
|
||||
std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY";
|
||||
const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
|
||||
if (!opt) {
|
||||
return;
|
||||
}
|
||||
std::string flagDefine = l + "_VISIBILITY_PRESET";
|
||||
std::string flagDefine = lang + "_VISIBILITY_PRESET";
|
||||
|
||||
const char* prop = target->GetProperty(flagDefine);
|
||||
if (!prop) {
|
||||
|
|
|
@ -1178,10 +1178,9 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
|
|||
}
|
||||
|
||||
std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
|
||||
const std::string& sin, const std::string& s2in)
|
||||
const std::string& sin, const std::string& s2)
|
||||
{
|
||||
std::string s = sin;
|
||||
std::string s2 = s2in;
|
||||
std::string unmodified = s;
|
||||
unmodified += s2;
|
||||
// if there is no restriction on the length of make variables
|
||||
|
|
|
@ -294,7 +294,7 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
|
|||
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
|
||||
|
||||
// Get the input file location.
|
||||
std::string input = source.GetFullPath();
|
||||
std::string const& input = source.GetFullPath();
|
||||
|
||||
// Get the output file location.
|
||||
std::string output = macdir;
|
||||
|
|
|
@ -2296,10 +2296,8 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg)
|
|||
}
|
||||
|
||||
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
||||
cmListFileBacktrace const& bt, bool force)
|
||||
cmListFileBacktrace const& backtrace, bool force)
|
||||
{
|
||||
cmListFileBacktrace backtrace = bt;
|
||||
|
||||
if (!force) {
|
||||
// override the message type, if needed, for warnings and errors
|
||||
cmake::MessageType override = this->ConvertMessageType(t);
|
||||
|
|
Loading…
Reference in New Issue