mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 06:40:01 +08:00
Support expressions in the context of a reference
...type variable by dereferencing the variable before evaluating the expression. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D128126
This commit is contained in:
committed by
Pavel Labath
parent
ed63fcb232
commit
6a85b9d163
@@ -145,8 +145,9 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
|
||||
Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
|
||||
|
||||
if (ctx_obj) {
|
||||
static unsigned const ctx_type_mask =
|
||||
lldb::TypeFlags::eTypeIsClass | lldb::TypeFlags::eTypeIsStructUnion;
|
||||
static unsigned const ctx_type_mask = lldb::TypeFlags::eTypeIsClass |
|
||||
lldb::TypeFlags::eTypeIsStructUnion |
|
||||
lldb::TypeFlags::eTypeIsReference;
|
||||
if (!(ctx_obj->GetTypeInfo() & ctx_type_mask)) {
|
||||
LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context object of "
|
||||
"an invalid type, can't run expressions.");
|
||||
@@ -155,6 +156,21 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx_obj && ctx_obj->GetTypeInfo() & lldb::TypeFlags::eTypeIsReference) {
|
||||
Status error;
|
||||
lldb::ValueObjectSP deref_ctx_sp = ctx_obj->Dereference(error);
|
||||
if (!error.Success()) {
|
||||
LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context object of "
|
||||
"a reference type that can't be dereferenced, can't run "
|
||||
"expressions.");
|
||||
error.SetErrorString(
|
||||
"passed context object of an reference type cannot be deferenced");
|
||||
return lldb::eExpressionSetupError;
|
||||
}
|
||||
|
||||
ctx_obj = deref_ctx_sp.get();
|
||||
}
|
||||
|
||||
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
|
||||
lldb::LanguageType language = options.GetLanguage();
|
||||
const ResultType desired_type = options.DoesCoerceToId()
|
||||
|
||||
Reference in New Issue
Block a user