Skip to content

Commit 394e36d

Browse files
committed
Fixed a leak of ASTStructExtractors and also
made sure we don't keep around no-longer-valid ASTTransformers. <rdar://problem/15182379> llvm-svn: 192333
1 parent 762df1f commit 394e36d

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lldb/include/lldb/Expression/ClangFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ class ClangFunction : public ClangExpression
630630
std::string m_wrapper_struct_name; ///< The name of the struct that contains the target function address, arguments, and result.
631631
std::list<lldb::addr_t> m_wrapper_args_addrs; ///< The addresses of the arguments to the wrapper function.
632632

633+
std::unique_ptr<ASTStructExtractor> m_struct_extractor; ///< The class that generates the argument struct below.
634+
633635
bool m_struct_valid; ///< True if the ASTStructExtractor has populated the variables below.
634636

635637
//------------------------------------------------------------------

lldb/source/Expression/ClangFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,5 +628,7 @@ ClangFunction::ExecuteFunction(
628628
clang::ASTConsumer *
629629
ClangFunction::ASTTransformer (clang::ASTConsumer *passthrough)
630630
{
631-
return new ASTStructExtractor(passthrough, m_wrapper_struct_name.c_str(), *this);
631+
m_struct_extractor.reset(new ASTStructExtractor(passthrough, m_wrapper_struct_name.c_str(), *this));
632+
633+
return m_struct_extractor.get();
632634
}

lldb/source/Expression/ClangUserExpression.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,9 @@ ClangUserExpression::~ClangUserExpression ()
9595

9696
clang::ASTConsumer *
9797
ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
98-
{
99-
ClangASTContext *clang_ast_context = m_target->GetScratchClangASTContext();
100-
101-
if (!clang_ast_context)
102-
return NULL;
103-
104-
if (!m_result_synthesizer.get())
105-
m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
106-
*m_target));
98+
{
99+
m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
100+
*m_target));
107101

108102
return m_result_synthesizer.get();
109103
}

0 commit comments

Comments
 (0)