Eliminating static destructor for the BitCodeErrorCategory by converting to a Managed...
authorChris Bieneman <beanz@apple.com>
Fri, 19 Sep 2014 20:29:02 +0000 (20:29 +0000)
committerChris Bieneman <beanz@apple.com>
Fri, 19 Sep 2014 20:29:02 +0000 (20:29 +0000)
Summary: This is part of the overall goal of removing static initializers from LLVM.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: chandlerc, llvm-commits

Differential Revision: http://reviews.llvm.org/D5416

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

lib/Bitcode/Reader/BitcodeReader.cpp

index 84ee0b4b3a683ba92c604c5292a90a5663b02eab..80afb56e746bb63c60f497bcf627d615c764e96b 100644 (file)
@@ -25,6 +25,8 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ManagedStatic.h"
+
 using namespace llvm;
 
 enum {
@@ -3502,9 +3504,10 @@ class BitcodeErrorCategoryType : public std::error_category {
 };
 }
 
+static ManagedStatic<BitcodeErrorCategoryType> ErrorCategory;
+
 const std::error_category &llvm::BitcodeErrorCategory() {
-  static BitcodeErrorCategoryType O;
-  return O;
+  return *ErrorCategory;
 }
 
 //===----------------------------------------------------------------------===//