]> granicus.if.org Git - llvm/commitdiff
Appease STLs where std::atomic<void*> lacks a constexpr default ctor
authorReid Kleckner <rnk@google.com>
Thu, 4 Apr 2019 18:45:05 +0000 (18:45 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 4 Apr 2019 18:45:05 +0000 (18:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357716 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/ManagedStatic.h
lib/Support/CommandLine.cpp

index 0290510e030cd8bdb6d3794a7ccf42db5e0bc0c9..30c3daa5ba5dc3f8daa105fefe73c8d122c811d0 100644 (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
index d2cfef9f42a1835020c1195f58d583ee785ae1af..1858fe941ae80de2eff988354d9be4e6f3ad680c 100644 (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);