Skip to content

Commit 8b63dfd

Browse files
committed
Rename rhs to operand, remove extra check and return ValueObject::Dereference error, cleanup code.
1 parent 336d59f commit 8b63dfd

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

lldb/include/lldb/ValueObject/DILAST.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ class IdentifierNode : public ASTNode {
9090

9191
class UnaryOpNode : public ASTNode {
9292
public:
93-
UnaryOpNode(uint32_t location, UnaryOpKind kind, ASTNodeUP rhs)
93+
UnaryOpNode(uint32_t location, UnaryOpKind kind, ASTNodeUP operand)
9494
: ASTNode(location, NodeKind::eUnaryOpNode), m_kind(kind),
95-
m_rhs(std::move(rhs)) {}
95+
m_operand(std::move(operand)) {}
9696

9797
llvm::Expected<lldb::ValueObjectSP> Accept(Visitor *v) const override;
9898

9999
UnaryOpKind kind() const { return m_kind; }
100-
ASTNode *rhs() const { return m_rhs.get(); }
100+
ASTNode *operand() const { return m_operand.get(); }
101101

102102
static bool classof(const ASTNode *node) {
103103
return node->GetKind() == NodeKind::eUnaryOpNode;
104104
}
105105

106106
private:
107107
UnaryOpKind m_kind;
108-
ASTNodeUP m_rhs;
108+
ASTNodeUP m_operand;
109109
};
110110

111111
/// This class contains one Visit method for each specialized type of

lldb/source/ValueObject/DILEval.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ Interpreter::Visit(const IdentifierNode *node) {
237237
llvm::Expected<lldb::ValueObjectSP>
238238
Interpreter::Visit(const UnaryOpNode *node) {
239239
Status error;
240-
auto rhs_or_err = Evaluate(node->rhs());
241-
if (!rhs_or_err) {
240+
auto rhs_or_err = Evaluate(node->operand());
241+
if (!rhs_or_err)
242242
return rhs_or_err;
243-
}
243+
244244
lldb::ValueObjectSP rhs = *rhs_or_err;
245245

246246
switch (node->kind()) {
@@ -249,30 +249,26 @@ Interpreter::Visit(const UnaryOpNode *node) {
249249
if (dynamic_rhs)
250250
rhs = dynamic_rhs;
251251

252-
CompilerType rhs_type = rhs->GetCompilerType();
253-
if (!rhs_type.IsReferenceType() && !rhs_type.IsPointerType())
254-
return llvm::make_error<DILDiagnosticError>(
255-
m_expr, "not a pointer or reference type",
256-
node->rhs()->GetLocation());
257-
258-
if (rhs_type.IsPointerToVoid()) {
252+
if (rhs->GetCompilerType().IsPointerToVoid()) {
259253
return llvm::make_error<DILDiagnosticError>(
260254
m_expr, "indirection not permitted on operand of type 'void *'",
261255
node->GetLocation());
262256
}
257+
263258
lldb::ValueObjectSP child_sp = rhs->Dereference(error);
264-
if (error.Success())
265-
rhs = child_sp;
259+
if (error.Fail())
260+
return llvm::make_error<DILDiagnosticError>(m_expr, error.AsCString(),
261+
node->GetLocation());
266262

267-
return rhs;
263+
return child_sp;
268264
}
269265
case UnaryOpKind::AddrOf: {
270266
Status error;
271267
lldb::ValueObjectSP value = rhs->AddressOf(error);
272-
if (error.Fail()) {
268+
if (error.Fail())
273269
return llvm::make_error<DILDiagnosticError>(m_expr, error.AsCString(),
274270
node->GetLocation());
275-
}
271+
276272
return value;
277273
}
278274
}
@@ -282,4 +278,4 @@ Interpreter::Visit(const UnaryOpNode *node) {
282278
m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
283279
}
284280

285-
} // namespace lldb_private::dil
281+
} // namespace lldb_private::dil

0 commit comments

Comments
 (0)