Extended the lifetime of Clang parser objects to the

lifetime of ClangExpressionDeclMap.  This allows
ClangExpressionVariables found during parsing to be
queried for their containing namespaces during
expression execution.

Other clients (like ClangFunction) explicitly delete
this state, so they should not result in any memory
leaks.

llvm-svn: 141821
This commit is contained in:
Sean Callanan
2011-10-12 22:20:02 +00:00
parent 154a967c23
commit e3aef1d063
2 changed files with 11 additions and 4 deletions

View File

@@ -61,6 +61,11 @@ ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory) :
ClangExpressionDeclMap::~ClangExpressionDeclMap()
{
// Note: The model is now that the parser's AST context and all associated
// data does not vanish until the expression has been executed. This means
// that valuable lookup data (like namespaces) doesn't vanish, but
DidParse();
DidDematerialize();
DisableStructVars();
}
@@ -933,6 +938,9 @@ ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
if (expr_var_sp)
{
if (!expr_var_sp->m_parser_vars.get())
return Value();
const ConstString &name(expr_var_sp->GetName());
TypeFromUser type(expr_var_sp->GetTypeFromUser());
@@ -1621,7 +1629,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
Process *process = exe_ctx.GetProcessPtr();
StackFrame *frame = exe_ctx.GetFramePtr();
if (!frame || !process || !target)
if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get())
return false;
// Vital information about the value

View File

@@ -276,9 +276,7 @@ ClangUserExpression::Parse (Stream &error_stream,
log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str());
}
m_expr_decl_map->DidParse();
if (jit_error.Success())
{
if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
@@ -449,6 +447,7 @@ ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
return false;
}
return true;
}