From b50b2755dad27302a18b6e86c912c76771843133 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 26 Jan 2020 14:01:45 +0100 Subject: cmComputeLinkInformation: modernize memory management --- Source/cmComputeLinkInformation.cxx | 20 ++++++++------------ Source/cmComputeLinkInformation.h | 10 +++++++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 8773d10..59a8f14 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -8,6 +8,8 @@ #include #include +#include + #include "cmAlgorithms.h" #include "cmComputeLinkDepends.h" #include "cmGeneratorTarget.h" @@ -256,11 +258,10 @@ cmComputeLinkInformation::cmComputeLinkInformation( "FIND_LIBRARY_USE_OPENBSD_VERSIONING"); // Allocate internals. - this->OrderLinkerSearchPath = new cmOrderDirectories( + this->OrderLinkerSearchPath = cm::make_unique( this->GlobalGenerator, target, "linker search path"); - this->OrderRuntimeSearchPath = new cmOrderDirectories( + this->OrderRuntimeSearchPath = cm::make_unique( this->GlobalGenerator, target, "runtime search path"); - this->OrderDependentRPath = nullptr; // Get the language used for linking this target. this->LinkLanguage = this->Target->GetLinkerLanguage(config); @@ -358,7 +359,7 @@ cmComputeLinkInformation::cmComputeLinkInformation( this->SharedDependencyMode = SharedDepModeLibDir; } else if (!this->RPathLinkFlag.empty()) { this->SharedDependencyMode = SharedDepModeDir; - this->OrderDependentRPath = new cmOrderDirectories( + this->OrderDependentRPath = cm::make_unique( this->GlobalGenerator, target, "dependent library path"); } @@ -400,12 +401,7 @@ cmComputeLinkInformation::cmComputeLinkInformation( "CMAKE_POLICY_WARNING_CMP0060"); } -cmComputeLinkInformation::~cmComputeLinkInformation() -{ - delete this->OrderLinkerSearchPath; - delete this->OrderRuntimeSearchPath; - delete this->OrderDependentRPath; -} +cmComputeLinkInformation::~cmComputeLinkInformation() = default; void cmComputeLinkInformation::AppendValues( std::string& result, std::vector>& values) @@ -747,10 +743,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, if (this->SharedDependencyMode == SharedDepModeLibDir && !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */) { // Add the item to the linker search path. - order = this->OrderLinkerSearchPath; + order = this->OrderLinkerSearchPath.get(); } else if (this->SharedDependencyMode == SharedDepModeDir) { // Add the item to the separate dependent library search path. - order = this->OrderDependentRPath; + order = this->OrderDependentRPath.get(); } if (order) { if (tgt) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 92ab83b..6fc1169 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include #include #include #include @@ -29,6 +30,9 @@ class cmComputeLinkInformation public: cmComputeLinkInformation(cmGeneratorTarget const* target, const std::string& config); + cmComputeLinkInformation(const cmComputeLinkInformation&) = delete; + cmComputeLinkInformation& operator=(const cmComputeLinkInformation&) = + delete; ~cmComputeLinkInformation(); bool Compute(); @@ -164,7 +168,7 @@ private: cmsys::RegularExpression SplitFramework; // Linker search path computation. - cmOrderDirectories* OrderLinkerSearchPath; + std::unique_ptr OrderLinkerSearchPath; bool FinishLinkerSearchDirectories(); void PrintLinkPolicyDiagnosis(std::ostream&); @@ -184,9 +188,9 @@ private: std::vector OldUserFlagItems; std::set CMP0060WarnItems; // Dependent library path computation. - cmOrderDirectories* OrderDependentRPath; + std::unique_ptr OrderDependentRPath; // Runtime path computation. - cmOrderDirectories* OrderRuntimeSearchPath; + std::unique_ptr OrderRuntimeSearchPath; bool OldLinkDirMode; bool OpenBSD; -- cgit v0.12