Skip to content

Commit

Permalink
Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC
Browse files Browse the repository at this point in the history
Replace some manual memory management with std::unique_ptr.

Differential Revision: https://reviews.llvm.org/D100151
  • Loading branch information
dexonsmith committed Apr 8, 2021
1 parent 429088b commit 022cced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
3 changes: 2 additions & 1 deletion llvm/include/llvm/Support/Signposts.h
Expand Up @@ -18,14 +18,15 @@
#define LLVM_SUPPORT_SIGNPOSTS_H

#include "llvm/ADT/StringRef.h"
#include <memory>

namespace llvm {
class SignpostEmitterImpl;

/// Manages the emission of signposts into the recording method supported by
/// the OS.
class SignpostEmitter {
SignpostEmitterImpl *Impl;
std::unique_ptr<SignpostEmitterImpl> Impl;

public:
SignpostEmitter();
Expand Down
10 changes: 2 additions & 8 deletions llvm/lib/Support/Signposts.cpp
Expand Up @@ -98,17 +98,11 @@ class SignpostEmitterImpl {

SignpostEmitter::SignpostEmitter() {
#if HAVE_ANY_SIGNPOST_IMPL
Impl = new SignpostEmitterImpl();
#else // if HAVE_ANY_SIGNPOST_IMPL
Impl = nullptr;
Impl = std::make_unique<SignpostEmitterImpl>();
#endif // if !HAVE_ANY_SIGNPOST_IMPL
}

SignpostEmitter::~SignpostEmitter() {
#if HAVE_ANY_SIGNPOST_IMPL
delete Impl;
#endif // if HAVE_ANY_SIGNPOST_IMPL
}
SignpostEmitter::~SignpostEmitter() = default;

bool SignpostEmitter::isEnabled() const {
#if HAVE_ANY_SIGNPOST_IMPL
Expand Down

0 comments on commit 022cced

Please sign in to comment.