From f3079d276268af8319e2a43b2d59af3763058584 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 10 Dec 2014 04:59:18 +0000 Subject: [PATCH] ClangFunction: Fix destruction order of parser and execution unit Fix PR21802 by correcting the destruction order of `ClangExpressionParser` and `IRExecutionUnit` in `ClangFunction`. The former has hooks into the latter -- i.e., `clang::CGDebugInfo` points at the `LLVMContext` -- so it needs to be torn down first. This was exposed by r223802 in LLVM, which started doing work in the `CGDebugInfo` teardown. llvm-svn: 223916 --- lldb/include/lldb/Expression/ClangFunction.h | 4 +++- lldb/source/Expression/ClangFunction.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Expression/ClangFunction.h b/lldb/include/lldb/Expression/ClangFunction.h index 476bf7d92edd..c122b21be279 100644 --- a/lldb/include/lldb/Expression/ClangFunction.h +++ b/lldb/include/lldb/Expression/ClangFunction.h @@ -411,8 +411,10 @@ private: // For ClangFunction only //------------------------------------------------------------------ - std::unique_ptr m_parser; ///< The parser responsible for compiling the function. + // Note: the parser needs to be destructed before the execution unit, so + // declare the the execution unit first. std::shared_ptr m_execution_unit_sp; + std::unique_ptr m_parser; ///< The parser responsible for compiling the function. lldb::ModuleWP m_jit_module_wp; std::string m_name; ///< The name of this clang function - for debugging purposes. diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index 5654e654cdbe..b438dacdfabc 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -57,8 +57,8 @@ ClangFunction::ClangFunction const ValueList &arg_value_list, const char *name ) : - m_parser(), m_execution_unit_sp(), + m_parser(), m_jit_module_wp(), m_name (name ? name : ""), m_function_ptr (NULL),