fix(*): static variable initialization problems

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-06-06 18:44:12 -07:00
parent 3562c76161
commit 89a7898054
2 changed files with 5 additions and 11 deletions

View file

@ -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, expr_hash, is_bi_equal_proc> expr_cache;
static std::unique_ptr<expr_cache> 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;

View file

@ -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<option_declarations> 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() {