[llvm] 022cced - Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 16:32:35 PDT 2021
Author: Duncan P. N. Exon Smith
Date: 2021-04-08T16:31:59-07:00
New Revision: 022ccedde8877e877b45e49641544b5e4fff0b42
URL: https://github.com/llvm/llvm-project/commit/022ccedde8877e877b45e49641544b5e4fff0b42
DIFF: https://github.com/llvm/llvm-project/commit/022ccedde8877e877b45e49641544b5e4fff0b42.diff
LOG: Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC
Replace some manual memory management with std::unique_ptr.
Differential Revision: https://reviews.llvm.org/D100151
Added:
Modified:
llvm/include/llvm/Support/Signposts.h
llvm/lib/Support/Signposts.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/Signposts.h b/llvm/include/llvm/Support/Signposts.h
index 984bad265d68..d31f3c1e6eb5 100644
--- a/llvm/include/llvm/Support/Signposts.h
+++ b/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 @@ 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();
diff --git a/llvm/lib/Support/Signposts.cpp b/llvm/lib/Support/Signposts.cpp
index eefd61f43b44..c85bab446cc5 100644
--- a/llvm/lib/Support/Signposts.cpp
+++ b/llvm/lib/Support/Signposts.cpp
@@ -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
More information about the llvm-commits
mailing list