[llvm] r218160 - Converting object's error_category to a ManagedStatic to avoid static constructors and destructors.

Chris Bieneman beanz at apple.com
Fri Sep 19 15:09:18 PDT 2014


Author: cbieneman
Date: Fri Sep 19 17:09:18 2014
New Revision: 218160

URL: http://llvm.org/viewvc/llvm-project?rev=218160&view=rev
Log:
Converting object's error_category to a ManagedStatic to avoid static constructors and destructors.

Modified:
    llvm/trunk/lib/Object/Error.cpp

Modified: llvm/trunk/lib/Object/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=218160&r1=218159&r2=218160&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Error.cpp (original)
+++ llvm/trunk/lib/Object/Error.cpp Fri Sep 19 17:09:18 2014
@@ -13,6 +13,7 @@
 
 #include "llvm/Object/Error.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ManagedStatic.h"
 
 using namespace llvm;
 using namespace object;
@@ -48,7 +49,8 @@ std::string _object_error_category::mess
                    "defined.");
 }
 
+static ManagedStatic<_object_error_category> error_category;
+
 const std::error_category &object::object_category() {
-  static _object_error_category o;
-  return o;
+  return *error_category;
 }





More information about the llvm-commits mailing list