diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2016-05-26 20:21:15 (GMT) |
---|---|---|
committer | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2016-05-26 20:21:15 (GMT) |
commit | 27ead963052b4c3f4e40ea9e6141ba9902ad310a (patch) | |
tree | 69996681031307b34c930d51e0b3406fedf74236 | |
parent | 618fb23fc9838d344e2033c64bfc1a3a55bb7f61 (diff) | |
download | CMake-27ead963052b4c3f4e40ea9e6141ba9902ad310a.zip CMake-27ead963052b4c3f4e40ea9e6141ba9902ad310a.tar.gz CMake-27ead963052b4c3f4e40ea9e6141ba9902ad310a.tar.bz2 |
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.
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestUploadCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmExternalMakefileProjectGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmake.cxx | 4 |
9 files changed, 16 insertions, 25 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 1f2d29c..b366930 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -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; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index fa9bd2c..664552a 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -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; diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 6813cbc..c85db02 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -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; diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index e3c8fa4..0e42d75 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -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; } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a1c9d76..143ad92 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -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) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2de12ba..e91eb46 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 653ea40..f60a595 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -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 diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6db0553..aec56d0 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e4d6656..89ea955 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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); |