[Lldb-commits] [lldb] r223916 - ClangFunction: Fix destruction order of parser and execution unit

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Dec 9 20:59:18 PST 2014


Author: dexonsmith
Date: Tue Dec  9 22:59:18 2014
New Revision: 223916

URL: http://llvm.org/viewvc/llvm-project?rev=223916&view=rev
Log:
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.

Modified:
    lldb/trunk/include/lldb/Expression/ClangFunction.h
    lldb/trunk/source/Expression/ClangFunction.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=223916&r1=223915&r2=223916&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangFunction.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangFunction.h Tue Dec  9 22:59:18 2014
@@ -411,8 +411,10 @@ private:
     // For ClangFunction only
     //------------------------------------------------------------------
 
-    std::unique_ptr<ClangExpressionParser> 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<IRExecutionUnit> m_execution_unit_sp;
+    std::unique_ptr<ClangExpressionParser> 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.
     

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=223916&r1=223915&r2=223916&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Dec  9 22:59:18 2014
@@ -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 : "<unknown>"),
     m_function_ptr (NULL),





More information about the lldb-commits mailing list