diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-03 11:20:31 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-05 15:21:00 (GMT) |
commit | 18b0330b86cae2771a54021e390f157a097c8a99 (patch) | |
tree | 85b770ff9467bdc764d7b42ed2480016c26b2235 /Source/CTest | |
parent | 2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 (diff) | |
download | CMake-18b0330b86cae2771a54021e390f157a097c8a99.zip CMake-18b0330b86cae2771a54021e390f157a097c8a99.tar.gz CMake-18b0330b86cae2771a54021e390f157a097c8a99.tar.bz2 |
clang-tidy: Enable performance-inefficient-string-concatenation
Enables the clang-tidy test performance-inefficient-string-concatenation
and replaces all inefficient string concatenations with `cmStrCat`.
Closes: #19555
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestLaunch.cxx | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmParseCoberturaCoverage.cxx | 5 |
5 files changed, 13 insertions, 17 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 407e9f8..b98a4e3 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -385,11 +385,8 @@ int cmCTestBuildHandler::ProcessHandler() if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) { std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory") + "/"; - std::string srcdirrep; for (cc = srcdir.size() - 2; cc > 0; cc--) { if (srcdir[cc] == '/') { - srcdirrep = srcdir.substr(cc); - srcdirrep = "/..." + srcdirrep; srcdir = srcdir.substr(0, cc + 1); break; } @@ -399,11 +396,8 @@ int cmCTestBuildHandler::ProcessHandler() if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) { std::string bindir = this->CTest->GetCTestConfiguration("BuildDirectory") + "/"; - std::string bindirrep; for (cc = bindir.size() - 2; cc > 0; cc--) { if (bindir[cc] == '/') { - bindirrep = bindir.substr(cc); - bindirrep = "/..." + bindirrep; bindir = bindir.substr(0, cc + 1); break; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index bbf490e..739cc58 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -494,9 +494,9 @@ void cmCTestLaunch::DumpFileToXML(cmXMLElement& e3, const char* tag, continue; } if (this->Match(line, this->RegexWarningSuppress)) { - line = "[CTest: warning suppressed] " + line; + line = cmStrCat("[CTest: warning suppressed] ", line); } else if (this->Match(line, this->RegexWarning)) { - line = "[CTest: warning matched] " + line; + line = cmStrCat("[CTest: warning matched] ", line); } e4.Content(sep); e4.Content(line); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index f8d9f1b..4288b25 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -30,6 +30,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -663,8 +664,8 @@ int cmCTestScriptHandler::PerformExtraUpdates() fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform extra updates:\n" + eu + - "\nWith output:\n" + output); + cmSystemTools::Error(cmStrCat("Unable to perform extra updates:\n", eu, + "\nWith output:\n", output)); return 0; } } @@ -934,7 +935,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( continue; } - std::string fullPath = directoryPath + std::string("/") + path; + std::string fullPath = cmStrCat(directoryPath, "/", path); bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) && !cmSystemTools::FileIsSymlink(fullPath); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 2c6ff83..17ef350 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -225,7 +225,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( std::string local_file = file; bool initialize_cdash_buildid = false; if (!cmSystemTools::FileExists(local_file)) { - local_file = localprefix + "/" + file; + local_file = cmStrCat(localprefix, "/", file); // If this file exists within the local Testing directory we assume // that it will be associated with the current build in CDash. initialize_cdash_buildid = true; @@ -237,9 +237,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( << remote_file << std::endl; std::string ofile = cmSystemTools::EncodeURL(remote_file); - std::string upload_as = url + - ((url.find('?') == std::string::npos) ? '?' : '&') + - "FileName=" + ofile; + std::string upload_as = + cmStrCat(url, ((url.find('?') == std::string::npos) ? '?' : '&'), + "FileName=", ofile); if (initialize_cdash_buildid) { // Provide extra arguments to CDash so that it can initialize and diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 848a034..e0186c9 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -2,6 +2,7 @@ #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -75,7 +76,7 @@ protected: // Check if this is a path that is relative to our source or // binary directories. for (std::string const& filePath : FilePaths) { - finalpath = filePath + "/" + filename; + finalpath = cmStrCat(filePath, "/", filename); if (cmSystemTools::FileExists(finalpath)) { this->CurFileName = finalpath; break; @@ -86,7 +87,7 @@ protected: cmsys::ifstream fin(this->CurFileName.c_str()); if (this->CurFileName.empty() || !fin) { this->CurFileName = - this->Coverage.BinaryDir + "/" + atts[tagCount + 1]; + cmStrCat(this->Coverage.BinaryDir, "/", atts[tagCount + 1]); fin.open(this->CurFileName.c_str()); if (!fin) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, |