================ @@ -232,4 +263,105 @@ Interpreter::Visit(const IdentifierNode *node) { return identifier; } -} // namespace lldb_private::dil +llvm::Expected<lldb::ValueObjectSP> +Interpreter::Visit(const UnaryOpNode *node) { + FlowAnalysis rhs_flow( + /* address_of_is_pending */ node->kind() == UnaryOpKind::AddrOf); + + Status error; + auto rhs_or_err = EvaluateNode(node->rhs(), &rhs_flow); + if (!rhs_or_err) { + return rhs_or_err; + } + lldb::ValueObjectSP rhs = *rhs_or_err; + + CompilerType rhs_type = rhs->GetCompilerType(); + switch (node->kind()) { + case UnaryOpKind::Deref: { + if (rhs_type.IsArrayType()) + rhs = ArrayToPointerConversion(rhs, m_exe_ctx_scope); + + lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_default_dynamic); + if (dynamic_rhs) + rhs = dynamic_rhs; + + if (rhs->GetCompilerType().IsPointerType()) { + if (rhs->GetCompilerType().IsPointerToVoid()) { + return llvm::make_error<DILDiagnosticError>( + m_expr, "indirection not permitted on operand of type 'void *'", + node->GetLocation(), 1); + } + return EvaluateDereference(rhs); + } + lldb::ValueObjectSP child_sp = rhs->Dereference(error); + if (error.Success()) + rhs = child_sp; + + return rhs; + } + case UnaryOpKind::AddrOf: { + if (node->rhs()->is_rvalue()) { ---------------- kuilpd wrote:
>From what I could gather, the first one is `ValueObject::AddressOf` that >creates a `ValueObjectConstResult` and fills in its address. The second one >calls `ValueObjectConstResultImpl::AddressOf` that also creates >`ValueObjectConstResult` but with no address this time (which makes sense for >a const value), so the third one fails. I'm guessing that the first `ValueObjectConstResult` is pretty much an implementation of a reference, so it has to have an address behind it so it can be dereferenced normally. https://github.com/llvm/llvm-project/pull/134428 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits