From 1d2f0120bec22a68641795610885917e770a8723 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Sun, 20 Sep 2026 10:06:55 +0300 Subject: [PATCH] Source: Reduce string allocations, part 3 --- .../cmCMakeHostSystemInformationCommand.cxx | 2 +- Source/cmCMakePkgConfigCommand.cxx | 2 +- Source/cmCTest.cxx | 2 +- Source/cmCoreTryCompile.cxx | 4 +-- Source/cmDependsFortran.cxx | 2 +- Source/cmDiscoverTestsCommand.cxx | 4 ++- Source/cmExecuteProcessCommand.cxx | 8 +++--- Source/cmExportBuildCMakeConfigGenerator.cxx | 3 +- Source/cmExportCommand.cxx | 4 +-- Source/cmExportFileGenerator.cxx | 2 +- .../cmExportInstallCMakeConfigGenerator.cxx | 3 +- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmFastbuildNormalTargetGenerator.cxx | 13 +++++---- Source/cmFastbuildTargetGenerator.cxx | 7 +++-- Source/cmFastbuildUtilityTargetGenerator.cxx | 8 +++--- Source/cmFileAPICodemodel.cxx | 6 ++-- Source/cmFileCommand.cxx | 22 +++++++-------- Source/cmFileInstaller.cxx | 5 ++-- Source/cmFortranParserImpl.cxx | 2 +- .../cmGeneratorExpressionEvaluationFile.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 3 +- Source/cmGeneratorTarget.cxx | 28 +++++++++---------- Source/cmGraphVizWriter.cxx | 6 ++-- Source/cmInstallFilesCommand.cxx | 5 ++-- Source/cmInstrumentationCommand.cxx | 4 +-- Source/cmake.cxx | 2 +- Source/cmcmd.cxx | 4 +-- 27 files changed, 82 insertions(+), 73 deletions(-) diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 4e67ba7c99..8a7e6b8b44 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -500,7 +500,7 @@ cm::optional GetDistribValue( std::string vars; for (auto const& kv : *os_release) { auto cmake_var_name = cmStrCat(variable, '_', kv.first); - vars += DELIM[!vars.empty()] + cmake_var_name; + vars = cmStrCat(vars, DELIM[!vars.empty()], cmake_var_name); makefile.AddDefinition(cmake_var_name, kv.second); } return cm::optional(std::move(vars)); diff --git a/Source/cmCMakePkgConfigCommand.cxx b/Source/cmCMakePkgConfigCommand.cxx index e6b1a52e7f..dbbe600b10 100644 --- a/Source/cmCMakePkgConfigCommand.cxx +++ b/Source/cmCMakePkgConfigCommand.cxx @@ -184,7 +184,7 @@ std::vector GetPkgConfSysCflags(cmMakefile& mf) std::string tmp; cmSystemTools::GetEnv(var, tmp); if (!tmp.empty()) { - paths += ";" + tmp; + paths = cmStrCat(paths, ';', tmp); } } }; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 0c0691802c..7c1f40e6c1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -707,7 +707,7 @@ bool cmCTest::OpenOutputFile(std::string const& path, std::string const& name, { std::string testingDir = this->Impl->BinaryDir + "/Testing"; if (!path.empty()) { - testingDir += "/" + path; + testingDir = cmStrCat(testingDir, '/', path); } if (cmSystemTools::FileExists(testingDir)) { if (!cmSystemTools::FileIsDirectory(testingDir)) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7610752650..b240c2907f 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1082,8 +1082,8 @@ cm::optional cmCoreTryCompile::TryCompileCode( if (testLangs.find(LinkerLanguage) == testLangs.end()) { this->Makefile->IssueMessage( MessageType::FATAL_ERROR, - "Linker language '" + LinkerLanguage + - "' must be enabled in project(LANGUAGES)."); + cmStrCat("Linker language '", LinkerLanguage, + "' must be enabled in project(LANGUAGES).")); } fprintf(fout, "set_property(TARGET %s PROPERTY LINKER_LANGUAGE %s)\n", diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index dd5779f436..aa20ff19eb 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -37,7 +37,7 @@ static void cmFortranModuleAppendUpperLower(std::string const& mod, } std::string const& name = mod.substr(0, mod.size() - ext_len); std::string const& ext = mod.substr(mod.size() - ext_len); - mod_upper += cmSystemTools::UpperCase(name) + ext; + mod_upper = cmStrCat(mod_upper, cmSystemTools::UpperCase(name), ext); mod_lower += mod; } diff --git a/Source/cmDiscoverTestsCommand.cxx b/Source/cmDiscoverTestsCommand.cxx index dc2e75dcdc..fa102291b0 100644 --- a/Source/cmDiscoverTestsCommand.cxx +++ b/Source/cmDiscoverTestsCommand.cxx @@ -18,6 +18,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmScriptGenerator.h" +#include "cmStringAlgorithms.h" #include "cmTestDiscovery.h" #include "cmTestGenerator.h" @@ -106,7 +107,8 @@ bool cmDiscoverTestsCommand(std::vector const& args, } if (!unparsed.empty()) { - status.SetError(" given unknown argument \"" + unparsed.front() + "\"."); + status.SetError( + cmStrCat(" given unknown argument \"", unparsed.front(), "\".")); return false; } diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 43d4febd33..344bf76469 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -135,8 +135,8 @@ bool cmExecuteProcessCommand(std::vector const& args, return true; } if (!unparsedArguments.empty()) { - status.SetError(" given unknown argument \"" + unparsedArguments.front() + - "\"."); + status.SetError(cmStrCat(" given unknown argument \"", + unparsedArguments.front(), "\".")); return false; } @@ -159,8 +159,8 @@ bool cmExecuteProcessCommand(std::vector const& args, } if (!status.GetMakefile().CanIWriteThisFile(outputFilename)) { - status.SetError("attempted to output into a file: " + outputFilename + - " into a source directory."); + status.SetError(cmStrCat("attempted to output into a file: ", + outputFilename, " into a source directory.")); cmSystemTools::SetFatalErrorOccurred(); return false; } diff --git a/Source/cmExportBuildCMakeConfigGenerator.cxx b/Source/cmExportBuildCMakeConfigGenerator.cxx index 2495754609..f6d43d8fad 100644 --- a/Source/cmExportBuildCMakeConfigGenerator.cxx +++ b/Source/cmExportBuildCMakeConfigGenerator.cxx @@ -41,7 +41,8 @@ bool cmExportBuildCMakeConfigGenerator::GenerateMainFile(std::ostream& os) std::string sep; bool generatedInterfaceRequired = false; auto visitor = [&](cmGeneratorTarget const* te) { - expectedTargets += sep + this->Namespace + te->GetExportName(); + expectedTargets = + cmStrCat(expectedTargets, sep, this->Namespace, te->GetExportName()); sep = " "; generatedInterfaceRequired |= diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 02f463a331..e2dd9a6865 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -507,8 +507,8 @@ static bool HandleSetupMode(std::vector const& args, SetupArguments arguments = parser.Parse(args, &unknownArgs); if (!unknownArgs.empty()) { - status.SetError("SETUP given unknown argument: \"" + unknownArgs.front() + - "\"."); + status.SetError(cmStrCat("SETUP given unknown argument: \"", + unknownArgs.front(), "\".")); return false; } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index c3b0cf8926..3ba8f4d0fe 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -462,7 +462,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( } else { this->ResolveTargetsInGeneratorExpression(li, target, lg); } - input += sep + li; + input = cmStrCat(input, sep, li); sep = ";"; } } diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx index 16b6071c22..ac4615fdb4 100644 --- a/Source/cmExportInstallCMakeConfigGenerator.cxx +++ b/Source/cmExportInstallCMakeConfigGenerator.cxx @@ -49,7 +49,8 @@ bool cmExportInstallCMakeConfigGenerator::GenerateMainFile(std::ostream& os) std::string sep; auto visitor = [&](cmTargetExport const* te) { allTargets.push_back(te); - expectedTargets += sep + this->Namespace + te->Target->GetExportName(); + expectedTargets = cmStrCat(expectedTargets, sep, this->Namespace, + te->Target->GetExportName()); sep = " "; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c71daca1f8..0d9b365694 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -605,7 +605,7 @@ void cmExportInstallFileGenerator::PopulateIncludeDirectoriesInterface( std::string includes = (input ? *input : ""); char const* const sep = input ? ";" : ""; - includes += sep + exportDirs; + includes = cmStrCat(includes, sep, exportDirs); std::string prepro = cmGeneratorExpression::Preprocess( includes, preprocessRule, this->GetImportPrefixWithSlash()); if (!prepro.empty()) { diff --git a/Source/cmFastbuildNormalTargetGenerator.cxx b/Source/cmFastbuildNormalTargetGenerator.cxx index db1640c06f..86479ad0e2 100644 --- a/Source/cmFastbuildNormalTargetGenerator.cxx +++ b/Source/cmFastbuildNormalTargetGenerator.cxx @@ -573,8 +573,8 @@ void cmFastbuildNormalTargetGenerator::ComputePCH( // Reuse compiler options for PCH options. node.PCHOptions += origCompileOptions; - if (this->Makefile->GetSafeDefinition("CMAKE_" + language + - "_COMPILER_ID") == "MSVC") { + if (this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", language, "_COMPILER_ID")) == "MSVC") { cmSystemTools::ReplaceString(node.PCHOptions, FASTBUILD_2_INPUT_PLACEHOLDER, FASTBUILD_3_INPUT_PLACEHOLDER); @@ -1801,8 +1801,9 @@ void cmFastbuildNormalTargetGenerator::AppendExternalObject( else if (target) { if (!linkedDeps.emplace(objLibName + FASTBUILD_OBJECTS_ALIAS_POSTFIX) .second) { - LogMessage("Object Target: " + objLibName + - FASTBUILD_OBJECTS_ALIAS_POSTFIX " already linked"); + LogMessage(cmStrCat("Object Target: ", objLibName, + FASTBUILD_OBJECTS_ALIAS_POSTFIX + " already linked")); continue; } linkerNode.LibrarianAdditionalInputs.emplace_back( @@ -1890,8 +1891,8 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep( // Skip exported objects. // Tested in "ExportImport" test. if (depType == cm::TargetType::OBJECT_LIBRARY) { - LogMessage("target : " + item.Target->GetName() + - " already linked... Skipping"); + LogMessage(cmStrCat("target : ", item.Target->GetName(), + " already linked... Skipping")); return; } // Tested in "ExportImport" test. diff --git a/Source/cmFastbuildTargetGenerator.cxx b/Source/cmFastbuildTargetGenerator.cxx index 2522cc8cd3..8ed16e8286 100644 --- a/Source/cmFastbuildTargetGenerator.cxx +++ b/Source/cmFastbuildTargetGenerator.cxx @@ -157,7 +157,8 @@ std::string cmFastbuildTargetGenerator::GetCustomCommandTargetName( extras += std::to_string(static_cast(step)); cmCryptoHash hash(cmCryptoHash::AlgoSHA256); - targetName += "-" + hash.HashString(extras).substr(0, 14); + targetName = + cmStrCat(targetName, '-', hash.HashString(extras).substr(0, 14)); return targetName; } @@ -674,8 +675,8 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands( execNode.PreBuildDependencies); for (auto const& util : ccg.GetUtilities()) { auto const& utilTargetName = util.Value.first; - LogMessage("Util: " + utilTargetName + - ", cross: " + std::to_string(util.Value.second)); + LogMessage(cmStrCat("Util: ", utilTargetName, + ", cross: ", std::to_string(util.Value.second))); auto* const target = this->Makefile->FindTargetToUse(utilTargetName); if (target && target->IsImported()) { diff --git a/Source/cmFastbuildUtilityTargetGenerator.cxx b/Source/cmFastbuildUtilityTargetGenerator.cxx index 02c9e604cf..90d53651f9 100644 --- a/Source/cmFastbuildUtilityTargetGenerator.cxx +++ b/Source/cmFastbuildUtilityTargetGenerator.cxx @@ -75,8 +75,8 @@ void cmFastbuildUtilityTargetGenerator::Generate() if (target && target->GetType() == cm::TargetType::INTERFACE_LIBRARY) { for (auto const& dep : target->GetUtilities()) { auto const& depName = this->ConvertToFastbuildPath(dep.Value.first); - LogMessage("Transitively propagating iface dep: " + depName + - ", is cross: " + std::to_string(dep.Value.second)); + LogMessage(cmStrCat("Transitively propagating iface dep: ", depName, + ", is cross: ", std::to_string(dep.Value.second))); nonImportedUtils.emplace_back(depName); addUtilDepToTarget(this->ConvertToFastbuildPath(depName)); } @@ -117,8 +117,8 @@ void cmFastbuildUtilityTargetGenerator::Generate() for (auto& exec : GenerateCommands(FastbuildBuildStep::REST).Nodes) { addUtilDepToTarget(exec.Name); for (auto const& dep : TargetDirectDependencies) { - LogMessage("Direct dep " + dep->GetName() + - "-all propagating to CC: " + exec.Name); + LogMessage(cmStrCat("Direct dep ", dep->GetName(), + "-all propagating to CC: ", exec.Name)); // All custom commands from within the target must be executed AFTER all // the target's deps. exec.PreBuildDependencies.emplace(dep->GetName()); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 655dbeddcd..3ee629ec5a 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -316,7 +316,7 @@ std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild) topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory()); std::string hash = hasher.HashString(path); hash.resize(20, '0'); - return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash; + return cmStrCat(gt->GetName(), CMAKE_DIRECTORY_ID_SEP, hash); } struct CompileData @@ -755,7 +755,7 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt, std::replace(safeTargetName.begin(), safeTargetName.end(), ':', '_'); std::string prefix = "target-" + safeTargetName; if (!this->Config.empty()) { - prefix += "-" + this->Config; + prefix = cmStrCat(prefix, '-', this->Config); } Json::Value target = this->FileAPI.MaybeJsonFile(t.Dump(), prefix); target["name"] = gt->GetName(); @@ -856,7 +856,7 @@ Json::Value CodemodelConfig::DumpDirectoryObject(Directory& d) } } if (!this->Config.empty()) { - prefix += "-" + this->Config; + prefix = cmStrCat(prefix, '-', this->Config); } DirectoryObject dir(d.LocalGenerator, this->VersionMajor, this->VersionMinor, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2ebf38c9c5..a333ed8df7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -755,7 +755,7 @@ bool HandleGlobImpl(std::vector const& args, bool recurse, expr = status.GetMakefile().GetCurrentSourceDirectory(); // Handle script mode if (!expr.empty()) { - expr += "/" + *i; + expr = cmStrCat(expr, '/', *i); } else { expr = *i; } @@ -2126,10 +2126,10 @@ bool HandleDownloadCommand(std::vector const& args, std::string dir = cmSystemTools::GetFilenamePath(file); if (!dir.empty() && !cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) { - std::string errstring = "DOWNLOAD error: cannot create directory '" + - dir + - "' - Specify file by full path name and verify that you " - "have directory creation and file write privileges."; + std::string errstring = + cmStrCat("DOWNLOAD error: cannot create directory '", dir, + "' - Specify file by full path name and verify that you " + "have directory creation and file write privileges."); status.SetError(errstring); return false; } @@ -2358,10 +2358,10 @@ bool HandleDownloadCommand(std::vector const& args, if (expectedHash != actualHash) { if (!statusVar.empty() && res == 0) { status.GetMakefile().AddDefinition(statusVar, - "1;HASH mismatch: " - "expected: " + - expectedHash + - " actual: " + actualHash); + cmStrCat("1;HASH mismatch: " + "expected: ", + expectedHash, + " actual: ", actualHash)); } status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n" @@ -3644,8 +3644,8 @@ bool HandleConfigureCommand(std::vector const& args, cmMakefile& makeFile = status.GetMakefile(); if (!makeFile.CanIWriteThisFile(outputFile)) { - cmSystemTools::Error("Attempt to write file: " + outputFile + - " into a source directory."); + cmSystemTools::Error(cmStrCat("Attempt to write file: ", outputFile, + " into a source directory.")); return false; } diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index c03bc682af..8c8f5e39f9 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -447,8 +447,9 @@ bool cmFileInstaller::HandleInstallDestination() if (this->InstallType != cmInstallType_DIRECTORY) { if (!cmSystemTools::FileExists(destination)) { if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) { - std::string errstring = "cannot create directory: " + destination + - ". Maybe need administrative privileges."; + std::string errstring = + cmStrCat("cannot create directory: ", destination, + ". Maybe need administrative privileges."); this->Status.SetError(errstring); return false; } diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 08dab98326..57138f07d0 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -82,7 +82,7 @@ std::string cmFortranParser_s::SModName(std::string const& mod_name, if (this->Compiler.SModSep.empty()) { return sub_name + SModExt; } - return mod_name + this->Compiler.SModSep + sub_name + SModExt; + return cmStrCat(mod_name, this->Compiler.SModSep, sub_name, SModExt); } bool cmFortranParser_FilePush(cmFortranParser* parser, char const* fname) diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 733d986e98..ff01403eeb 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -167,7 +167,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) std::string line; std::string sep; while (cmSystemTools::GetLineFromStream(fin, line)) { - inputContent += sep + line; + inputContent = cmStrCat(inputContent, sep, line); sep = "\n"; } inputContent += sep; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 70002d67bb..51ebc560e7 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -4834,7 +4834,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode std::string linkedTargetsContent = getLinkedTargetsContent( target, interfacePropertyName, eval, &dagChecker, usage); if (!linkedTargetsContent.empty()) { - result += (result.empty() ? "" : ";") + linkedTargetsContent; + result = + cmStrCat(result, (result.empty() ? "" : ";"), linkedTargetsContent); } } return result; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bdc7a273a7..62d3a2137c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1326,7 +1326,7 @@ std::string cmGeneratorTarget::GetCompilePDBName( *config_name, this->LocalGenerator, config, this); NameComponents const& components = GetFullNameInternalComponents( config, cmStateEnums::RuntimeBinaryArtifact); - return components.prefix + pdbName + ".pdb"; + return cmStrCat(components.prefix, pdbName, ".pdb"); } cmValue name = this->GetProperty("COMPILE_PDB_NAME"); @@ -1335,7 +1335,7 @@ std::string cmGeneratorTarget::GetCompilePDBName( *name, this->LocalGenerator, config, this); NameComponents const& components = GetFullNameInternalComponents( config, cmStateEnums::RuntimeBinaryArtifact); - return components.prefix + pdbName + ".pdb"; + return cmStrCat(components.prefix, pdbName, ".pdb"); } // If the target is PCH-reused or PCH-reuses, we need a stable name for the @@ -3211,8 +3211,8 @@ std::string cmGeneratorTarget::GetPchHeader(std::string const& config, generatorTarget = reuseTarget; } - auto const inserted = - this->PchHeaders.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchHeaders.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::vector> const headers = this->GetPrecompileHeaders(config, language); @@ -3305,8 +3305,8 @@ std::string cmGeneratorTarget::GetPchSource(std::string const& config, language != "OBJCXX") { return std::string(); } - auto const inserted = - this->PchSources.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchSources.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string const pchHeader = this->GetPchHeader(config, language, arch); if (pchHeader.empty()) { @@ -3365,8 +3365,8 @@ std::string cmGeneratorTarget::GetPchFileObject(std::string const& config, language != "OBJCXX") { return std::string(); } - auto const inserted = - this->PchObjectFiles.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchObjectFiles.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string const pchSource = this->GetPchSource(config, language, arch); if (pchSource.empty()) { @@ -3388,8 +3388,8 @@ std::string cmGeneratorTarget::GetPchFile(std::string const& config, std::string const& language, std::string const& arch) { - auto const inserted = - this->PchFiles.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchFiles.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& pchFile = inserted.first->second; @@ -3448,7 +3448,7 @@ std::string cmGeneratorTarget::GetPchCreateCompileOptions( std::string const& arch) { auto const inserted = this->PchCreateCompileOptions.insert( - std::make_pair(language + config + arch, "")); + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& createOptionList = inserted.first->second; @@ -3496,7 +3496,7 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions( std::string const& arch) { auto const inserted = this->PchUseCompileOptions.insert( - std::make_pair(language + config + arch, "")); + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& useOptionList = inserted.first->second; @@ -3944,7 +3944,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( targetNames.Output = components.prefix + targetNames.Base; } else { targetNames.Output = - components.prefix + targetNames.Base + components.suffix; + cmStrCat(components.prefix, targetNames.Base, components.suffix); } // The executable's real name on disk. @@ -3977,7 +3977,7 @@ std::string cmGeneratorTarget::GetFullNameInternal( { NameComponents const& components = this->GetFullNameInternalComponents(config, artifact); - return components.prefix + components.base + components.suffix; + return cmStrCat(components.prefix, components.base, components.suffix); } std::string cmGeneratorTarget::ImportedGetLocation( diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 6d5225fc8c..c48bfc8be7 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -567,7 +567,7 @@ std::string cmGraphVizWriter::ItemNameWithAliases( auto nameWithAliases = itemName; for(auto const& item : items) { - nameWithAliases += "\\n(" + item + ")"; + nameWithAliases = cmStrCat(nameWithAliases, "\\n(" , item , ')'); } return nameWithAliases; @@ -578,10 +578,10 @@ std::string cmGraphVizWriter::GetEdgeStyle(DependencyType dt) std::string style; switch (dt) { case DependencyType::LinkPrivate: - style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_PRIVATE) + " ]"; + style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_PRIVATE, " ]"); break; case DependencyType::LinkInterface: - style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_INTERFACE) + " ]"; + style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_INTERFACE, " ]"); break; default: break; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index d23b3aed54..244330d5cb 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -82,8 +82,9 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, // replace any variables std::string const& temps = *s; if (!cmSystemTools::GetFilenamePath(temps).empty()) { - testf = cmSystemTools::GetFilenamePath(temps) + "/" + - cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; + testf = + cmStrCat(cmSystemTools::GetFilenamePath(temps), '/', + cmSystemTools::GetFilenameWithoutLastExtension(temps), ext); } else { testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; } diff --git a/Source/cmInstrumentationCommand.cxx b/Source/cmInstrumentationCommand.cxx index 48715cec9f..f138e40c43 100644 --- a/Source/cmInstrumentationCommand.cxx +++ b/Source/cmInstrumentationCommand.cxx @@ -146,8 +146,8 @@ bool cmInstrumentationCommand(std::vector const& args, return true; } if (!unparsedArguments.empty()) { - status.SetError("given unknown argument \"" + unparsedArguments.front() + - "\"."); + status.SetError( + cmStrCat("given unknown argument \"", unparsedArguments.front(), "\".")); return false; } int apiVersion; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 39ade85a53..39210f31c5 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -974,7 +974,7 @@ bool cmake::FindPackage(std::vector const& args) lg->GetStateSnapshot().GetDirectory()); lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags, linkFlags, frameworkPath, linkPath, gtgt); - linkLibs = frameworkPath + linkPath + linkLibs; + linkLibs = cmStrCat(frameworkPath, linkPath, linkLibs); printf("%s\n", linkLibs.c_str()); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 77b5771c6d..79aa715cab 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -3400,8 +3400,8 @@ int cmVSLink::LinkNonIncremental() } // Run the manifest tool to embed the final manifest in the binary. - std::string mtOut = "/outputresource:" + this->TargetFile + - (this->Type == 1 ? ";#1" : ";#2"); + std::string mtOut = cmStrCat("/outputresource:", this->TargetFile, + (this->Type == 1 ? ";#1" : ";#2")); return this->RunMT(mtOut, false); }