[PATCH] D100151: Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 16:12:34 PDT 2021
dexonsmith created this revision.
dexonsmith added reviewers: dsanders, bogner.
Herald added a subscriber: hiraditya.
dexonsmith requested review of this revision.
Herald added a project: LLVM.
Replace some manual memory management with std::unique_ptr.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100151
Files:
llvm/include/llvm/Support/Signposts.h
llvm/lib/Support/Signposts.cpp
Index: llvm/lib/Support/Signposts.cpp
===================================================================
--- llvm/lib/Support/Signposts.cpp
+++ llvm/lib/Support/Signposts.cpp
@@ -98,17 +98,11 @@
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
Index: llvm/include/llvm/Support/Signposts.h
===================================================================
--- llvm/include/llvm/Support/Signposts.h
+++ llvm/include/llvm/Support/Signposts.h
@@ -18,6 +18,7 @@
#define LLVM_SUPPORT_SIGNPOSTS_H
#include "llvm/ADT/StringRef.h"
+#include <memory>
namespace llvm {
class SignpostEmitterImpl;
@@ -25,7 +26,7 @@
/// Manages the emission of signposts into the recording method supported by
/// the OS.
class SignpostEmitter {
- SignpostEmitterImpl *Impl;
+ std::unique_ptr<SignpostEmitterImpl> Impl;
public:
SignpostEmitter();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100151.336253.patch
Type: text/x-patch
Size: 1289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/565913ed/attachment.bin>
More information about the llvm-commits
mailing list