summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-10 17:22:52 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-13 15:20:27 (GMT)
commit30a550d6ade191e6510fb74a73fe34f1615b6086 (patch)
treecf7e21d9e58bc4a14c451b1394d4917c92ef0a0c
parent0024356f8e8e5f9ec2fa6af1e651c634eba3b22b (diff)
downloadCMake-30a550d6ade191e6510fb74a73fe34f1615b6086.zip
CMake-30a550d6ade191e6510fb74a73fe34f1615b6086.tar.gz
CMake-30a550d6ade191e6510fb74a73fe34f1615b6086.tar.bz2
Ninja: In cmNinjaTargetGenerator use std::unique_ptr to manage new instances
-rw-r--r--Source/cmLocalNinjaGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx9
-rw-r--r--Source/cmNinjaTargetGenerator.h4
3 files changed, 9 insertions, 7 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 515651a..e6d4457 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -83,14 +83,13 @@ void cmLocalNinjaGenerator::Generate()
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(target);
+ auto tg = cmNinjaTargetGenerator::New(target);
if (tg) {
tg->Generate();
// Add the target to "all" if required.
if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) {
this->GetGlobalNinjaGenerator()->AddDependencyToAll(target);
}
- delete tg;
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 9ab0947..506711a 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -33,7 +33,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
-cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
+std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New(
+ cmGeneratorTarget* target)
{
switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
@@ -41,14 +42,14 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY:
- return new cmNinjaNormalTargetGenerator(target);
+ return cm::make_unique<cmNinjaNormalTargetGenerator>(target);
case cmStateEnums::UTILITY:
case cmStateEnums::GLOBAL_TARGET:
- return new cmNinjaUtilityTargetGenerator(target);
+ return cm::make_unique<cmNinjaUtilityTargetGenerator>(target);
default:
- return nullptr;
+ return std::unique_ptr<cmNinjaTargetGenerator>();
}
}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 51c9ac7..3dbc1b5 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -11,6 +11,7 @@
#include "cmOSXBundleGenerator.h"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <string>
#include <vector>
@@ -26,7 +27,8 @@ class cmNinjaTargetGenerator : public cmCommonTargetGenerator
{
public:
/// Create a cmNinjaTargetGenerator according to the @a target's type.
- static cmNinjaTargetGenerator* New(cmGeneratorTarget* target);
+ static std::unique_ptr<cmNinjaTargetGenerator> New(
+ cmGeneratorTarget* target);
/// Build a NinjaTargetGenerator.
cmNinjaTargetGenerator(cmGeneratorTarget* target);