diff options
author | Reid Kleckner <rnk@google.com> | 2019-04-04 00:11:21 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-04-04 00:11:21 +0000 |
commit | e9f2847b815a05fe1b4eefac9c00b304e3c88dfa (patch) | |
tree | 86de7c8694699e1ca2a600f32bc0f0c63b41b625 | |
parent | 920f6c81634c1ef636c71e1bd18d392b7caff336 (diff) | |
download | llvm-e9f2847b815a05fe1b4eefac9c00b304e3c88dfa.zip llvm-e9f2847b815a05fe1b4eefac9c00b304e3c88dfa.tar.gz llvm-e9f2847b815a05fe1b4eefac9c00b304e3c88dfa.tar.bz2 |
Make ManagedStatic constexpr constructible
Apparently it needs member initializers so that it can be constructed in
a constexpr context. I explained my investigation of this in PR41367.
llvm-svn: 357655
-rw-r--r-- | llvm/include/llvm/Support/ManagedStatic.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/ManagedStatic.h b/llvm/include/llvm/Support/ManagedStatic.h index 441f24e0..ebf9bba 100644 --- a/llvm/include/llvm/Support/ManagedStatic.h +++ b/llvm/include/llvm/Support/ManagedStatic.h @@ -37,13 +37,18 @@ class ManagedStaticBase { protected: // This should only be used as a static variable, which guarantees that this // will be zero initialized. - mutable std::atomic<void *> Ptr; - mutable void (*DeleterFn)(void*); - mutable const ManagedStaticBase *Next; + mutable std::atomic<void *> Ptr{nullptr}; + mutable void (*DeleterFn)(void *) = nullptr; + mutable const ManagedStaticBase *Next = nullptr; void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const; public: + /// ManagedStaticBase must be constexpr constructed so that they can be + /// accessed and constructed lazily during dynamic initilization of other + /// global variables, such as cl::opt command line flags. + constexpr ManagedStaticBase() = default; + /// isConstructed - Return true if this object has not been created yet. bool isConstructed() const { return Ptr != nullptr; } |