From c2dd5dfbe8a8c5254e8a0a6ec1d1c611ad039ff7 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 9 Jan 2024 12:22:54 +0100 Subject: Makefile: Remove no-op call --- Source/cmMakefileTargetGenerator.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 8fda774..8122f0f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1800,7 +1800,6 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << "# Object files for target " << this->GeneratorTarget->GetName() << "\n" << variableName << " ="; - std::string object; const auto& lineContinue = this->GlobalGenerator->LineContinueDirective; cmValue pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); @@ -1828,7 +1827,6 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( << variableNameExternal << " ="; /* clang-format on */ for (std::string const& obj : this->ExternalObjects) { - object = this->LocalGenerator->MaybeRelativeToCurBinDir(obj); *this->BuildFileStream << " " << lineContinue; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( -- cgit v0.12 From 3e533bd64ffda57a6d0e6af1d361913a2a948873 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 9 Jan 2024 12:26:09 +0100 Subject: Makefile: Improve const correctness --- Source/cmMakefileTargetGenerator.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 8122f0f..756e5aa 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -139,7 +139,7 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags( this->LocalGenerator->AppendFlags( flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS")); - std::string linkFlagsConfig = + std::string const linkFlagsConfig = cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->GetConfigName())); this->LocalGenerator->AppendFlags( flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig)); @@ -236,7 +236,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } // Look for ISPC extra object files generated by this target - auto ispcAdditionalObjs = + auto const ispcAdditionalObjs = this->GeneratorTarget->GetGeneratedISPCObjects(this->GetConfigName()); for (std::string const& ispcObj : ispcAdditionalObjs) { this->CleanFiles.insert( @@ -244,7 +244,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } // add custom commands to the clean rules? - bool clean = cmIsOff(this->Makefile->GetProperty("CLEAN_NO_CUSTOM")); + bool const clean = cmIsOff(this->Makefile->GetProperty("CLEAN_NO_CUSTOM")); // First generate the object rule files. Save a list of all object // files for this target. @@ -1906,7 +1906,7 @@ void cmMakefileTargetGenerator::WriteObjectsStrings( for (std::string const& obj : this->ExternalObjects) { helper.Feed(obj); } - auto ispcAdditionalObjs = + auto const ispcAdditionalObjs = this->GeneratorTarget->GetGeneratedISPCObjects(this->GetConfigName()); for (std::string const& obj : ispcAdditionalObjs) { helper.Feed(obj); @@ -1970,7 +1970,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends( } // Loop over all library dependencies. - if (cmComputeLinkInformation* cli = + if (cmComputeLinkInformation const* cli = this->GeneratorTarget->GetLinkInformation(cfg)) { cm::append(depends, cli->GetDepends()); } @@ -2195,9 +2195,10 @@ void cmMakefileTargetGenerator::CreateLinkLibs( std::string responseFlag = this->GetResponseFlag(responseMode); // Create this response file. - std::string responseFileName = + std::string const responseFileName = (responseMode == Link) ? "linkLibs.rsp" : "deviceLinkLibs.rsp"; - std::string responseLang = (responseMode == Link) ? linkLanguage : "CUDA"; + std::string const responseLang = + (responseMode == Link) ? linkLanguage : "CUDA"; std::string link_rsp = this->CreateResponseFile( responseFileName, linkLibs, makefile_depends, responseLang); @@ -2228,7 +2229,7 @@ void cmMakefileTargetGenerator::CreateObjectLists( responseFileLimit); // Lookup the response file reference flag. - std::string responseFlag = this->GetResponseFlag(responseMode); + std::string const responseFlag = this->GetResponseFlag(responseMode); // Write a response file for each string. const char* sep = ""; @@ -2268,15 +2269,15 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, const std::string& lang, const std::string& /*config*/) { - std::string responseVar = + std::string const responseVar = cmStrCat("CMAKE_", lang, "_USE_RESPONSE_FILE_FOR_INCLUDES"); - bool useResponseFile = this->Makefile->IsOn(responseVar); + bool const useResponseFile = this->Makefile->IsOn(responseVar); std::vector includes; this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, lang, this->GetConfigName()); - std::string includeFlags = this->LocalGenerator->GetIncludeFlags( + std::string const includeFlags = this->LocalGenerator->GetIncludeFlags( includes, this->GeneratorTarget, lang, this->GetConfigName(), useResponseFile); if (includeFlags.empty()) { @@ -2291,8 +2292,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, if (responseFlag.empty()) { responseFlag = "@"; } - std::string name = cmStrCat("includes_", lang, ".rsp"); - std::string arg = std::move(responseFlag) + + std::string const name = cmStrCat("includes_", lang, ".rsp"); + std::string const arg = std::move(responseFlag) + this->CreateResponseFile(name, includeFlags, this->FlagFileDepends[lang], lang); this->LocalGenerator->AppendFlags(flags, arg); @@ -2321,7 +2322,7 @@ void cmMakefileTargetGenerator::GenDefFile( cmd += this->LocalGenerator->ConvertToOutputFormat( this->LocalGenerator->MaybeRelativeToCurBinDir(objlist_file), cmOutputConverter::SHELL); - cmValue nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); + cmValue const nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( @@ -2361,7 +2362,7 @@ std::string cmMakefileTargetGenerator::GetResponseFlag( responseFlagVar = "CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG"; } - if (cmValue p = this->Makefile->GetDefinition(responseFlagVar)) { + if (cmValue const p = this->Makefile->GetDefinition(responseFlagVar)) { responseFlag = *p; } return responseFlag; -- cgit v0.12 From 4d928592eb1c0a47c2eea3c2df25cf957c2e538b Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 9 Jan 2024 12:27:17 +0100 Subject: Makefile: Remove redundant push_back --- Source/cmMakefileTargetGenerator.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 756e5aa..6a02bdb 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1926,8 +1926,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( this->LocalGenerator->MaybeRelativeToTopBinDir(buildTargetRuleName); // Build the list of target outputs to drive. - std::vector depends; - depends.push_back(main_output); + std::vector depends{ main_output }; const char* comment = nullptr; if (relink) { -- cgit v0.12 From 63d4e4ec2865b85a60f3f26d14be2c7116da79f0 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 9 Jan 2024 12:58:28 +0100 Subject: Makefile: Reduce string copies --- Source/cmMakefileTargetGenerator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6a02bdb..4fd22fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1921,7 +1921,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( std::string dir = this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); std::string buildTargetRuleName = - cmStrCat(dir, relink ? "/preinstall" : "/build"); + cmStrCat(std::move(dir), relink ? "/preinstall" : "/build"); buildTargetRuleName = this->LocalGenerator->MaybeRelativeToTopBinDir(buildTargetRuleName); @@ -2202,9 +2202,9 @@ void cmMakefileTargetGenerator::CreateLinkLibs( responseFileName, linkLibs, makefile_depends, responseLang); // Reference the response file. - linkLibs = cmStrCat(responseFlag, + linkLibs = cmStrCat(std::move(responseFlag), this->LocalGenerator->ConvertToOutputFormat( - link_rsp, cmOutputConverter::SHELL)); + std::move(link_rsp), cmOutputConverter::SHELL)); } } -- cgit v0.12