summaryrefslogtreecommitdiffstats
path: root/Source/cmOutputRequiredFilesCommand.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-03 11:20:31 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-05 15:21:00 (GMT)
commit18b0330b86cae2771a54021e390f157a097c8a99 (patch)
tree85b770ff9467bdc764d7b42ed2480016c26b2235 /Source/cmOutputRequiredFilesCommand.cxx
parent2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 (diff)
downloadCMake-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/cmOutputRequiredFilesCommand.cxx')
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx36
1 files changed, 13 insertions, 23 deletions
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index a66af5a..587e21c 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -215,10 +215,8 @@ protected:
if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::string path : this->IncludeDirectories) {
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path)) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
@@ -227,10 +225,8 @@ protected:
if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::string path : this->IncludeDirectories) {
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path)) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
@@ -240,10 +236,8 @@ protected:
if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::string path : this->IncludeDirectories) {
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path)) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
@@ -253,10 +247,8 @@ protected:
if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::string path : this->IncludeDirectories) {
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path)) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
@@ -340,9 +332,9 @@ protected:
// try to guess which include path to use
for (std::string incpath : this->IncludeDirectories) {
if (!incpath.empty() && incpath.back() != '/') {
- incpath = incpath + "/";
+ incpath += "/";
}
- incpath = incpath + path;
+ incpath += path;
if (srcFile->GetFullPath() == incpath) {
// set the path to the guessed path
info->FullPath = incpath;
@@ -421,9 +413,9 @@ protected:
for (std::string path : this->IncludeDirectories) {
if (!path.empty() && path.back() != '/') {
- path = path + "/";
+ path += "/";
}
- path = path + fname;
+ path += fname;
if (cmSystemTools::FileExists(path, true) &&
!cmSystemTools::FileIsDirectory(path)) {
std::string fp = cmSystemTools::CollapseFullPath(path);
@@ -486,9 +478,7 @@ bool cmOutputRequiredFilesCommand::InitialPass(
// write them out
FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w");
if (!fout) {
- std::string err = "Can not open output file: ";
- err += this->OutputFile;
- this->SetError(err);
+ this->SetError(cmStrCat("Can not open output file: ", this->OutputFile));
return false;
}
std::set<cmDependInformation const*> visited;