Revert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC""

This reverts commit 078072285d, reapplying
022ccedde8.

I figured out why this was failing in other environments: it's not a
problem with std::unique_ptr, but that SignpostEmitterImpl only has a
forward declaration. Adding an empty definition should do the trick.

Original commit message:

    Replace some manual memory management with std::unique_ptr.

    Differential Revision: https://reviews.llvm.org/D100151
This commit is contained in:
Duncan P. N. Exon Smith 2021-04-08 16:41:40 -07:00
parent 078072285d
commit e7ed5c920d
2 changed files with 7 additions and 10 deletions

View File

@ -18,6 +18,7 @@
#define LLVM_SUPPORT_SIGNPOSTS_H
#include "llvm/ADT/StringRef.h"
#include <memory>
namespace llvm {
class SignpostEmitterImpl;
@ -25,8 +26,7 @@ class SignpostEmitterImpl;
/// Manages the emission of signposts into the recording method supported by
/// the OS.
class SignpostEmitter {
/// Not using std::unique_ptr since some hosts need a definition.
SignpostEmitterImpl *Impl;
std::unique_ptr<SignpostEmitterImpl> Impl;
public:
SignpostEmitter();

View File

@ -96,21 +96,18 @@ public:
#define HAVE_ANY_SIGNPOST_IMPL 1
#else
#define HAVE_ANY_SIGNPOST_IMPL 0
/// Definition necessary for use of std::unique_ptr.
class SignpostEmitterImpl {};
#endif
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