Appease STLs where std::atomic<void*> lacks a constexpr default ctor

MSVC 2019 casts the pointer to a pointer-sized integer, which is a
reinterpret_cast, which is invalid in a constexpr context, so I have to
remove the LLVM_REQUIRES_CONSTANT_INITIALIZATION annotation for now.

llvm-svn: 357716
This commit is contained in:
Reid Kleckner 2019-04-04 18:45:05 +00:00
parent 09137be7f8
commit 4312fee0a9
2 changed files with 3 additions and 5 deletions

View File

@ -45,7 +45,7 @@ template <typename T, size_t N> struct object_deleter<T[N]> {
class ManagedStaticBase {
protected:
#ifndef LLVM_AVOID_CONSTEXPR_CTOR
mutable std::atomic<void *> Ptr;
mutable std::atomic<void *> Ptr{nullptr};
mutable void (*DeleterFn)(void *) = nullptr;
mutable const ManagedStaticBase *Next = nullptr;
#else

View File

@ -377,12 +377,10 @@ void OptionCategory::registerCategory() {
// that this ManagedStatic uses constant initailization and not dynamic
// initialization because it is referenced from cl::opt constructors, which run
// dynamically in an arbitrary order.
LLVM_REQUIRE_CONSTANT_INITIALIZATION ManagedStatic<SubCommand>
llvm::cl::TopLevelSubCommand;
ManagedStatic<SubCommand> llvm::cl::TopLevelSubCommand;
// A special subcommand that can be used to put an option into all subcommands.
LLVM_REQUIRE_CONSTANT_INITIALIZATION ManagedStatic<SubCommand>
llvm::cl::AllSubCommands;
ManagedStatic<SubCommand> llvm::cl::AllSubCommands;
void SubCommand::registerSubCommand() {
GlobalParser->registerSubCommand(this);