From 89a789805423687584d40ab362e6affac632e14d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 6 Jun 2014 18:44:12 -0700 Subject: [PATCH] fix(*): static variable initialization problems Signed-off-by: Leonardo de Moura --- src/kernel/expr.cpp | 8 +++----- src/util/sexpr/options.cpp | 8 ++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/kernel/expr.cpp b/src/kernel/expr.cpp index 4fe5ffdff..5bc64b177 100644 --- a/src/kernel/expr.cpp +++ b/src/kernel/expr.cpp @@ -267,14 +267,12 @@ expr_macro::~expr_macro() { // Constructors #ifdef LEAN_CACHE_EXPRS +static bool LEAN_THREAD_LOCAL g_expr_cache_enabled = true; typedef lru_cache expr_cache; -static std::unique_ptr LEAN_THREAD_LOCAL g_expr_cache; -static bool LEAN_THREAD_LOCAL g_expr_cache_enabled = true; inline expr cache(expr const & e) { if (g_expr_cache_enabled) { - if (!g_expr_cache) - g_expr_cache.reset(new expr_cache(LEAN_INITIAL_EXPR_CACHE_CAPACITY)); - if (auto r = g_expr_cache->insert(e)) + static expr_cache LEAN_THREAD_LOCAL g_expr_cache(LEAN_INITIAL_EXPR_CACHE_CAPACITY); + if (auto r = g_expr_cache.insert(e)) return *r; } return e; diff --git a/src/util/sexpr/options.cpp b/src/util/sexpr/options.cpp index c4669d0e8..20b451ee2 100644 --- a/src/util/sexpr/options.cpp +++ b/src/util/sexpr/options.cpp @@ -32,13 +32,9 @@ std::ostream & operator<<(std::ostream & out, option_kind k) { return out; } -// Replace with std::unique_ptr after bug in clang++ is fixed -static std::shared_ptr g_option_declarations; - option_declarations & get_option_declarations_core() { - if (!g_option_declarations) - g_option_declarations.reset(new option_declarations()); - return *g_option_declarations; + static option_declarations g_option_declarations; + return g_option_declarations; } option_declarations const & get_option_declarations() {