From fa60523bf665fcdb648e3658fffeef95cee2d0c8 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Sun, 27 Sep 2026 20:53:54 +0000 Subject: [PATCH] Source: fix ast-grep suggestions --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 2 +- Source/CPack/cmCPackBundleGenerator.cxx | 7 ++- Source/CPack/cmCPackGenerator.cxx | 2 +- Source/CPack/cmCPackNSISGenerator.cxx | 9 ++- Source/CTest/cmCTestMultiProcessHandler.cxx | 8 +-- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 12 ++-- Source/cmCMakeLanguageCommand.cxx | 63 ++++++++++--------- Source/cmComputeLinkDepends.cxx | 17 +++-- Source/cmCoreTryCompile.cxx | 5 +- Source/cmCreateTestSourceList.cxx | 6 +- Source/cmExtraCodeBlocksGenerator.cxx | 3 +- Source/cmFastbuildNormalTargetGenerator.cxx | 16 ++--- Source/cmFindBase.cxx | 36 +++++------ Source/cmFindPackageCommand.cxx | 2 +- Source/cmGeneratorExpression.cxx | 2 +- Source/cmGeneratorTarget.cxx | 3 +- .../cmGeneratorTarget_IncludeDirectories.cxx | 3 +- Source/cmGeneratorTarget_LinkDirectories.cxx | 3 +- Source/cmGeneratorTarget_Options.cxx | 2 +- Source/cmGeneratorTarget_Sources.cxx | 2 +- Source/cmGlobalNinjaGenerator.cxx | 11 ++-- Source/cmGlobalVisualStudio7Generator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 6 +- Source/cmLinkLineComputer.cxx | 8 +-- Source/cmList.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmMakefile.cxx | 39 ++++++------ .../cmMakefileExecutableTargetGenerator.cxx | 3 +- Source/cmMakefileLibraryTargetGenerator.cxx | 3 +- Source/cmMakefileTargetGenerator.cxx | 21 ++++--- Source/cmNinjaNormalTargetGenerator.cxx | 12 ++-- Source/cmNinjaTargetGenerator.cxx | 11 ++-- Source/cmQtAutoGen.cxx | 4 +- Source/cmQtAutoGenInitializer.cxx | 11 ++-- Source/cmQtAutoGenerator.cxx | 8 ++- Source/cmQtAutoMocUic.cxx | 14 +++-- Source/cmSeparateArgumentsCommand.cxx | 3 +- Source/cmTargetIncludeDirectoriesCommand.cxx | 5 +- Source/cmTryRunCommand.cxx | 37 ++++++----- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 42 files changed, 229 insertions(+), 182 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index f79312e4eb..1d639967d5 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -952,7 +952,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( std::string componentId = "CM_SHORTCUT"; if (!idPrefix.empty()) { - componentId += cmStrCat('_', idPrefix); + componentId = cmStrCat(std::move(componentId), '_', idPrefix); } componentId += idSuffix; diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 90d6370658..5740e7c878 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -233,11 +233,12 @@ int cmCPackBundleGenerator::SignBundle(std::string const& src_dir) cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', sign_parameter, " -s \"", cpack_apple_cert_app, '"'); if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) { - temp_codesign_cmd += - cmStrCat(" --entitlements ", + temp_codesign_cmd = + cmStrCat(std::move(temp_codesign_cmd), " --entitlements ", this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")); } - temp_codesign_cmd += cmStrCat(" \"", bundle_path, '"'); + temp_codesign_cmd = + cmStrCat(std::move(temp_codesign_cmd), " \"", bundle_path, '"'); if (!this->RunCommand(temp_codesign_cmd, &output)) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 48a30f24ee..9cbef625e1 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -107,7 +107,7 @@ int cmCPackGenerator::PrepareNames() { cmValue toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG"); if (toplevelTag) { - topDirectory += cmStrCat(toplevelTag, '/'); + topDirectory = cmStrCat(std::move(topDirectory), toplevelTag, '/'); } } topDirectory += *this->GetOption("CPACK_GENERATOR"); diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index d3e5a09764..cc4ea02e9b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -131,11 +131,13 @@ int cmCPackNSISGenerator::PackageFiles() std::string installerIconCode; if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_ICON")) { std::string iconFile = cmSystemTools::ConvertToWindowsOutputPath(*v); - installerIconCode += cmStrCat("!define MUI_ICON ", iconFile, '\n'); + installerIconCode = cmStrCat(std::move(installerIconCode), + "!define MUI_ICON ", iconFile, '\n'); } if (cmValue v = this->GetOptionIfSet("CPACK_NSIS_MUI_UNIICON")) { std::string iconFile = cmSystemTools::ConvertToWindowsOutputPath(*v); - installerIconCode += cmStrCat("!define MUI_UNICON ", iconFile, '\n'); + installerIconCode = cmStrCat(std::move(installerIconCode), + "!define MUI_UNICON ", iconFile, '\n'); } this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE", installerIconCode.c_str()); @@ -739,7 +741,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( std::string const componentOutputDir = this->CustomComponentInstallDirectory(component->Name); - componentCode += cmStrCat(" SetOutPath \"", componentOutputDir, "\"\n"); + componentCode = cmStrCat(std::move(componentCode), " SetOutPath \"", + componentOutputDir, "\"\n"); // Create the actual installation commands if (component->IsDownloaded) { diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7017c4c1fb..331b0cbff5 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -232,8 +232,8 @@ bool cmCTestMultiProcessHandler::ComputeFixtureRepetition() cmStrCat("Error: the setup and cleanup tests of fixture \"", fi.first, "\" request conflicting FIXTURE_REPEAT_MODE values:\n"); for (auto const& r : fixture.RequestedModes) { - e += cmStrCat(" \"", this->GetName(r.second), "\" requests ", - FixtureRepeatModeString(r.first), '\n'); + e = cmStrCat(std::move(e), " \"", this->GetName(r.second), + "\" requests ", FixtureRepeatModeString(r.first), '\n'); } e += "All setup and cleanup tests of a fixture must request the same " "mode.\n"; @@ -263,8 +263,8 @@ bool cmCTestMultiProcessHandler::ComputeFixtureRepetition() "\" takes part in fixtures with conflicting " "FIXTURE_REPEAT_MODE values:\n"); for (auto const& m : modes) { - e += cmStrCat(" fixture \"", m.second, "\" uses ", - FixtureRepeatModeString(m.first), '\n'); + e = cmStrCat(std::move(e), " fixture \"", m.second, "\" uses ", + FixtureRepeatModeString(m.first), '\n'); } e += "Fixtures that share a test must use the same mode.\n"; cmCTestLog(this->CTest, ERROR_MESSAGE, e); diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 2e59c04d8d..b568d6eeb9 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -957,7 +957,7 @@ void cmCTestRunTest::SetupResourcesEnvironment(cmEnvironment& env) var += ';'; } firstName = false; - var += cmStrCat("id:", it2.Id, ",slots:", it2.Slots); + var = cmStrCat(std::move(var), "id:", it2.Id, ",slots:", it2.Slots); } env.PutEnv(var); } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d7073e92f9..2160e75e0e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1110,18 +1110,18 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const if (setupRegExp.empty()) { setupRegExp = this->TestOptions.ExcludeFixtureSetupRegularExpression; } else { - setupRegExp.append( - cmStrCat('(', setupRegExp, ")|(", - this->TestOptions.ExcludeFixtureSetupRegularExpression, ')')); + setupRegExp = + cmStrCat(setupRegExp, '(', setupRegExp, ")|(", + this->TestOptions.ExcludeFixtureSetupRegularExpression, ')'); } } if (!this->TestOptions.ExcludeFixtureCleanupRegularExpression.empty()) { if (cleanupRegExp.empty()) { cleanupRegExp = this->TestOptions.ExcludeFixtureCleanupRegularExpression; } else { - cleanupRegExp.append(cmStrCat( - '(', cleanupRegExp, ")|(", - this->TestOptions.ExcludeFixtureCleanupRegularExpression, ')')); + cleanupRegExp = cmStrCat( + cleanupRegExp, '(', cleanupRegExp, ")|(", + this->TestOptions.ExcludeFixtureCleanupRegularExpression, ')'); } } cmsys::RegularExpression excludeSetupRegex(setupRegExp); diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx index 3b668e057a..6b7f9a4214 100644 --- a/Source/cmCMakeLanguageCommand.cxx +++ b/Source/cmCMakeLanguageCommand.cxx @@ -493,9 +493,9 @@ bool cmCMakeLanguageCommandPRINT_TARGETS( continue; } } - lines += - cmStrCat(" ", t.first, " (", cmState::GetTargetTypeName(t.second.Type), - t.second.Imported ? ", IMPORTED" : "", ")\n"); + lines = cmStrCat(std::move(lines), " ", t.first, " (", + cmState::GetTargetTypeName(t.second.Type), + t.second.Imported ? ", IMPORTED" : "", ")\n"); anyMatched = true; } @@ -509,13 +509,13 @@ bool cmCMakeLanguageCommandPRINT_TARGETS( } else if (parsedArgs.NoImported) { label = "Non-imported targets"; } - out += cmStrCat(' ', label); + out = cmStrCat(std::move(out), ' ', label); if (parsedArgs.Regex) { - out += cmStrCat( - " matching REGEX '", *parsedArgs.Regex, "' (", + out = cmStrCat( + std::move(out), " matching REGEX '", *parsedArgs.Regex, "' (", parsedArgs.IgnoreCase ? "case insensitive" : "case sensitive", ')'); } - out += cmStrCat(":\n", lines); + out = cmStrCat(std::move(out), ":\n", lines); makefile.DisplayStatus(out, -1); } @@ -567,7 +567,7 @@ void PrintVariablesNamed(cmMakefile& makefile, } first = false; cmValue v = makefile.GetDefinition(name); - msg += cmStrCat(name, "=\"", v ? *v : std::string(), '"'); + msg = cmStrCat(std::move(msg), name, "=\"", v ? *v : std::string(), '"'); } makefile.DisplayStatus(msg, -1); return; @@ -577,9 +577,9 @@ void PrintVariablesNamed(cmMakefile& makefile, for (std::string const& name : names) { cmValue v = makefile.GetDefinition(name); if (v) { - out += cmStrCat(" ", name, " = \"", *v, "\"\n"); + out = cmStrCat(std::move(out), " ", name, " = \"", *v, "\"\n"); } else { - out += cmStrCat(" ", name, " = \n"); + out = cmStrCat(std::move(out), " ", name, " = \n"); } } makefile.DisplayStatus(out, -1); @@ -657,17 +657,18 @@ bool PrintVariablesAll(cmMakefile& makefile, PrintVariablesArgs const& parsed, for (std::string const& name : names) { cmValue regular = snapshot.GetDefinition(name); if (regular && matches(name, *regular)) { - body += cmStrCat(" ", name, " = \"", *regular, "\"\n"); + body = cmStrCat(std::move(body), " ", name, " = \"", *regular, "\"\n"); anyMatched = true; } cmValue cached = state->GetInitializedCacheValue(name); if (cached && matches(name, *cached)) { auto const type = state->GetCacheEntryType(name); - body += cmStrCat(" CACHE{", name, '}'); + body = cmStrCat(std::move(body), " CACHE{", name, '}'); if (type != cmStateEnums::UNINITIALIZED) { - body += cmStrCat(':', cmState::CacheEntryTypeToString(type)); + body = cmStrCat(std::move(body), ':', + cmState::CacheEntryTypeToString(type)); } - body += cmStrCat(" = \"", *cached, "\"\n"); + body = cmStrCat(std::move(body), " = \"", *cached, "\"\n"); anyMatched = true; } } @@ -680,30 +681,30 @@ bool PrintVariablesAll(cmMakefile& makefile, PrintVariablesArgs const& parsed, if (parsed.NameRegex || parsed.ValueRegex) { out += " matching"; if (parsed.NameRegex) { - out += cmStrCat(" name '", *parsed.NameRegex, '\''); + out = cmStrCat(std::move(out), " name '", *parsed.NameRegex, '\''); } if (parsed.NameRegex && parsed.ValueRegex) { out += " and"; } if (parsed.ValueRegex) { - out += cmStrCat(" value '", *parsed.ValueRegex, '\''); + out = cmStrCat(std::move(out), " value '", *parsed.ValueRegex, '\''); } out += parsed.IgnoreCase ? " (case insensitive)" : " (case sensitive)"; } - out += cmStrCat(":\n", body); + out = cmStrCat(std::move(out), ":\n", body); makefile.DisplayStatus(out, -1); } if (!anyMatched && (parsed.NameRegex || parsed.ValueRegex)) { std::string msg = "No variables in scope matching"; if (parsed.NameRegex) { - msg += cmStrCat(" name '", *parsed.NameRegex, '\''); + msg = cmStrCat(std::move(msg), " name '", *parsed.NameRegex, '\''); } if (parsed.NameRegex && parsed.ValueRegex) { msg += " and"; } if (parsed.ValueRegex) { - msg += cmStrCat(" value '", *parsed.ValueRegex, '\''); + msg = cmStrCat(std::move(msg), " value '", *parsed.ValueRegex, '\''); } msg += parsed.IgnoreCase ? " (case insensitive)" : " (case sensitive)"; msg += " in cmake_language(PRINT_VARIABLES ...)."; @@ -836,9 +837,9 @@ std::vector CollectDependentTargets( void WritePropertyLine(std::string& out, std::string const& entityName, std::string const& propertyName, cmValue value) { - out += cmStrCat(" ", entityName, '.', propertyName); + out = cmStrCat(std::move(out), " ", entityName, '.', propertyName); if (value) { - out += cmStrCat(" = \"", *value, '"'); + out = cmStrCat(std::move(out), " = \"", *value, '"'); } else { out += " = "; } @@ -863,22 +864,22 @@ void EmitBlockHeader( cm::optional const& nameRegexStr = cm::nullopt, cm::optional const& valueRegexStr = cm::nullopt) { - out += - cmStrCat(' ', (kind == BlockKind::All ? "All properties" : "Properties"), - " for ", entityType, ' ', entityName); + out = cmStrCat(std::move(out), ' ', + (kind == BlockKind::All ? "All properties" : "Properties"), + " for ", entityType, ' ', entityName); if (suffix == HeaderSuffix::Reachable) { out += " (and all reachable)"; } if (kind == BlockKind::All && (nameRegexStr || valueRegexStr)) { out += " matching"; if (nameRegexStr) { - out += cmStrCat(" name '", *nameRegexStr, '\''); + out = cmStrCat(std::move(out), " name '", *nameRegexStr, '\''); } if (nameRegexStr && valueRegexStr) { out += " and"; } if (valueRegexStr) { - out += cmStrCat(" value '", *valueRegexStr, '\''); + out = cmStrCat(std::move(out), " value '", *valueRegexStr, '\''); } } out += ":\n"; @@ -896,13 +897,13 @@ std::string EmptyMatchWarningMessage( std::string msg = cmStrCat("No properties for ", entityType, ' ', entityName, " matching"); if (nameRegexStr) { - msg += cmStrCat(" name '", *nameRegexStr, '\''); + msg = cmStrCat(std::move(msg), " name '", *nameRegexStr, '\''); } if (nameRegexStr && valueRegexStr) { msg += " and"; } if (valueRegexStr) { - msg += cmStrCat(" value '", *valueRegexStr, '\''); + msg = cmStrCat(std::move(msg), " value '", *valueRegexStr, '\''); } msg += " in cmake_language(PRINT_PROPERTIES ...)."; return msg; @@ -1064,7 +1065,8 @@ bool PrintPropertiesConfigureTime( if (kind == EntityKind::Target) { cmTarget* target = makefile.FindTargetToUse(entityName); if (!target) { - out += cmStrCat("\n No such TARGET \"", entityName, "\" !\n\n"); + out = cmStrCat(std::move(out), "\n No such TARGET \"", entityName, + "\" !\n\n"); anyEmitted = true; continue; } @@ -1140,7 +1142,8 @@ bool PrintTargetPropertiesDeferred( for (std::string const& name : targetNames) { cmGeneratorTarget* root = lg.FindGeneratorTargetToUse(name); if (!root) { - out += cmStrCat("\n No such TARGET \"", name, "\" !\n\n"); + out = + cmStrCat(std::move(out), "\n No such TARGET \"", name, "\" !\n\n"); anyEmitted = true; continue; } diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 4548b5d5d6..690a8d6720 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -272,7 +272,8 @@ LinkLibraryFeatureAttributeSet const& GetLinkLibraryFeatureAttributes( featureAttributes.LibraryTypes.emplace( cm::TargetType::EXECUTABLE); } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = + cmStrCat(std::move(errorMessage), " ", option, '\n'); break; } } @@ -290,7 +291,8 @@ LinkLibraryFeatureAttributeSet const& GetLinkLibraryFeatureAttributes( featureAttributes.Deduplication = LinkLibraryFeatureAttributeSet::Default; } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = + cmStrCat(std::move(errorMessage), " ", option, '\n'); } } else if (processingOption.match(1) == "OVERRIDE") { featureAttributes.Override.clear(); @@ -299,7 +301,7 @@ LinkLibraryFeatureAttributeSet const& GetLinkLibraryFeatureAttributes( featureAttributes.Override.insert(values.begin(), values.end()); } } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = cmStrCat(std::move(errorMessage), " ", option, '\n'); } } if (!errorMessage.empty()) { @@ -403,7 +405,8 @@ public: } else if (processingOption.match(2) == "REVERSE") { this->Order = Reverse; } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = + cmStrCat(std::move(errorMessage), " ", option, '\n'); } } else if (processingOption.match(1) == "UNICITY" || processingOption.match(1) == "DEDUPLICATION") { @@ -414,11 +417,13 @@ public: } else if (processingOption.match(2) == "SHARED") { this->Deduplication = Shared; } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = + cmStrCat(std::move(errorMessage), " ", option, '\n'); } } } else { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = + cmStrCat(std::move(errorMessage), " ", option, '\n'); } } if (!errorMessage.empty()) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index e38c2fcba5..f04f6c7c6e 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -708,7 +708,7 @@ cm::optional cmCoreTryCompile::TryCompileCode( std::string projectLangs; for (std::string const& li : testLangs) { - projectLangs += cmStrCat(' ', li); + projectLangs = cmStrCat(std::move(projectLangs), ' ', li); std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, '_', li); if (cmValue rulesOverridePath = @@ -1090,7 +1090,8 @@ cm::optional cmCoreTryCompile::TryCompileCode( if (arguments.LinkLibraries) { std::string libsToLink = " "; for (std::string const& i : *arguments.LinkLibraries) { - libsToLink += cmStrCat('"', cmTrimWhitespace(i), "\" "); + libsToLink = + cmStrCat(std::move(libsToLink), '"', cmTrimWhitespace(i), "\" "); } fprintf(fout, "target_link_libraries(%s %s)\n", targetName.c_str(), libsToLink.c_str()); diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index b1dba7f2f6..64cf906846 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -3,6 +3,7 @@ #include "cmCreateTestSourceList.h" #include +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -93,8 +94,9 @@ bool cmCreateTestSourceList(std::vector const& args, tests_func_name.end(); tests_func_name.push_back(func_name); if (!already_declared) { - forwardDeclareCode += - cmStrCat("extern int ", func_name, "(int, char*[]);\n"); + forwardDeclareCode = + cmStrCat(std::move(forwardDeclareCode), "extern int ", func_name, + "(int, char*[]);\n"); } } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index b68db1eebc..61bbac1017 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -154,7 +154,8 @@ void Tree::BuildVirtualFolder(cmXMLWriter& xml) const void Tree::BuildVirtualFolderImpl(std::string& virtualFolders, std::string const& prefix) const { - virtualFolders += cmStrCat("CMake Files\\", prefix, this->path, "\\;"); + virtualFolders = cmStrCat(std::move(virtualFolders), "CMake Files\\", prefix, + this->path, "\\;"); for (Tree const& folder : this->folders) { folder.BuildVirtualFolderImpl(virtualFolders, cmStrCat(prefix, this->path, '\\')); diff --git a/Source/cmFastbuildNormalTargetGenerator.cxx b/Source/cmFastbuildNormalTargetGenerator.cxx index 43a95bec97..e47e1e3b62 100644 --- a/Source/cmFastbuildNormalTargetGenerator.cxx +++ b/Source/cmFastbuildNormalTargetGenerator.cxx @@ -435,8 +435,8 @@ void cmFastbuildNormalTargetGenerator::ApplyLWYUToLinkerCommand( std::string args = " -E __run_co_compile --lwyu="; args += this->GetLocalGenerator()->EscapeForShell(*lwyuCheck); - args += cmStrCat( - " --source=", + args = cmStrCat( + std::move(args), " --source=", this->ConvertToFastbuildPath(this->GetGeneratorTarget()->GetFullPath( Config, cmStateEnums::RuntimeBinaryArtifact, /*realname=*/true))); @@ -1946,7 +1946,7 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep( ? FASTBUILD_OBJECTS_ALIAS_POSTFIX : FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX); if (!linkerNode.Arch.empty()) { - dep += cmStrCat('-', linkerNode.Arch); + dep = cmStrCat(std::move(dep), '-', linkerNode.Arch); } // If we have a special way of linking the dep, we can't have it in // ".Libraries" (since there might be multiple such deps, but @@ -2252,8 +2252,9 @@ void cmFastbuildNormalTargetGenerator::AddLipoCommand(FastbuildTarget& target) for (auto const& ArchSpecificTarget : target.LinkerNode) { exec.ExecInput.emplace_back(ArchSpecificTarget.LinkerOutput); } - exec.ExecArguments += cmStrCat("-create -output ", target.RealOutput, ' ', - cmJoin(exec.ExecInput, " ")); + exec.ExecArguments = + cmStrCat(std::move(exec.ExecArguments), "-create -output ", + target.RealOutput, ' ', cmJoin(exec.ExecInput, " ")); target.PostBuildExecNodes.Alias.PreBuildDependencies.emplace( exec.ExecOutput); target.PostBuildExecNodes.Nodes.emplace_back(std::move(exec)); @@ -2375,8 +2376,9 @@ void cmFastbuildNormalTargetGenerator::GenerateLink( this->GetGlobalGenerator()->AddFileToClean(linkerNode.LinkerOutput); target.RealOutput = targetOutputReal; if (!arch.empty()) { - linkerNode.Name += cmStrCat('-', arch); - linkerNode.LinkerOutput += cmStrCat('.', arch); + linkerNode.Name = cmStrCat(std::move(linkerNode.Name), '-', arch); + linkerNode.LinkerOutput = + cmStrCat(std::move(linkerNode.LinkerOutput), '.', arch); linkerNode.Arch = arch; } linkerNode.Linker = executable; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index b07edd6798..c9f4b3742e 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -221,12 +221,14 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) if (this->Names.empty()) { this->VariableDocumentation += "the (unknown) library be found"; } else if (this->Names.size() == 1) { - this->VariableDocumentation += - cmStrCat("the ", this->Names.front(), " library be found"); + this->VariableDocumentation = + cmStrCat(std::move(this->VariableDocumentation), "the ", + this->Names.front(), " library be found"); } else { - this->VariableDocumentation += cmStrCat( - "one of the ", cmJoin(cmMakeRange(this->Names).retreat(1), ", "), - " or ", this->Names.back(), " libraries be found"); + this->VariableDocumentation = + cmStrCat(std::move(this->VariableDocumentation), "one of the ", + cmJoin(cmMakeRange(this->Names).retreat(1), ", "), " or ", + this->Names.back(), " libraries be found"); } } @@ -698,30 +700,28 @@ void cmFindBaseDebugState::WriteDebug() const buffer += " NO_DEFAULT_PATH Enabled\n"; } else { // clang-format off - buffer += cmStrCat( - " CMAKE_FIND_USE_CMAKE_PATH: ", !this->FindCommand->NoCMakePath, - "\n CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ", !this->FindCommand->NoCMakeEnvironmentPath, - "\n CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ", !this->FindCommand->NoSystemEnvironmentPath, - "\n CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ", !this->FindCommand->NoCMakeSystemPath, - "\n CMAKE_FIND_USE_INSTALL_PREFIX: ", !this->FindCommand->NoCMakeInstallPath, - '\n' - ); + buffer = cmStrCat(std::move(buffer), " CMAKE_FIND_USE_CMAKE_PATH: ", !this->FindCommand->NoCMakePath, + "\n CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ", !this->FindCommand->NoCMakeEnvironmentPath, + "\n CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ", !this->FindCommand->NoSystemEnvironmentPath, + "\n CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ", !this->FindCommand->NoCMakeSystemPath, + "\n CMAKE_FIND_USE_INSTALL_PREFIX: ", !this->FindCommand->NoCMakeInstallPath, + '\n'); // clang-format on } - buffer += - cmStrCat(this->CommandName, " considered the following locations:\n"); + buffer = cmStrCat(std::move(buffer), this->CommandName, + " considered the following locations:\n"); for (auto const& state : this->FailedSearchLocations) { std::string path = cmStrCat(" ", state.path); if (!state.regexName.empty()) { path = cmStrCat(std::move(path), '/', state.regexName); } - buffer += cmStrCat(path, '\n'); + buffer = cmStrCat(std::move(buffer), path, '\n'); } if (this->HasBeenFound()) { - buffer += cmStrCat("The item was found at\n ", - this->FoundSearchLocation.path, '\n'); + buffer = cmStrCat(std::move(buffer), "The item was found at\n ", + this->FoundSearchLocation.path, '\n'); } else { buffer += "The item was not found.\n"; } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 4b6904b82a..c2cfbd0146 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -89,7 +89,7 @@ std::size_t collectPathsForDebug(std::string& buffer, return 0; } for (auto i = startIndex; i < paths.size(); i++) { - buffer += cmStrCat(" ", paths[i].Path, '\n'); + buffer = cmStrCat(std::move(buffer), " ", paths[i].Path, '\n'); } return paths.size(); } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 2fd2df24a4..fee038d242 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -213,7 +213,7 @@ static std::string extractAllGeneratorExpressions( } std::string::size_type const traversed = (c - cStart) + 1; if (!*c) { - result += cmStrCat("$<", input.substr(pos, traversed)); + result = cmStrCat(std::move(result), "$<", input.substr(pos, traversed)); } pos += traversed; lastPos = pos; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a15e772665..d03a8145ed 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2900,7 +2900,8 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const if (compiler == "Intel") { cmList targets(arch); if (!targets.empty()) { - flags += cmStrCat(" --target=", cmWrap("", targets, "", ",")); + flags = + cmStrCat(std::move(flags), " --target=", cmWrap("", targets, "", ",")); } } } diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index 5b3d79b035..3138999f26 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -196,7 +196,8 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt, if (uniqueIncludes.insert(entryInclude).second) { includes.emplace_back(entryInclude, entry.Backtrace); if (debugIncludes) { - usedIncludes += cmStrCat(" * ", entryInclude, '\n'); + usedIncludes = + cmStrCat(std::move(usedIncludes), " * ", entryInclude, '\n'); } } } diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index cc56034a1e..259dcd6825 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -76,7 +76,8 @@ void processLinkDirectories(cmGeneratorTarget const* tgt, if (uniqueDirectories.insert(entryDirectory).second) { directories.emplace_back(entryDirectory, entry.Backtrace); if (debugDirectories) { - usedDirectories += cmStrCat(" * ", entryDirectory, '\n'); + usedDirectories = + cmStrCat(std::move(usedDirectories), " * ", entryDirectory, '\n'); } } } diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index 2fee725de7..ba016aa75e 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -82,7 +82,7 @@ void processOptions(cmGeneratorTarget const* tgt, options.emplace_back(opt, entry.Backtrace); } if (debugOptions) { - usedOptions += cmStrCat(" * ", opt, '\n'); + usedOptions = cmStrCat(std::move(usedOptions), " * ", opt, '\n'); } } } diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 58f6b158d2..9a8d55b844 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -161,7 +161,7 @@ bool processSources(cmGeneratorTarget const* tgt, std::string const& config, if (uniqueSrcs.insert(src).second) { srcs.emplace_back(src, entry.Backtrace); if (debugSources) { - usedSources += cmStrCat(" * ", src, '\n'); + usedSources = cmStrCat(std::move(usedSources), " * ", src, '\n'); } } else { auto const& fileSets = diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 71ca5f8180..0d24fa209a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -278,14 +278,16 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, // Write explicit dependencies. for (std::string const& explicitDep : build.ExplicitDeps) { - arguments += cmStrCat(' ', this->EncodePath(explicitDep)); + arguments = + cmStrCat(std::move(arguments), ' ', this->EncodePath(explicitDep)); } // Write implicit dependencies. if (!build.ImplicitDeps.empty()) { arguments += " |"; for (std::string const& implicitDep : build.ImplicitDeps) { - arguments += cmStrCat(' ', this->EncodePath(implicitDep)); + arguments = + cmStrCat(std::move(arguments), ' ', this->EncodePath(implicitDep)); } } @@ -293,7 +295,8 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, if (!build.OrderOnlyDeps.empty()) { arguments += " ||"; for (std::string const& orderOnlyDep : build.OrderOnlyDeps) { - arguments += cmStrCat(' ', this->EncodePath(orderOnlyDep)); + arguments = + cmStrCat(std::move(arguments), ' ', this->EncodePath(orderOnlyDep)); } } @@ -3313,7 +3316,7 @@ void cmGlobalNinjaGenerator::AppendDirectoryForConfig( std::string const& suffix, std::string& dir) { if (!config.empty() && this->IsMultiConfig()) { - dir += cmStrCat(prefix, config, suffix); + dir = cmStrCat(std::move(dir), prefix, config, suffix); } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0c891ffa44..7712944a56 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -225,7 +225,7 @@ void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig( std::string const& suffix, std::string& dir) { if (!config.empty()) { - dir += cmStrCat(prefix, config, suffix); + dir = cmStrCat(std::move(dir), prefix, config, suffix); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 1ba4181bde..1abc655414 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2726,7 +2726,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::set defines(targetSwiftDefines.begin(), targetSwiftDefines.end()); this->CurrentLocalGenerator->JoinDefines(defines, defineString, "Swift"); - cflags["Swift"] += cmStrCat(' ', defineString); + cflags["Swift"] = + cmStrCat(std::move(cflags["Swift"]), ' ', defineString); } else { BuildObjectListOrString swiftDefs(this, true); this->AppendDefines(swiftDefs, targetSwiftDefines); @@ -3108,7 +3109,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, includes, gtgt, language, configName); if (!includeFlags.empty()) { - cflags[language] += cmStrCat(' ', includeFlags); + cflags[language] = + cmStrCat(std::move(cflags[language]), ' ', includeFlags); } } } diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index d8cd30c6ee..b69d2f615e 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -145,8 +145,8 @@ void cmLinkLineComputer::ComputeLinkPath( type = cmStateEnums::ImportLibraryArtifact; } - linkPathNoBT += - cmStrCat(' ', libPathFlag, + linkPathNoBT = + cmStrCat(std::move(linkPathNoBT), ' ', libPathFlag, this->ConvertToOutputForExisting( item.Target->GetDirectory(cli.GetConfig(), type)), libPathTerminator, ' '); @@ -210,8 +210,8 @@ std::string cmLinkLineComputer::ComputeFrameworkPath( std::string frameworkPath; for (auto const& fd : cli.GetFrameworkPaths()) { - frameworkPath += - cmStrCat(fwSearchFlag, this->ConvertToOutputFormat(fd), ' '); + frameworkPath = cmStrCat(std::move(frameworkPath), fwSearchFlag, + this->ConvertToOutputFormat(fd), ' '); } return frameworkPath; } diff --git a/Source/cmList.cxx b/Source/cmList.cxx index 16e43a5516..abcd5d575d 100644 --- a/Source/cmList.cxx +++ b/Source/cmList.cxx @@ -1139,7 +1139,7 @@ std::string& cmList::append(std::string& list, std::string&& value) if (list.empty()) { list = std::move(value); } else { - list += cmStrCat(cmList::element_separator, value); + list = cmStrCat(std::move(list), cmList::element_separator, value); } return list; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4d1a0d6434..3649ddd77f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3819,7 +3819,7 @@ void cmLocalGenerator::AppendWarningAsErrorLinkerFlags( std::string errorMessage; for (auto const& option : wErrorOptions) { if (option != "DRIVER"_s && option != "LINKER"_s) { - errorMessage += cmStrCat(" ", option, '\n'); + errorMessage = cmStrCat(std::move(errorMessage), " ", option, '\n'); continue; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 81b2f1b1d9..e5198f0891 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -440,7 +440,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript( scriptPath += '/'; scriptPath += customStep; if (this->GlobalGenerator->IsMultiConfig()) { - scriptPath += cmStrCat('-', commandConfig); + scriptPath = cmStrCat(std::move(scriptPath), '-', commandConfig); } #ifdef _WIN32 scriptPath += ".bat"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d21e007224..d22e1e0d44 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -317,12 +317,12 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& rootVar, cmValue rootDef, if ((rootDef || rootEnv) && this->WarnedCMP0074.insert(rootVar).second) { std::string e; if (rootDef) { - e += cmStrCat("CMake variable ", rootVar, " is set to:\n ", *rootDef, - '\n'); + e = cmStrCat(std::move(e), "CMake variable ", rootVar, " is set to:\n ", + *rootDef, '\n'); } if (rootEnv) { - e += cmStrCat("Environment variable ", rootVar, " is set to:\n ", - *rootEnv, '\n'); + e = cmStrCat(std::move(e), "Environment variable ", rootVar, + " is set to:\n ", *rootEnv, '\n'); } e += "For compatibility, CMake is ignoring the variable."; this->IssuePolicyWarning(cmPolicies::CMP0074, {}, e); @@ -336,12 +336,12 @@ void cmMakefile::MaybeWarnCMP0144(std::string const& rootVar, cmValue rootDef, if ((rootDef || rootEnv) && this->WarnedCMP0144.insert(rootVar).second) { std::string e; if (rootDef) { - e += cmStrCat("CMake variable ", rootVar, " is set to:\n ", *rootDef, - '\n'); + e = cmStrCat(std::move(e), "CMake variable ", rootVar, " is set to:\n ", + *rootDef, '\n'); } if (rootEnv) { - e += cmStrCat("Environment variable ", rootVar, " is set to:\n ", - *rootEnv, '\n'); + e = cmStrCat(std::move(e), "Environment variable ", rootVar, + " is set to:\n ", *rootEnv, '\n'); } e += "For compatibility, find_package is ignoring the variable, but " "code in a .cmake module might still use it."; @@ -1186,15 +1186,15 @@ cmTarget* cmMakefile::GetCustomCommandTarget( std::string e; if (cmTarget const* t = this->FindTargetToUse(target)) { if (t->IsImported()) { - e += cmStrCat("TARGET '", target, - "' is IMPORTED and does not build here."); + e = cmStrCat(std::move(e), "TARGET '", target, + "' is IMPORTED and does not build here."); } else { - e += - cmStrCat("TARGET '", target, "' was not created in this directory."); + e = cmStrCat(std::move(e), "TARGET '", target, + "' was not created in this directory."); } } else { - e += cmStrCat("No TARGET '", target, - "' has been created in this directory."); + e = cmStrCat(std::move(e), "No TARGET '", target, + "' has been created in this directory."); } this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e, lfbt); return nullptr; @@ -2725,7 +2725,7 @@ void cmMakefile::IssueCMP0219Warning( if (!oldArgs.empty()) { oldArgs += '\n'; } - oldArgs += cmStrCat(" \"", arg, '"'); + oldArgs = cmStrCat(std::move(oldArgs), " \"", arg, '"'); } std::string newArgs = oldArgs; @@ -2961,10 +2961,11 @@ MessageType cmMakefile::ExpandVariablesInStringImpl( if (!openstack.empty() && !(cmsysString_isalnum(inc) || inc == '_' || inc == '/' || inc == '.' || inc == '+' || inc == '-')) { - errorstr += cmStrCat("Invalid character ('", inc); + errorstr = + cmStrCat(std::move(errorstr), "Invalid character ('", inc); result.append(last, in - last); - errorstr += cmStrCat("') in a variable name: '", - result.substr(openstack.back().loc), '\''); + errorstr = cmStrCat(std::move(errorstr), "') in a variable name: '", + result.substr(openstack.back().loc), '\''); mtype = MessageType::FATAL_ERROR; error = true; } @@ -2986,7 +2987,7 @@ MessageType cmMakefile::ExpandVariablesInStringImpl( // This filename and line number may be more specific than the // command context because one command invocation can have // arguments on multiple lines. - e += cmStrCat("at\n ", filename, ':', line, '\n'); + e = cmStrCat(std::move(e), "at\n ", filename, ':', line, '\n'); } errorstr = cmStrCat(e, "when parsing string\n ", source, '\n', std::move(errorstr)); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index dccc6cf116..f33a554f25 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -618,7 +618,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL), " -E __run_co_compile --lwyu="); cmakeCommand += this->LocalGenerator->EscapeForShell(*lwyuCheck); - cmakeCommand += cmStrCat(" --source=", targetOutPathReal); + cmakeCommand = + cmStrCat(std::move(cmakeCommand), " --source=", targetOutPathReal); real_link_commands.push_back(std::move(cmakeCommand)); } } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 89d970aa99..8d8ce49483 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -953,7 +953,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL), " -E __run_co_compile --lwyu="); cmakeCommand += this->LocalGenerator->EscapeForShell(*lwyuCheck); - cmakeCommand += cmStrCat(" --source=", targetOutPathReal); + cmakeCommand = + cmStrCat(std::move(cmakeCommand), " --source=", targetOutPathReal); real_link_commands.push_back(std::move(cmakeCommand)); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6cde10fb22..953f06c7b3 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1174,17 +1174,18 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // compiler must be launched through a wrapper to pick-up dependencies std::string depFilter = "$(CMAKE_COMMAND) -E cmake_cl_compile_depends "; - depFilter += cmStrCat("--dep-file=", shellDependencyFile); - depFilter += - cmStrCat(" --working-dir=", + depFilter = + cmStrCat(std::move(depFilter), "--dep-file=", shellDependencyFile); + depFilter = + cmStrCat(std::move(depFilter), " --working-dir=", this->LocalGenerator->ConvertToOutputFormat( this->LocalGenerator->GetCurrentBinaryDirectory(), cmOutputConverter::SHELL)); auto const& prefix = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_CL_SHOWINCLUDES_PREFIX")); - depFilter += cmStrCat(" --filter-prefix=", - this->LocalGenerator->ConvertToOutputFormat( - prefix, cmOutputConverter::SHELL)); + depFilter = cmStrCat(std::move(depFilter), " --filter-prefix=", + this->LocalGenerator->ConvertToOutputFormat( + prefix, cmOutputConverter::SHELL)); depFilter += " -- "; compileCommands.front().insert(0, depFilter); } @@ -1698,7 +1699,8 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule( std::string const cubin = cmStrCat(objectDir, "sm_", architecture, ".cubin"); - profiles += cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); + profiles = cmStrCat(std::move(profiles), " -im=profile=sm_", architecture, + ",file=", cubin); fatbinaryDepends.emplace_back(cubin); std::string command = cmStrCat( @@ -2310,8 +2312,9 @@ void cmMakefileTargetGenerator::CreateObjectLists( std::string objects_rsp = this->CreateResponseFile( responseFileName, object_strings[i], makefile_depends, linkLanguage); - buildObjs += - cmStrCat(sep, // Separate from previous response file references. + buildObjs = + cmStrCat(std::move(buildObjs), + sep, // Separate from previous response file references. responseFlag, // Reference the response file. this->LocalGenerator->ConvertToOutputFormat( objects_rsp, cmOutputConverter::SHELL)); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6ed3aabf67..bdba437768 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -771,7 +771,8 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd( this->ConvertToNinjaPath(this->GetGeneratorTarget()->GetFullPath( config, cmStateEnums::RuntimeBinaryArtifact, /*realname=*/true)); - cmakeCommand += cmStrCat(" --source=", targetOutputReal); + cmakeCommand = + cmStrCat(std::move(cmakeCommand), " --source=", targetOutputReal); linkCmds.push_back(std::move(cmakeCommand)); } } @@ -944,8 +945,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatements( "--register-link-binaries=", ninjaOutputDir, "/cmake_cuda_register.h"); } - fatbinary.Variables["PROFILES"] += - cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); + fatbinary.Variables["PROFILES"] = + cmStrCat(std::move(fatbinary.Variables["PROFILES"]), " -im=profile=sm_", + architecture, ",file=", cubin); fatbinary.ExplicitDeps.emplace_back(cubin); globalGen->WriteBuild(this->GetCommonFileStream(), dlink); @@ -1401,8 +1403,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( std::string rspPath = cmStrCat(this->GeneratorTarget->GetSupportDirectory(), configDir, "/CXXInterfaceObjects.rsp"); - vars["LINK_FLAGS"] += cmStrCat( - " @", + vars["LINK_FLAGS"] = cmStrCat( + std::move(vars["LINK_FLAGS"]), " @", this->GetLocalGenerator()->ConvertToOutputFormat( this->ConvertToNinjaPath(rspPath), cmOutputConverter::SHELL)); linkBuild.ImplicitDeps.emplace_back(this->ConvertToNinjaPath(rspPath)); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index be70d89db1..b4e8da3401 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -555,7 +555,7 @@ std::string cmNinjaTargetGenerator::GetTargetFilePath( if (path.empty() || path == ".") { return name; } - path += cmStrCat('/', name); + path = cmStrCat(std::move(path), '/', name); return path; } @@ -920,7 +920,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang, // source if that was performed). std::string ddModmapArg; if (!modmapFormat.empty()) { - ddModmapArg += cmStrCat(" --modmapfmt=", modmapFormat); + ddModmapArg = + cmStrCat(std::move(ddModmapArg), " --modmapfmt=", modmapFormat); } { std::vector ddCmds; @@ -984,7 +985,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang, if (!depfileFlags.empty()) { rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), depfileFlags, vars); - flags += cmStrCat(' ', depfileFlags); + flags = cmStrCat(std::move(flags), ' ', depfileFlags); } } @@ -993,7 +994,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang, mf->GetRequiredDefinition(cmStrCat("CMAKE_", lang, "_MODULE_MAP_FLAG")); cmSystemTools::ReplaceString(modmapFlags, "", "$DYNDEP_MODULE_MAP_FILE"); - flags += cmStrCat(' ', modmapFlags); + flags = cmStrCat(std::move(flags), ' ', modmapFlags); } vars.Flags = flags.c_str(); @@ -2614,7 +2615,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( // corresponding file path. cmSystemTools::ReplaceString(modmapFlags, "", cmStrCat(objectFileName, ".modmap")); - fullFlags += cmStrCat(' ', modmapFlags); + fullFlags = cmStrCat(std::move(fullFlags), ' ', modmapFlags); } } diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 40e07a4388..2fcaca295c 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -347,10 +347,10 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile, error = cmStrCat("The rcc list process failed for ", Quoted(qrcFile), '\n'); if (!rccStdOut.empty()) { - error += cmStrCat(rccStdOut, '\n'); + error = cmStrCat(std::move(error), rccStdOut, '\n'); } if (!rccStdErr.empty()) { - error += cmStrCat(rccStdErr, '\n'); + error = cmStrCat(std::move(error), rccStdErr, '\n'); } return false; } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index e47713a21f..dafb45c87a 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -961,7 +961,7 @@ bool cmQtAutoGenInitializer::InitRcc() this->GenTarget->GetSafeProperty(kw.AUTORCC_OPTIONS); std::string const nozstd = "--no-zstd"; if (rccOptions.find(nozstd) == std::string::npos) { - rccOptions.append(cmStrCat(';', nozstd, ';')); + rccOptions = cmStrCat(std::move(rccOptions), ';', nozstd, ';'); } this->GenTarget->Target->SetProperty(kw.AUTORCC_OPTIONS, rccOptions); } @@ -1251,7 +1251,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() } std::string files; for (MUFile const* muf : this->AutogenTarget.FilesGenerated) { - files += cmStrCat(" ", Quoted(muf->FullPath), '\n'); + files = cmStrCat(std::move(files), " ", Quoted(muf->FullPath), '\n'); } this->Makefile->IssuePolicyWarning( cmPolicies::CMP0071, {}, @@ -1281,7 +1281,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() } std::string files; for (cmSourceFile const* sf : this->AutogenTarget.CMP0100HeadersWarn) { - files += cmStrCat(" ", Quoted(sf->GetFullPath()), '\n'); + files = + cmStrCat(std::move(files), " ", Quoted(sf->GetFullPath()), '\n'); } this->Makefile->IssuePolicyWarning( cmPolicies::CMP0100, {}, @@ -1349,7 +1350,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Replace '-' with '_'. The former is not valid for symbol names. std::replace(name.begin(), name.end(), '-', '_'); if (!qrc.Unique) { - name += cmStrCat('_', qrc.QrcPathChecksum); + name = cmStrCat(std::move(name), '_', qrc.QrcPathChecksum); } std::vector nameOpts; nameOpts.emplace_back("-name"); @@ -1899,7 +1900,7 @@ bool cmQtAutoGenInitializer::InitRccTargets() { ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName); if (!qrc.Unique) { - ccName += cmStrCat('_', qrc.QrcPathChecksum); + ccName = cmStrCat(std::move(ccName), '_', qrc.QrcPathChecksum); } cc->SetByproducts(ccOutput); diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 124692ae04..b1beb7acf3 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -3,6 +3,7 @@ #include "cmQtAutoGenerator.h" #include +#include #include @@ -105,9 +106,10 @@ void cmQtAutoGenerator::Logger::ErrorCommand( std::string msg = cmStrCat( '\n', HeadLine(cmStrCat(GeneratorName(genType), " subprocess error")), message, cmHasSuffix(message, '\n') ? "\n" : "\n\n"); - msg += cmStrCat(HeadLine("Command"), QuotedCommand(command), "\n\n"); - msg += cmStrCat(HeadLine("Output"), output, - cmHasSuffix(output, '\n') ? "\n" : "\n\n"); + msg = cmStrCat(std::move(msg), HeadLine("Command"), QuotedCommand(command), + "\n\n"); + msg = cmStrCat(std::move(msg), HeadLine("Output"), output, + cmHasSuffix(output, '\n') ? "\n" : "\n\n"); { std::lock_guard lock(this->Mutex_); cmSystemTools::Stderr(msg); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 024f2db849..65243ba82b 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1576,7 +1576,8 @@ bool cmQtAutoMocUicT::JobEvalCacheMocT::RegisterIncluded( std::string files = cmStrCat(" ", this->MessagePath(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { - files += cmStrCat(" ", this->MessagePath(item->FileName), '\n'); + files = cmStrCat(std::move(files), " ", + this->MessagePath(item->FileName), '\n'); } this->LogError( GenT::MOC, @@ -1772,7 +1773,8 @@ bool cmQtAutoMocUicT::JobEvalCacheUicT::RegisterMapping( std::string files = cmStrCat(" ", this->MessagePath(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { - files += cmStrCat(" ", this->MessagePath(item->FileName), '\n'); + files = cmStrCat(std::move(files), " ", + this->MessagePath(item->FileName), '\n'); } this->LogError( GenT::UIC, @@ -2194,7 +2196,8 @@ void cmQtAutoMocUicT::JobCompileMocT::Process() if (!this->Mapping->IncluderFiles.empty()) { includers = "included by\n"; for (auto const& item : this->Mapping->IncluderFiles) { - includers += cmStrCat(" ", this->MessagePath(item->FileName), '\n'); + includers = cmStrCat(std::move(includers), " ", + this->MessagePath(item->FileName), '\n'); } } this->LogCommandError(GenT::MOC, @@ -2265,7 +2268,8 @@ void cmQtAutoMocUicT::JobCompileUicT::Process() // Uic command failed std::string includers; for (auto const& item : this->Mapping->IncluderFiles) { - includers += cmStrCat(" ", this->MessagePath(item->FileName), '\n'); + includers = cmStrCat(std::move(includers), " ", + this->MessagePath(item->FileName), '\n'); } this->LogCommandError(GenT::UIC, cmStrCat("The uic process failed to compile\n ", @@ -3069,7 +3073,7 @@ bool cmQtAutoMocUicT::SettingsFileWrite() auto SettingAppend = [&content](cm::string_view key, cm::string_view value) { if (!value.empty()) { - content += cmStrCat(key, ':', value, '\n'); + content = cmStrCat(std::move(content), key, ':', value, '\n'); } }; SettingAppend("moc", this->SettingsStringMoc_); diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index 5540e8f07b..fdda4f225a 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -3,6 +3,7 @@ #include "cmSeparateArgumentsCommand.h" #include +#include #include #include @@ -116,7 +117,7 @@ bool cmSeparateArgumentsCommand(std::vector const& args, } if (!program.empty()) { - program += cmStrCat(';', programArgs); + program = cmStrCat(std::move(program), ';', programArgs); } status.GetMakefile().AddDefinition(var, program); diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index e6e0a56be5..f803adb43d 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -3,6 +3,7 @@ #include "cmTargetIncludeDirectoriesCommand.h" #include +#include #include @@ -51,9 +52,9 @@ std::string TargetIncludeDirectoriesImpl::Join( for (std::string const& it : content) { if (cmSystemTools::FileIsFullPath(it) || cmGeneratorExpression::Find(it) == 0) { - dirs += cmStrCat(sep, it); + dirs = cmStrCat(std::move(dirs), sep, it); } else { - dirs += cmStrCat(sep, prefix, it); + dirs = cmStrCat(std::move(dirs), sep, prefix, it); } sep = ";"; } diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 13b0981c3c..d873d156c2 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -3,6 +3,7 @@ #include "cmTryRunCommand.h" #include +#include #include #include @@ -273,7 +274,8 @@ void TryRunCommandImpl::RunExecutable(std::string const& runArgs, this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR"); if (!emulator.empty()) { cmList emulatorWithArgs{ emulator }; - finalCommand += cmStrCat( + finalCommand = cmStrCat( + std::move(finalCommand), cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]), ' ', cmWrap("\"", cmMakeRange(emulatorWithArgs).advance(1), "\"", " "), ' '); } @@ -444,8 +446,8 @@ void TryRunCommandImpl::DoNotRunExecutable( "enter \"FAILED_TO_RUN\".\n"); if (stdOut || stdErr) { if (stdOut) { - comment += cmStrCat( - internalRunOutputStdOutName, + comment = cmStrCat( + std::move(comment), internalRunOutputStdOutName, "\n contains the text the executable would have printed on " "stdout.\n" " If the executable would not have been able to run, set ", @@ -457,8 +459,8 @@ void TryRunCommandImpl::DoNotRunExecutable( "called with the given arguments.\n"); } if (stdErr) { - comment += cmStrCat( - internalRunOutputStdErrName, + comment = cmStrCat( + std::move(comment), internalRunOutputStdErrName, "\n contains the text the executable would have printed on " "stderr.\n" " If the executable would not have been able to run, set ", @@ -470,8 +472,8 @@ void TryRunCommandImpl::DoNotRunExecutable( "called with the given arguments.\n"); } } else if (out) { - comment += cmStrCat( - internalRunOutputName, + comment = cmStrCat( + std::move(comment), internalRunOutputName, "\n contains the text the executable would have printed on stdout " "and stderr.\n" " If the executable would not have been able to run, set ", @@ -483,19 +485,20 @@ void TryRunCommandImpl::DoNotRunExecutable( "called with the given arguments.\n"); } - comment += - cmStrCat("The ", compileResultVariable, + comment = + cmStrCat(std::move(comment), "The ", compileResultVariable, " variable holds the build result for this try_run().\n\n"); if (srcFile) { - comment += cmStrCat("Source file : ", *srcFile, '\n'); + comment = + cmStrCat(std::move(comment), "Source file : ", *srcFile, '\n'); } - comment += cmStrCat("Executable : ", copyDest, - "\n" - "Run arguments : ", - runArgs, - "\n" - " Called from: ", - this->Makefile->FormatListFileStack()); + comment = cmStrCat(std::move(comment), "Executable : ", copyDest, + "\n" + "Run arguments : ", + runArgs, + "\n" + " Called from: ", + this->Makefile->FormatListFileStack()); cmsys::SystemTools::ReplaceString(comment, "\n", "\n# "); file << comment << "\n\n"; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 812ec26545..e5ce371e6f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3557,7 +3557,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (!clrString.empty()) { clrString = cmStrCat(':', std::move(clrString)); } - flags += cmStrCat(" /clr", clrString); + flags = cmStrCat(std::move(flags), " /clr", clrString); } }