Source: Reduce string allocations, part 3

This commit is contained in:
AJIOB
2026-09-22 11:37:41 +03:00
parent cb20c5bd89
commit 1d2f0120be
27 changed files with 82 additions and 73 deletions
@@ -500,7 +500,7 @@ cm::optional<std::string> GetDistribValue(
std::string vars; std::string vars;
for (auto const& kv : *os_release) { for (auto const& kv : *os_release) {
auto cmake_var_name = cmStrCat(variable, '_', kv.first); 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); makefile.AddDefinition(cmake_var_name, kv.second);
} }
return cm::optional<std::string>(std::move(vars)); return cm::optional<std::string>(std::move(vars));
+1 -1
View File
@@ -184,7 +184,7 @@ std::vector<std::string> GetPkgConfSysCflags(cmMakefile& mf)
std::string tmp; std::string tmp;
cmSystemTools::GetEnv(var, tmp); cmSystemTools::GetEnv(var, tmp);
if (!tmp.empty()) { if (!tmp.empty()) {
paths += ";" + tmp; paths = cmStrCat(paths, ';', tmp);
} }
} }
}; };
+1 -1
View File
@@ -707,7 +707,7 @@ bool cmCTest::OpenOutputFile(std::string const& path, std::string const& name,
{ {
std::string testingDir = this->Impl->BinaryDir + "/Testing"; std::string testingDir = this->Impl->BinaryDir + "/Testing";
if (!path.empty()) { if (!path.empty()) {
testingDir += "/" + path; testingDir = cmStrCat(testingDir, '/', path);
} }
if (cmSystemTools::FileExists(testingDir)) { if (cmSystemTools::FileExists(testingDir)) {
if (!cmSystemTools::FileIsDirectory(testingDir)) { if (!cmSystemTools::FileIsDirectory(testingDir)) {
+2 -2
View File
@@ -1082,8 +1082,8 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
if (testLangs.find(LinkerLanguage) == testLangs.end()) { if (testLangs.find(LinkerLanguage) == testLangs.end()) {
this->Makefile->IssueMessage( this->Makefile->IssueMessage(
MessageType::FATAL_ERROR, MessageType::FATAL_ERROR,
"Linker language '" + LinkerLanguage + cmStrCat("Linker language '", LinkerLanguage,
"' must be enabled in project(LANGUAGES)."); "' must be enabled in project(LANGUAGES)."));
} }
fprintf(fout, "set_property(TARGET %s PROPERTY LINKER_LANGUAGE %s)\n", fprintf(fout, "set_property(TARGET %s PROPERTY LINKER_LANGUAGE %s)\n",
+1 -1
View File
@@ -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& name = mod.substr(0, mod.size() - ext_len);
std::string const& ext = mod.substr(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; mod_lower += mod;
} }
+3 -1
View File
@@ -18,6 +18,7 @@
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmScriptGenerator.h" #include "cmScriptGenerator.h"
#include "cmStringAlgorithms.h"
#include "cmTestDiscovery.h" #include "cmTestDiscovery.h"
#include "cmTestGenerator.h" #include "cmTestGenerator.h"
@@ -106,7 +107,8 @@ bool cmDiscoverTestsCommand(std::vector<std::string> const& args,
} }
if (!unparsed.empty()) { if (!unparsed.empty()) {
status.SetError(" given unknown argument \"" + unparsed.front() + "\"."); status.SetError(
cmStrCat(" given unknown argument \"", unparsed.front(), "\"."));
return false; return false;
} }
+4 -4
View File
@@ -135,8 +135,8 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
return true; return true;
} }
if (!unparsedArguments.empty()) { if (!unparsedArguments.empty()) {
status.SetError(" given unknown argument \"" + unparsedArguments.front() + status.SetError(cmStrCat(" given unknown argument \"",
"\"."); unparsedArguments.front(), "\"."));
return false; return false;
} }
@@ -159,8 +159,8 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
} }
if (!status.GetMakefile().CanIWriteThisFile(outputFilename)) { if (!status.GetMakefile().CanIWriteThisFile(outputFilename)) {
status.SetError("attempted to output into a file: " + outputFilename + status.SetError(cmStrCat("attempted to output into a file: ",
" into a source directory."); outputFilename, " into a source directory."));
cmSystemTools::SetFatalErrorOccurred(); cmSystemTools::SetFatalErrorOccurred();
return false; return false;
} }
+2 -1
View File
@@ -41,7 +41,8 @@ bool cmExportBuildCMakeConfigGenerator::GenerateMainFile(std::ostream& os)
std::string sep; std::string sep;
bool generatedInterfaceRequired = false; bool generatedInterfaceRequired = false;
auto visitor = [&](cmGeneratorTarget const* te) { auto visitor = [&](cmGeneratorTarget const* te) {
expectedTargets += sep + this->Namespace + te->GetExportName(); expectedTargets =
cmStrCat(expectedTargets, sep, this->Namespace, te->GetExportName());
sep = " "; sep = " ";
generatedInterfaceRequired |= generatedInterfaceRequired |=
+2 -2
View File
@@ -507,8 +507,8 @@ static bool HandleSetupMode(std::vector<std::string> const& args,
SetupArguments arguments = parser.Parse(args, &unknownArgs); SetupArguments arguments = parser.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) { if (!unknownArgs.empty()) {
status.SetError("SETUP given unknown argument: \"" + unknownArgs.front() + status.SetError(cmStrCat("SETUP given unknown argument: \"",
"\"."); unknownArgs.front(), "\"."));
return false; return false;
} }
+1 -1
View File
@@ -462,7 +462,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
} else { } else {
this->ResolveTargetsInGeneratorExpression(li, target, lg); this->ResolveTargetsInGeneratorExpression(li, target, lg);
} }
input += sep + li; input = cmStrCat(input, sep, li);
sep = ";"; sep = ";";
} }
} }
@@ -49,7 +49,8 @@ bool cmExportInstallCMakeConfigGenerator::GenerateMainFile(std::ostream& os)
std::string sep; std::string sep;
auto visitor = [&](cmTargetExport const* te) { auto visitor = [&](cmTargetExport const* te) {
allTargets.push_back(te); allTargets.push_back(te);
expectedTargets += sep + this->Namespace + te->Target->GetExportName(); expectedTargets = cmStrCat(expectedTargets, sep, this->Namespace,
te->Target->GetExportName());
sep = " "; sep = " ";
}; };
+1 -1
View File
@@ -605,7 +605,7 @@ void cmExportInstallFileGenerator::PopulateIncludeDirectoriesInterface(
std::string includes = (input ? *input : ""); std::string includes = (input ? *input : "");
char const* const sep = input ? ";" : ""; char const* const sep = input ? ";" : "";
includes += sep + exportDirs; includes = cmStrCat(includes, sep, exportDirs);
std::string prepro = cmGeneratorExpression::Preprocess( std::string prepro = cmGeneratorExpression::Preprocess(
includes, preprocessRule, this->GetImportPrefixWithSlash()); includes, preprocessRule, this->GetImportPrefixWithSlash());
if (!prepro.empty()) { if (!prepro.empty()) {
+7 -6
View File
@@ -573,8 +573,8 @@ void cmFastbuildNormalTargetGenerator::ComputePCH(
// Reuse compiler options for PCH options. // Reuse compiler options for PCH options.
node.PCHOptions += origCompileOptions; node.PCHOptions += origCompileOptions;
if (this->Makefile->GetSafeDefinition("CMAKE_" + language + if (this->Makefile->GetSafeDefinition(
"_COMPILER_ID") == "MSVC") { cmStrCat("CMAKE_", language, "_COMPILER_ID")) == "MSVC") {
cmSystemTools::ReplaceString(node.PCHOptions, cmSystemTools::ReplaceString(node.PCHOptions,
FASTBUILD_2_INPUT_PLACEHOLDER, FASTBUILD_2_INPUT_PLACEHOLDER,
FASTBUILD_3_INPUT_PLACEHOLDER); FASTBUILD_3_INPUT_PLACEHOLDER);
@@ -1801,8 +1801,9 @@ void cmFastbuildNormalTargetGenerator::AppendExternalObject(
else if (target) { else if (target) {
if (!linkedDeps.emplace(objLibName + FASTBUILD_OBJECTS_ALIAS_POSTFIX) if (!linkedDeps.emplace(objLibName + FASTBUILD_OBJECTS_ALIAS_POSTFIX)
.second) { .second) {
LogMessage("Object Target: " + objLibName + LogMessage(cmStrCat("Object Target: ", objLibName,
FASTBUILD_OBJECTS_ALIAS_POSTFIX " already linked"); FASTBUILD_OBJECTS_ALIAS_POSTFIX
" already linked"));
continue; continue;
} }
linkerNode.LibrarianAdditionalInputs.emplace_back( linkerNode.LibrarianAdditionalInputs.emplace_back(
@@ -1890,8 +1891,8 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep(
// Skip exported objects. // Skip exported objects.
// Tested in "ExportImport" test. // Tested in "ExportImport" test.
if (depType == cm::TargetType::OBJECT_LIBRARY) { if (depType == cm::TargetType::OBJECT_LIBRARY) {
LogMessage("target : " + item.Target->GetName() + LogMessage(cmStrCat("target : ", item.Target->GetName(),
" already linked... Skipping"); " already linked... Skipping"));
return; return;
} }
// Tested in "ExportImport" test. // Tested in "ExportImport" test.
+4 -3
View File
@@ -157,7 +157,8 @@ std::string cmFastbuildTargetGenerator::GetCustomCommandTargetName(
extras += std::to_string(static_cast<int>(step)); extras += std::to_string(static_cast<int>(step));
cmCryptoHash hash(cmCryptoHash::AlgoSHA256); cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
targetName += "-" + hash.HashString(extras).substr(0, 14); targetName =
cmStrCat(targetName, '-', hash.HashString(extras).substr(0, 14));
return targetName; return targetName;
} }
@@ -674,8 +675,8 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
execNode.PreBuildDependencies); execNode.PreBuildDependencies);
for (auto const& util : ccg.GetUtilities()) { for (auto const& util : ccg.GetUtilities()) {
auto const& utilTargetName = util.Value.first; auto const& utilTargetName = util.Value.first;
LogMessage("Util: " + utilTargetName + LogMessage(cmStrCat("Util: ", utilTargetName,
", cross: " + std::to_string(util.Value.second)); ", cross: ", std::to_string(util.Value.second)));
auto* const target = this->Makefile->FindTargetToUse(utilTargetName); auto* const target = this->Makefile->FindTargetToUse(utilTargetName);
if (target && target->IsImported()) { if (target && target->IsImported()) {
+4 -4
View File
@@ -75,8 +75,8 @@ void cmFastbuildUtilityTargetGenerator::Generate()
if (target && target->GetType() == cm::TargetType::INTERFACE_LIBRARY) { if (target && target->GetType() == cm::TargetType::INTERFACE_LIBRARY) {
for (auto const& dep : target->GetUtilities()) { for (auto const& dep : target->GetUtilities()) {
auto const& depName = this->ConvertToFastbuildPath(dep.Value.first); auto const& depName = this->ConvertToFastbuildPath(dep.Value.first);
LogMessage("Transitively propagating iface dep: " + depName + LogMessage(cmStrCat("Transitively propagating iface dep: ", depName,
", is cross: " + std::to_string(dep.Value.second)); ", is cross: ", std::to_string(dep.Value.second)));
nonImportedUtils.emplace_back(depName); nonImportedUtils.emplace_back(depName);
addUtilDepToTarget(this->ConvertToFastbuildPath(depName)); addUtilDepToTarget(this->ConvertToFastbuildPath(depName));
} }
@@ -117,8 +117,8 @@ void cmFastbuildUtilityTargetGenerator::Generate()
for (auto& exec : GenerateCommands(FastbuildBuildStep::REST).Nodes) { for (auto& exec : GenerateCommands(FastbuildBuildStep::REST).Nodes) {
addUtilDepToTarget(exec.Name); addUtilDepToTarget(exec.Name);
for (auto const& dep : TargetDirectDependencies) { for (auto const& dep : TargetDirectDependencies) {
LogMessage("Direct dep " + dep->GetName() + LogMessage(cmStrCat("Direct dep ", dep->GetName(),
"-all propagating to CC: " + exec.Name); "-all propagating to CC: ", exec.Name));
// All custom commands from within the target must be executed AFTER all // All custom commands from within the target must be executed AFTER all
// the target's deps. // the target's deps.
exec.PreBuildDependencies.emplace(dep->GetName()); exec.PreBuildDependencies.emplace(dep->GetName());
+3 -3
View File
@@ -316,7 +316,7 @@ std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild)
topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory()); topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory());
std::string hash = hasher.HashString(path); std::string hash = hasher.HashString(path);
hash.resize(20, '0'); hash.resize(20, '0');
return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash; return cmStrCat(gt->GetName(), CMAKE_DIRECTORY_ID_SEP, hash);
} }
struct CompileData struct CompileData
@@ -755,7 +755,7 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt,
std::replace(safeTargetName.begin(), safeTargetName.end(), ':', '_'); std::replace(safeTargetName.begin(), safeTargetName.end(), ':', '_');
std::string prefix = "target-" + safeTargetName; std::string prefix = "target-" + safeTargetName;
if (!this->Config.empty()) { if (!this->Config.empty()) {
prefix += "-" + this->Config; prefix = cmStrCat(prefix, '-', this->Config);
} }
Json::Value target = this->FileAPI.MaybeJsonFile(t.Dump(), prefix); Json::Value target = this->FileAPI.MaybeJsonFile(t.Dump(), prefix);
target["name"] = gt->GetName(); target["name"] = gt->GetName();
@@ -856,7 +856,7 @@ Json::Value CodemodelConfig::DumpDirectoryObject(Directory& d)
} }
} }
if (!this->Config.empty()) { if (!this->Config.empty()) {
prefix += "-" + this->Config; prefix = cmStrCat(prefix, '-', this->Config);
} }
DirectoryObject dir(d.LocalGenerator, this->VersionMajor, this->VersionMinor, DirectoryObject dir(d.LocalGenerator, this->VersionMajor, this->VersionMinor,
+11 -11
View File
@@ -755,7 +755,7 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
expr = status.GetMakefile().GetCurrentSourceDirectory(); expr = status.GetMakefile().GetCurrentSourceDirectory();
// Handle script mode // Handle script mode
if (!expr.empty()) { if (!expr.empty()) {
expr += "/" + *i; expr = cmStrCat(expr, '/', *i);
} else { } else {
expr = *i; expr = *i;
} }
@@ -2126,10 +2126,10 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
std::string dir = cmSystemTools::GetFilenamePath(file); std::string dir = cmSystemTools::GetFilenamePath(file);
if (!dir.empty() && !cmSystemTools::FileExists(dir) && if (!dir.empty() && !cmSystemTools::FileExists(dir) &&
!cmSystemTools::MakeDirectory(dir)) { !cmSystemTools::MakeDirectory(dir)) {
std::string errstring = "DOWNLOAD error: cannot create directory '" + std::string errstring =
dir + cmStrCat("DOWNLOAD error: cannot create directory '", dir,
"' - Specify file by full path name and verify that you " "' - Specify file by full path name and verify that you "
"have directory creation and file write privileges."; "have directory creation and file write privileges.");
status.SetError(errstring); status.SetError(errstring);
return false; return false;
} }
@@ -2358,10 +2358,10 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
if (expectedHash != actualHash) { if (expectedHash != actualHash) {
if (!statusVar.empty() && res == 0) { if (!statusVar.empty() && res == 0) {
status.GetMakefile().AddDefinition(statusVar, status.GetMakefile().AddDefinition(statusVar,
"1;HASH mismatch: " cmStrCat("1;HASH mismatch: "
"expected: " + "expected: ",
expectedHash + expectedHash,
" actual: " + actualHash); " actual: ", actualHash));
} }
status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n" status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n"
@@ -3644,8 +3644,8 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
cmMakefile& makeFile = status.GetMakefile(); cmMakefile& makeFile = status.GetMakefile();
if (!makeFile.CanIWriteThisFile(outputFile)) { if (!makeFile.CanIWriteThisFile(outputFile)) {
cmSystemTools::Error("Attempt to write file: " + outputFile + cmSystemTools::Error(cmStrCat("Attempt to write file: ", outputFile,
" into a source directory."); " into a source directory."));
return false; return false;
} }
+3 -2
View File
@@ -447,8 +447,9 @@ bool cmFileInstaller::HandleInstallDestination()
if (this->InstallType != cmInstallType_DIRECTORY) { if (this->InstallType != cmInstallType_DIRECTORY) {
if (!cmSystemTools::FileExists(destination)) { if (!cmSystemTools::FileExists(destination)) {
if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) { if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
std::string errstring = "cannot create directory: " + destination + std::string errstring =
". Maybe need administrative privileges."; cmStrCat("cannot create directory: ", destination,
". Maybe need administrative privileges.");
this->Status.SetError(errstring); this->Status.SetError(errstring);
return false; return false;
} }
+1 -1
View File
@@ -82,7 +82,7 @@ std::string cmFortranParser_s::SModName(std::string const& mod_name,
if (this->Compiler.SModSep.empty()) { if (this->Compiler.SModSep.empty()) {
return sub_name + SModExt; 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) bool cmFortranParser_FilePush(cmFortranParser* parser, char const* fname)
@@ -167,7 +167,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
std::string line; std::string line;
std::string sep; std::string sep;
while (cmSystemTools::GetLineFromStream(fin, line)) { while (cmSystemTools::GetLineFromStream(fin, line)) {
inputContent += sep + line; inputContent = cmStrCat(inputContent, sep, line);
sep = "\n"; sep = "\n";
} }
inputContent += sep; inputContent += sep;
+2 -1
View File
@@ -4834,7 +4834,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
std::string linkedTargetsContent = getLinkedTargetsContent( std::string linkedTargetsContent = getLinkedTargetsContent(
target, interfacePropertyName, eval, &dagChecker, usage); target, interfacePropertyName, eval, &dagChecker, usage);
if (!linkedTargetsContent.empty()) { if (!linkedTargetsContent.empty()) {
result += (result.empty() ? "" : ";") + linkedTargetsContent; result =
cmStrCat(result, (result.empty() ? "" : ";"), linkedTargetsContent);
} }
} }
return result; return result;
+14 -14
View File
@@ -1326,7 +1326,7 @@ std::string cmGeneratorTarget::GetCompilePDBName(
*config_name, this->LocalGenerator, config, this); *config_name, this->LocalGenerator, config, this);
NameComponents const& components = GetFullNameInternalComponents( NameComponents const& components = GetFullNameInternalComponents(
config, cmStateEnums::RuntimeBinaryArtifact); config, cmStateEnums::RuntimeBinaryArtifact);
return components.prefix + pdbName + ".pdb"; return cmStrCat(components.prefix, pdbName, ".pdb");
} }
cmValue name = this->GetProperty("COMPILE_PDB_NAME"); cmValue name = this->GetProperty("COMPILE_PDB_NAME");
@@ -1335,7 +1335,7 @@ std::string cmGeneratorTarget::GetCompilePDBName(
*name, this->LocalGenerator, config, this); *name, this->LocalGenerator, config, this);
NameComponents const& components = GetFullNameInternalComponents( NameComponents const& components = GetFullNameInternalComponents(
config, cmStateEnums::RuntimeBinaryArtifact); 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 // 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; generatorTarget = reuseTarget;
} }
auto const inserted = auto const inserted = this->PchHeaders.insert(
this->PchHeaders.insert(std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::vector<BT<std::string>> const headers = std::vector<BT<std::string>> const headers =
this->GetPrecompileHeaders(config, language); this->GetPrecompileHeaders(config, language);
@@ -3305,8 +3305,8 @@ std::string cmGeneratorTarget::GetPchSource(std::string const& config,
language != "OBJCXX") { language != "OBJCXX") {
return std::string(); return std::string();
} }
auto const inserted = auto const inserted = this->PchSources.insert(
this->PchSources.insert(std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::string const pchHeader = this->GetPchHeader(config, language, arch); std::string const pchHeader = this->GetPchHeader(config, language, arch);
if (pchHeader.empty()) { if (pchHeader.empty()) {
@@ -3365,8 +3365,8 @@ std::string cmGeneratorTarget::GetPchFileObject(std::string const& config,
language != "OBJCXX") { language != "OBJCXX") {
return std::string(); return std::string();
} }
auto const inserted = auto const inserted = this->PchObjectFiles.insert(
this->PchObjectFiles.insert(std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::string const pchSource = this->GetPchSource(config, language, arch); std::string const pchSource = this->GetPchSource(config, language, arch);
if (pchSource.empty()) { if (pchSource.empty()) {
@@ -3388,8 +3388,8 @@ std::string cmGeneratorTarget::GetPchFile(std::string const& config,
std::string const& language, std::string const& language,
std::string const& arch) std::string const& arch)
{ {
auto const inserted = auto const inserted = this->PchFiles.insert(
this->PchFiles.insert(std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::string& pchFile = inserted.first->second; std::string& pchFile = inserted.first->second;
@@ -3448,7 +3448,7 @@ std::string cmGeneratorTarget::GetPchCreateCompileOptions(
std::string const& arch) std::string const& arch)
{ {
auto const inserted = this->PchCreateCompileOptions.insert( auto const inserted = this->PchCreateCompileOptions.insert(
std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::string& createOptionList = inserted.first->second; std::string& createOptionList = inserted.first->second;
@@ -3496,7 +3496,7 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions(
std::string const& arch) std::string const& arch)
{ {
auto const inserted = this->PchUseCompileOptions.insert( auto const inserted = this->PchUseCompileOptions.insert(
std::make_pair(language + config + arch, "")); std::make_pair(cmStrCat(language, config, arch), ""));
if (inserted.second) { if (inserted.second) {
std::string& useOptionList = inserted.first->second; std::string& useOptionList = inserted.first->second;
@@ -3944,7 +3944,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
targetNames.Output = components.prefix + targetNames.Base; targetNames.Output = components.prefix + targetNames.Base;
} else { } else {
targetNames.Output = targetNames.Output =
components.prefix + targetNames.Base + components.suffix; cmStrCat(components.prefix, targetNames.Base, components.suffix);
} }
// The executable's real name on disk. // The executable's real name on disk.
@@ -3977,7 +3977,7 @@ std::string cmGeneratorTarget::GetFullNameInternal(
{ {
NameComponents const& components = NameComponents const& components =
this->GetFullNameInternalComponents(config, artifact); this->GetFullNameInternalComponents(config, artifact);
return components.prefix + components.base + components.suffix; return cmStrCat(components.prefix, components.base, components.suffix);
} }
std::string cmGeneratorTarget::ImportedGetLocation( std::string cmGeneratorTarget::ImportedGetLocation(
+3 -3
View File
@@ -567,7 +567,7 @@ std::string cmGraphVizWriter::ItemNameWithAliases(
auto nameWithAliases = itemName; auto nameWithAliases = itemName;
for(auto const& item : items) { for(auto const& item : items) {
nameWithAliases += "\\n(" + item + ")"; nameWithAliases = cmStrCat(nameWithAliases, "\\n(" , item , ')');
} }
return nameWithAliases; return nameWithAliases;
@@ -578,10 +578,10 @@ std::string cmGraphVizWriter::GetEdgeStyle(DependencyType dt)
std::string style; std::string style;
switch (dt) { switch (dt) {
case DependencyType::LinkPrivate: case DependencyType::LinkPrivate:
style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_PRIVATE) + " ]"; style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_PRIVATE, " ]");
break; break;
case DependencyType::LinkInterface: case DependencyType::LinkInterface:
style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_INTERFACE) + " ]"; style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_INTERFACE, " ]");
break; break;
default: default:
break; break;
+3 -2
View File
@@ -82,8 +82,9 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest,
// replace any variables // replace any variables
std::string const& temps = *s; std::string const& temps = *s;
if (!cmSystemTools::GetFilenamePath(temps).empty()) { if (!cmSystemTools::GetFilenamePath(temps).empty()) {
testf = cmSystemTools::GetFilenamePath(temps) + "/" + testf =
cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; cmStrCat(cmSystemTools::GetFilenamePath(temps), '/',
cmSystemTools::GetFilenameWithoutLastExtension(temps), ext);
} else { } else {
testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
} }
+2 -2
View File
@@ -146,8 +146,8 @@ bool cmInstrumentationCommand(std::vector<std::string> const& args,
return true; return true;
} }
if (!unparsedArguments.empty()) { if (!unparsedArguments.empty()) {
status.SetError("given unknown argument \"" + unparsedArguments.front() + status.SetError(
"\"."); cmStrCat("given unknown argument \"", unparsedArguments.front(), "\"."));
return false; return false;
} }
int apiVersion; int apiVersion;
+1 -1
View File
@@ -974,7 +974,7 @@ bool cmake::FindPackage(std::vector<std::string> const& args)
lg->GetStateSnapshot().GetDirectory()); lg->GetStateSnapshot().GetDirectory());
lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags, lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags,
linkFlags, frameworkPath, linkPath, gtgt); linkFlags, frameworkPath, linkPath, gtgt);
linkLibs = frameworkPath + linkPath + linkLibs; linkLibs = cmStrCat(frameworkPath, linkPath, linkLibs);
printf("%s\n", linkLibs.c_str()); printf("%s\n", linkLibs.c_str());
+2 -2
View File
@@ -3400,8 +3400,8 @@ int cmVSLink::LinkNonIncremental()
} }
// Run the manifest tool to embed the final manifest in the binary. // Run the manifest tool to embed the final manifest in the binary.
std::string mtOut = "/outputresource:" + this->TargetFile + std::string mtOut = cmStrCat("/outputresource:", this->TargetFile,
(this->Type == 1 ? ";#1" : ";#2"); (this->Type == 1 ? ";#1" : ";#2"));
return this->RunMT(mtOut, false); return this->RunMT(mtOut, false);
} }