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

David Blaikie dblaikie at gmail.com
Fri Sep 19 15:44:43 PDT 2014


On Fri, Sep 19, 2014 at 3:09 PM, Chris Bieneman <beanz at apple.com> wrote:

> 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.
>

Hmm. Pity. In C++14 std::error_category's ctor is required to be
constexpr... well, one day when we adopt C++14 we can remove this
workaround.


>
> 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;
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140919/1f725169/attachment.html>


More information about the llvm-commits mailing list