summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-12-18 16:27:16 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2019-12-18 16:27:16 (GMT)
commit3c632b89abf7edd2d82f21dc31d0a933775d8b85 (patch)
treee61ab35f549c8f157e33f06f24b09182c7073c87 /Source
parente6c4d7d4be3d0e9ccd4674d1a5b75d376a31eca0 (diff)
downloadCMake-3c632b89abf7edd2d82f21dc31d0a933775d8b85.zip
CMake-3c632b89abf7edd2d82f21dc31d0a933775d8b85.tar.gz
CMake-3c632b89abf7edd2d82f21dc31d0a933775d8b85.tar.bz2
cmOrderDirectories: Modernize memory management
Diffstat (limited to 'Source')
-rw-r--r--Source/cmOrderDirectories.cxx23
-rw-r--r--Source/cmOrderDirectories.h6
2 files changed, 15 insertions, 14 deletions
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 9ee7127..0369af0 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -8,9 +8,9 @@
#include <sstream>
#include <vector>
+#include <cm/memory>
#include <cmext/algorithm>
-#include "cmAlgorithms.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmMessageType.h"
@@ -250,11 +250,7 @@ cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
this->Computed = false;
}
-cmOrderDirectories::~cmOrderDirectories()
-{
- cmDeleteAll(this->ConstraintEntries);
- cmDeleteAll(this->ImplicitDirEntries);
-}
+cmOrderDirectories::~cmOrderDirectories() = default;
std::vector<std::string> const& cmOrderDirectories::GetOrderedDirectories()
{
@@ -288,14 +284,16 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath,
if (this->IsImplicitDirectory(dir)) {
this->ImplicitDirEntries.push_back(
- new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
+ cm::make_unique<cmOrderDirectoriesConstraintSOName>(this, fullPath,
+ soname));
return;
}
}
// Construct the runtime information entry for this library.
this->ConstraintEntries.push_back(
- new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
+ cm::make_unique<cmOrderDirectoriesConstraintSOName>(this, fullPath,
+ soname));
} else {
// This can happen if the same library is linked multiple times.
// In that case the runtime information check need be done only
@@ -316,14 +314,15 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath)
std::string dir = cmSystemTools::GetFilenamePath(fullPath);
if (this->IsImplicitDirectory(dir)) {
this->ImplicitDirEntries.push_back(
- new cmOrderDirectoriesConstraintLibrary(this, fullPath));
+ cm::make_unique<cmOrderDirectoriesConstraintLibrary>(this,
+ fullPath));
return;
}
}
// Construct the link library entry.
this->ConstraintEntries.push_back(
- new cmOrderDirectoriesConstraintLibrary(this, fullPath));
+ cm::make_unique<cmOrderDirectoriesConstraintLibrary>(this, fullPath));
}
}
@@ -371,7 +370,7 @@ void cmOrderDirectories::CollectOriginalDirectories()
this->AddOriginalDirectories(this->UserDirectories);
// Add directories containing constraints.
- for (cmOrderDirectoriesConstraint* entry : this->ConstraintEntries) {
+ for (const auto& entry : this->ConstraintEntries) {
entry->AddDirectory();
}
@@ -456,7 +455,7 @@ void cmOrderDirectories::FindImplicitConflicts()
// Check for items in implicit link directories that have conflicts
// in the explicit directories.
std::ostringstream conflicts;
- for (cmOrderDirectoriesConstraint* entry : this->ImplicitDirEntries) {
+ for (const auto& entry : this->ImplicitDirEntries) {
entry->FindImplicitConflicts(conflicts);
}
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 23c5145..8ce53e0 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -46,8 +47,9 @@ private:
std::vector<std::string> OrderedDirectories;
- std::vector<cmOrderDirectoriesConstraint*> ConstraintEntries;
- std::vector<cmOrderDirectoriesConstraint*> ImplicitDirEntries;
+ std::vector<std::unique_ptr<cmOrderDirectoriesConstraint>> ConstraintEntries;
+ std::vector<std::unique_ptr<cmOrderDirectoriesConstraint>>
+ ImplicitDirEntries;
std::vector<std::string> UserDirectories;
std::vector<std::string> LanguageDirectories;
cmsys::RegularExpression RemoveLibraryExtension;