aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2023-05-28 22:10:35 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-06-30 17:15:14 +0000
commitd96093d97b5ab84005a2bc615dda953a53f97cd1 (patch)
tree8e1cd0c692be9ea953cadba4e080c6b5ee7c94b7 /gcc/rust/hir
parent9d3f1985720417f969b1156871e9244a21490e43 (diff)
downloadgcc-d96093d97b5ab84005a2bc615dda953a53f97cd1.zip
gcc-d96093d97b5ab84005a2bc615dda953a53f97cd1.tar.gz
gcc-d96093d97b5ab84005a2bc615dda953a53f97cd1.tar.bz2
gccrs: cleanup getters to return &unique_ptr instead of pointer
Make all getter methods in HIR classes return a unique_ptr reference instead of a pointer and adjust all callers. gcc/rust/ChangeLog: * hir/tree/rust-hir-type.h (ArrayType::get_element_type): Returns unique_ptr. * hir/tree/rust-hir-expr.h (ArithmeticOrLogicalExpr::get_lhs) (ArithmeticOrLogicalExpr::get_rhs): Likewise. (ComparisonExpr::get_lhs, ComparisonExpr::get_rhs): Likewise. (LazyBooleanExpr::get_lhs, LazyBooleanExpr::get_rhs): Likewise. (AssignmentExpr::get_lhs, AssignmentExpr::get_rhs): Likewise. (ArrayExpr::get_internal_elements): Likewise. (ArrayIndexExpr::get_index_expr, ArrayIndexExpr::get_array_expr): Likewise. (StructExprFieldWithVal::get_value): Likewise. (IfExpr::get_if_condition, IfExpr::get_if_block): Likewise. (ExprWithBlock::get_else_block): Likewise. * hir/tree/rust-hir-item.h (FunctionParam::get_param_name) (FunctionParam::get_type): Likewise. (ConstantItem::get_type, ConstantItem::get_expr): Likewise. (StaticItem::get_expr, StaticItem::get_type): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Adjust for previous change. * backend/rust-compile-block.cc (CompileConditionalBlocks::visit): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h34
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h12
-rw-r--r--gcc/rust/hir/tree/rust-hir-type.h4
3 files changed, 26 insertions, 24 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index bf8bc68..421ab23 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -387,8 +387,8 @@ public:
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
- Expr *get_lhs () { return main_or_left_expr.get (); }
- Expr *get_rhs () { return right_expr.get (); }
+ std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
+ std::unique_ptr<Expr> &get_rhs () { return right_expr; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -459,8 +459,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- Expr *get_lhs () { return main_or_left_expr.get (); }
- Expr *get_rhs () { return right_expr.get (); }
+ std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
+ std::unique_ptr<Expr> &get_rhs () { return right_expr; }
ExprType get_kind () { return expr_type; }
@@ -533,9 +533,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- Expr *get_lhs () { return main_or_left_expr.get (); }
-
- Expr *get_rhs () { return right_expr.get (); }
+ std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
+ std::unique_ptr<Expr> &get_rhs () { return right_expr; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -667,8 +666,8 @@ public:
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
- Expr *get_lhs () { return main_or_left_expr.get (); }
- Expr *get_rhs () { return right_expr.get (); }
+ std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
+ std::unique_ptr<Expr> &get_rhs () { return right_expr; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -1039,7 +1038,10 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- ArrayElems *get_internal_elements () { return internal_elements.get (); };
+ std::unique_ptr<ArrayElems> &get_internal_elements ()
+ {
+ return internal_elements;
+ };
ExprType get_expression_type () const override final
{
@@ -1105,8 +1107,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- Expr *get_array_expr () { return array_expr.get (); }
- Expr *get_index_expr () { return index_expr.get (); }
+ std::unique_ptr<Expr> &get_array_expr () { return array_expr; }
+ std::unique_ptr<Expr> &get_index_expr () { return index_expr; }
ExprType get_expression_type () const override final
{
@@ -1516,7 +1518,7 @@ protected:
public:
std::string as_string () const override;
- Expr *get_value () { return value.get (); }
+ std::unique_ptr<Expr> &get_value () { return value; }
};
// Identifier and value variant of StructExprField HIR node
@@ -3252,8 +3254,8 @@ public:
void vis_if_condition (HIRFullVisitor &vis) { condition->accept_vis (vis); }
void vis_if_block (HIRFullVisitor &vis) { if_block->accept_vis (vis); }
- Expr *get_if_condition () { return condition.get (); }
- BlockExpr *get_if_block () { return if_block.get (); }
+ std::unique_ptr<Expr> &get_if_condition () { return condition; }
+ std::unique_ptr<BlockExpr> &get_if_block () { return if_block; }
ExprType get_expression_type () const final override { return ExprType::If; }
@@ -3316,7 +3318,7 @@ public:
void vis_else_block (HIRFullVisitor &vis) { else_block->accept_vis (vis); }
- ExprWithBlock *get_else_block () { return else_block.get (); }
+ std::unique_ptr<ExprWithBlock> &get_else_block () { return else_block; }
protected:
/* Use covariance to implement clone function as returning this object rather
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index 8fdfa5f..8932c55 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -551,9 +551,9 @@ public:
Location get_locus () const { return locus; }
- Pattern *get_param_name () { return param_name.get (); }
+ std::unique_ptr<Pattern> &get_param_name () { return param_name; }
- Type *get_type () { return type.get (); }
+ std::unique_ptr<Type> &get_type () { return type; }
const Analysis::NodeMapping &get_mappings () const { return mappings; }
};
@@ -2129,9 +2129,9 @@ public:
void accept_vis (HIRImplVisitor &vis) override;
void accept_vis (HIRVisItemVisitor &vis) override;
- Type *get_type () { return type.get (); }
+ std::unique_ptr<Type> &get_type () { return type; }
- Expr *get_expr () { return const_expr.get (); }
+ std::unique_ptr<Expr> &get_expr () { return const_expr; }
Identifier get_identifier () const { return identifier; }
@@ -2225,9 +2225,9 @@ public:
bool is_mut () const { return mut == Mutability::Mut; }
- Expr *get_expr () { return expr.get (); }
+ std::unique_ptr<Expr> &get_expr () { return expr; }
- Type *get_type () { return type.get (); }
+ std::unique_ptr<Type> &get_type () { return type; }
ItemKind get_item_kind () const override { return ItemKind::Static; }
diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h
index 2e7df10..8f09896 100644
--- a/gcc/rust/hir/tree/rust-hir-type.h
+++ b/gcc/rust/hir/tree/rust-hir-type.h
@@ -570,9 +570,9 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- Type *get_element_type () { return elem_type.get (); }
+ std::unique_ptr<Type> &get_element_type () { return elem_type; }
- Expr *get_size_expr () { return size.get (); }
+ std::unique_ptr<Expr> &get_size_expr () { return size; }
protected:
/* Use covariance to implement clone function as returning this object rather