From c5069ad26c72412637429f04451aa1c7b34aa479 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 17 Oct 2012 22:11:14 +0000 Subject: [PATCH] Fixed ClangASTContext to own its TargetOptions using a reference-counted pointer. This avoids memory-management problems when the TargetOptions are deleted. llvm-svn: 166132 --- lldb/include/lldb/Symbol/ClangASTContext.h | 2 +- lldb/source/Symbol/ClangASTContext.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 9f2c038563d4..a7d15c1c0959 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -977,7 +977,7 @@ protected: std::auto_ptr m_source_manager_ap; std::auto_ptr m_diagnostics_engine_ap; std::auto_ptr m_diagnostic_consumer_ap; - std::auto_ptr m_target_options_ap; + llvm::IntrusiveRefCntPtr m_target_options_rp; std::auto_ptr m_target_info_ap; std::auto_ptr m_identifier_table_ap; std::auto_ptr m_selector_table_ap; diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 70f4af17749f..6a77c3fc729b 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -379,7 +379,7 @@ ClangASTContext::ClangASTContext (const char *target_triple) : m_language_options_ap(), m_source_manager_ap(), m_diagnostics_engine_ap(), - m_target_options_ap(), + m_target_options_rp(), m_target_info_ap(), m_identifier_table_ap(), m_selector_table_ap(), @@ -402,7 +402,7 @@ ClangASTContext::~ClangASTContext() m_selector_table_ap.reset(); m_identifier_table_ap.reset(); m_target_info_ap.reset(); - m_target_options_ap.reset(); + m_target_options_rp.reset(); m_diagnostics_engine_ap.reset(); m_source_manager_ap.reset(); m_language_options_ap.reset(); @@ -417,7 +417,7 @@ ClangASTContext::Clear() m_language_options_ap.reset(); m_source_manager_ap.reset(); m_diagnostics_engine_ap.reset(); - m_target_options_ap.reset(); + m_target_options_rp.reset(); m_target_info_ap.reset(); m_identifier_table_ap.reset(); m_selector_table_ap.reset(); @@ -609,13 +609,14 @@ ClangASTContext::getDiagnosticConsumer() TargetOptions * ClangASTContext::getTargetOptions() { - if (m_target_options_ap.get() == NULL && !m_target_triple.empty()) + if (m_target_options_rp.getPtr() == NULL && !m_target_triple.empty()) { - m_target_options_ap.reset (new TargetOptions()); - if (m_target_options_ap.get()) - m_target_options_ap->Triple = m_target_triple; + m_target_options_rp.reset (); + m_target_options_rp = new TargetOptions(); + if (m_target_options_rp.getPtr() != NULL) + m_target_options_rp->Triple = m_target_triple; } - return m_target_options_ap.get(); + return m_target_options_rp.getPtr(); } -- GitLab