[Lldb-commits] [lldb] r141452 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h include/lldb/lldb-forward.h source/Expression/ClangUserExpression.cpp

Sean Callanan scallanan at apple.com
Fri Oct 7 17:21:35 PDT 2011


Author: spyffe
Date: Fri Oct  7 19:21:35 2011
New Revision: 141452

URL: http://llvm.org/viewvc/llvm-project?rev=141452&view=rev
Log:
Fixed a memory leak of ASTResultSynthesizers,
by attaching them to the ClangExpressionParser.

Modified:
    lldb/trunk/include/lldb/Expression/ClangUserExpression.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/source/Expression/ClangUserExpression.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=141452&r1=141451&r2=141452&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Fri Oct  7 19:21:35 2011
@@ -325,6 +325,8 @@
     std::auto_ptr<ClangExpressionVariableList>  m_local_variables;      ///< The local expression variables, if the expression is DWARF.
     std::auto_ptr<ProcessDataAllocator>         m_data_allocator;       ///< The allocator that the parser uses to place strings for use by JIT-compiled code.
     
+    std::auto_ptr<ASTResultSynthesizer>         m_result_synthesizer;   ///< The result synthesizer, if one is needed.
+    
     bool                                        m_cplusplus;            ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method).
     bool                                        m_objectivec;           ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method).
     bool                                        m_needs_object_ptr;     ///< True if "this" or "self" must be looked up and passed in.  False if the expression doesn't really use them and they can be NULL.

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=141452&r1=141451&r2=141452&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Fri Oct  7 19:21:35 2011
@@ -24,6 +24,7 @@
 class   AddressResolver;
 class   ArchSpec;
 class   Args;
+class   ASTResultSynthesizer;
 class   Baton;
 class   Block;
 class   Breakpoint;

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=141452&r1=141451&r2=141452&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Oct  7 19:21:35 2011
@@ -72,10 +72,13 @@
     if (!clang_ast_context)
         return NULL;
     
-    return new ASTResultSynthesizer(passthrough,
-                                    m_desired_type,
-                                    *m_target->GetScratchClangASTContext()->getASTContext(),
-                                    m_target->GetPersistentVariables());
+    if (!m_result_synthesizer.get())
+        m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
+                                                            m_desired_type,
+                                                            *m_target->GetScratchClangASTContext()->getASTContext(),
+                                                            m_target->GetPersistentVariables()));
+    
+    return m_result_synthesizer.get();
 }
 
 void





More information about the lldb-commits mailing list