diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-22 14:34:40 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-22 14:38:10 (GMT) |
commit | 9b334397f55b70689ff1d8f7d6767a34834e85b6 (patch) | |
tree | bc33e4dc90eef2c351e278219bc9743d40af632c /Source/cmExtraEclipseCDT4Generator.cxx | |
parent | 130dbe4a5d49baa4404a399860bd3a6182783ece (diff) | |
download | CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.zip CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.gz CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.bz2 |
Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind
```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```
and replaces them with a single `cmStrCat` call
```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```
If any `<ARGX>` is itself a concatenated string of the kind
```
a + b + c + ...;
```
then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.
If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.
Single character strings are converted to single char arguments for
the `cmStrCat` call.
`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.
`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
Diffstat (limited to 'Source/cmExtraEclipseCDT4Generator.cxx')
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 9ac355c..5ff638d 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -240,8 +240,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, std::string envVarValue; const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue); - std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; - cacheEntryName += envVar; + std::string cacheEntryName = cmStrCat("CMAKE_ECLIPSE_ENVVAR_", envVar); const std::string* cacheValue = lg->GetState()->GetInitializedCacheValue(cacheEntryName); @@ -464,9 +463,7 @@ void cmExtraEclipseCDT4Generator::WriteGroups( cmXMLWriter& xml) { for (cmSourceGroup const& sg : sourceGroups) { - std::string linkName3 = linkName; - linkName3 += "/"; - linkName3 += sg.GetFullName(); + std::string linkName3 = cmStrCat(linkName, '/', sg.GetFullName()); std::replace(linkName3.begin(), linkName3.end(), '\\', '/'); @@ -481,9 +478,8 @@ void cmExtraEclipseCDT4Generator::WriteGroups( std::string const& fullPath = file->GetFullPath(); if (!cmSystemTools::FileIsDirectory(fullPath)) { - std::string linkName4 = linkName3; - linkName4 += "/"; - linkName4 += cmSystemTools::GetFilenameName(fullPath); + std::string linkName4 = + cmStrCat(linkName3, '/', cmSystemTools::GetFilenameName(fullPath)); cmExtraEclipseCDT4Generator::AppendLinkedResource( xml, linkName4, cmExtraEclipseCDT4Generator::GetEclipsePath(fullPath), LinkToFile); @@ -503,8 +499,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets(); for (cmGeneratorTarget* target : targets) { - std::string linkName2 = linkName; - linkName2 += "/"; + std::string linkName2 = cmStrCat(linkName, '/'); switch (target->GetType()) { case cmStateEnums::EXECUTABLE: case cmStateEnums::STATIC_LIBRARY: @@ -566,8 +561,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( // .project itself if ((baseDir != linkSourceDirectory) && !cmSystemTools::IsSubDirectory(baseDir, linkSourceDirectory)) { - std::string linkName = "[Subprojects]/"; - linkName += it.first; + std::string linkName = cmStrCat("[Subprojects]/", it.first); cmExtraEclipseCDT4Generator::AppendLinkedResource( xml, linkName, cmExtraEclipseCDT4Generator::GetEclipsePath(linkSourceDirectory), @@ -970,28 +964,21 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const : "[lib] "); cmExtraEclipseCDT4Generator::AppendTarget(xml, targetName, make, makeArgs, subdir, prefix); - std::string fastTarget = targetName; - fastTarget += "/fast"; + std::string fastTarget = cmStrCat(targetName, "/fast"); cmExtraEclipseCDT4Generator::AppendTarget(xml, fastTarget, make, makeArgs, subdir, prefix); // Add Build and Clean targets in the virtual folder of targets: if (this->SupportsVirtualFolders) { - std::string virtDir = "[Targets]/"; - virtDir += prefix; - virtDir += targetName; - std::string buildArgs = "-C \""; - buildArgs += lgen->GetBinaryDirectory(); - buildArgs += "\" "; - buildArgs += makeArgs; + std::string virtDir = cmStrCat("[Targets]/", prefix, targetName); + std::string buildArgs = + cmStrCat("-C \"", lgen->GetBinaryDirectory(), "\" ", makeArgs); cmExtraEclipseCDT4Generator::AppendTarget( xml, "Build", make, buildArgs, virtDir, "", targetName.c_str()); - std::string cleanArgs = "-E chdir \""; - cleanArgs += lgen->GetCurrentBinaryDirectory(); - cleanArgs += "\" \""; - cleanArgs += cmSystemTools::GetCMakeCommand(); - cleanArgs += "\" -P \""; + std::string cleanArgs = + cmStrCat("-E chdir \"", lgen->GetCurrentBinaryDirectory(), + "\" \"", cmSystemTools::GetCMakeCommand(), "\" -P \""); cmGeneratorTarget* gt = target; cleanArgs += lgen->GetTargetDirectory(gt); cleanArgs += "/cmake_clean.cmake\""; |