Skip to content

Commit 124963f

Browse files
committed
Headers: remove C++14 compatibility shim
We currently use C++17 as the C++ standard. Remove compatibility shims to enable building with C++11.
1 parent a03e184 commit 124963f

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

Headers/DebugServer2/Base.h

+5-12
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,10 @@ typename std::enable_if<
124124
}
125125

126126
namespace ds2 {
127-
128-
// We don't use C++14 (yet).
129-
template <typename T, typename... Args>
130-
std::unique_ptr<T> make_unique(Args &&... args) {
131-
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
132-
}
133-
134-
// This thing allows classes with protected constructors to call
135-
// make_protected_unique to construct a unique_ptr cleanly (which calls
136-
// make_unique internally). Without this, classes with protected constructors
137-
// cannot be make_unique'd.
127+
// Wrapper to allow classes with protected constructors to call
128+
// `make_protected_unique` to construct a `unique_ptr` cleanly (which calls
129+
// `make_unique` internally). Without this, classes with protected constructors
130+
// cannot be `make_unique`'d.
138131
template <typename T> struct make_unique_enabler {
139132
struct make_unique_enabler_helper : public T {
140133
template <typename... Args>
@@ -143,7 +136,7 @@ template <typename T> struct make_unique_enabler {
143136

144137
template <typename... Args>
145138
static std::unique_ptr<T> make_protected_unique(Args... args) {
146-
return ds2::make_unique<make_unique_enabler_helper>(
139+
return std::make_unique<make_unique_enabler_helper>(
147140
std::forward<Args>(args)...);
148141
}
149142
};

Sources/Target/Common/ProcessBase.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ErrorCode ProcessBase::afterResume() {
324324

325325
SoftwareBreakpointManager *ProcessBase::softwareBreakpointManager() const {
326326
if (!_softwareBreakpointManager) {
327-
_softwareBreakpointManager = ds2::make_unique<SoftwareBreakpointManager>(
327+
_softwareBreakpointManager = std::make_unique<SoftwareBreakpointManager>(
328328
const_cast<ProcessBase *>(this));
329329
}
330330

@@ -333,7 +333,7 @@ SoftwareBreakpointManager *ProcessBase::softwareBreakpointManager() const {
333333

334334
HardwareBreakpointManager *ProcessBase::hardwareBreakpointManager() const {
335335
if (!_hardwareBreakpointManager) {
336-
_hardwareBreakpointManager = ds2::make_unique<HardwareBreakpointManager>(
336+
_hardwareBreakpointManager = std::make_unique<HardwareBreakpointManager>(
337337
const_cast<ProcessBase *>(this));
338338
}
339339

Sources/Target/POSIX/Process.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <cerrno>
1919
#include <csignal>
2020
#include <cstring>
21+
#include <memory>
2122

2223
#include <sys/mman.h>
2324
#include <sys/wait.h>
@@ -129,7 +130,7 @@ ds2::Target::Process *Process::Attach(ProcessId pid) {
129130
if (pid <= 0)
130131
return nullptr;
131132

132-
auto process = ds2::make_unique<Target::Process>();
133+
auto process = std::make_unique<Target::Process>();
133134

134135
if (process->ptrace().attach(pid) != kSuccess) {
135136
DS2LOG(Error, "ptrace attach failed: %s", strerror(errno));
@@ -145,7 +146,7 @@ ds2::Target::Process *Process::Attach(ProcessId pid) {
145146
}
146147

147148
ds2::Target::Process *Process::Create(ProcessSpawner &spawner) {
148-
auto process = ds2::make_unique<Target::Process>();
149+
auto process = std::make_unique<Target::Process>();
149150

150151
if (spawner.run([&process]() {
151152
// move debug targets to their own process group

Sources/Target/Windows/Process.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ ds2::Target::Process *Process::Create(ProcessSpawner &spawner) {
533533
DS2LOG(Debug, "created process %" PRIu64, (uint64_t)spawner.pid());
534534

535535
struct MakeUniqueEnabler : public Process {};
536-
auto process = ds2::make_unique<MakeUniqueEnabler>();
536+
auto process = std::make_unique<MakeUniqueEnabler>();
537537

538538
if (process->initialize(spawner.pid(), kFlagNewProcess) != kSuccess) {
539539
return nullptr;

Sources/main.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static std::unique_ptr<Socket> CreateFDSocket(int fd) {
8383
DS2LOG(Error, "cannot use fd %d: refers to a terminal", fd);
8484
}
8585

86-
auto socket = ds2::make_unique<Socket>(fd);
86+
auto socket = std::make_unique<Socket>(fd);
8787

8888
return socket;
8989
}
@@ -95,7 +95,7 @@ static std::unique_ptr<Socket> CreateFDSocket(int fd) {
9595
static std::unique_ptr<Socket> CreateTCPSocket(std::string const &host,
9696
std::string const &port,
9797
bool reverse) {
98-
auto socket = ds2::make_unique<Socket>();
98+
auto socket = std::make_unique<Socket>();
9999

100100
if (reverse) {
101101
if (!socket->connect(host, port)) {
@@ -136,7 +136,7 @@ static std::unique_ptr<Socket> CreateUNIXSocket(std::string const &path,
136136
DS2LOG(Fatal, "reverse connections not supported with UNIX sockets");
137137
}
138138

139-
auto socket = ds2::make_unique<Socket>();
139+
auto socket = std::make_unique<Socket>();
140140

141141
if (!socket->listen(path, abstract)) {
142142
DS2LOG(Fatal, "cannot listen on %s: %s", path.c_str(),
@@ -499,11 +499,11 @@ static int GdbserverMain(int argc, char **argv) {
499499
std::unique_ptr<DebugSessionImpl> impl;
500500

501501
if (attachPid > 0)
502-
impl = ds2::make_unique<DebugSessionImpl>(attachPid);
502+
impl = std::make_unique<DebugSessionImpl>(attachPid);
503503
else if (args.size() > 0)
504-
impl = ds2::make_unique<DebugSessionImpl>(args, env);
504+
impl = std::make_unique<DebugSessionImpl>(args, env);
505505
else
506-
impl = ds2::make_unique<DebugSessionImpl>();
506+
impl = std::make_unique<DebugSessionImpl>();
507507

508508
return RunDebugServer(channel.get(), impl.get());
509509
}
@@ -550,7 +550,7 @@ static int PlatformMain(int argc, char **argv) {
550550
do {
551551
std::unique_ptr<Socket> clientSocket = serverSocket->accept();
552552
auto platformClient =
553-
ds2::make_unique<PlatformClient>(std::move(clientSocket));
553+
std::make_unique<PlatformClient>(std::move(clientSocket));
554554

555555
std::thread thread(
556556
[](std::unique_ptr<PlatformClient> client) {

0 commit comments

Comments
 (0)