From 022ccedde8877e877b45e49641544b5e4fff0b42 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 8 Apr 2021 16:04:55 -0700 Subject: [PATCH] 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 --- llvm/include/llvm/Support/Signposts.h | 3 ++- llvm/lib/Support/Signposts.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/Support/Signposts.h b/llvm/include/llvm/Support/Signposts.h index 984bad2..d31f3c1 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 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 Impl; public: SignpostEmitter(); diff --git a/llvm/lib/Support/Signposts.cpp b/llvm/lib/Support/Signposts.cpp index eefd61f4..c85bab4 100644 --- a/llvm/lib/Support/Signposts.cpp +++ b/llvm/lib/Support/Signposts.cpp @@ -98,17 +98,11 @@ public: SignpostEmitter::SignpostEmitter() { #if HAVE_ANY_SIGNPOST_IMPL - Impl = new SignpostEmitterImpl(); -#else // if HAVE_ANY_SIGNPOST_IMPL - Impl = nullptr; + Impl = std::make_unique(); #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 -- 2.7.4