diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-03-08 14:42:10 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-21 12:32:57 +0100 |
commit | d123f43e42f623dfd7dbe63f484197a99ea7f9ed (patch) | |
tree | 0955456af6fb2891ec313f8b63ecb6e3929f46fa /gcc/rust/hir/tree/rust-hir-expr.h | |
parent | c29a3bc945c2d018f75974c12c29aaf99a978984 (diff) | |
download | gcc-d123f43e42f623dfd7dbe63f484197a99ea7f9ed.zip gcc-d123f43e42f623dfd7dbe63f484197a99ea7f9ed.tar.gz gcc-d123f43e42f623dfd7dbe63f484197a99ea7f9ed.tar.bz2 |
gccrs: Refactor HIR with optionals, references & newtypes
The HIR made heavy use of pair and other unamed types which can be
difficult to read.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: Use FnParam getter.
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
* backend/rust-compile-intrinsic.cc: Likewise.
* backend/rust-compile-type.cc: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
Only visit childrens if not missing.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Use
a reference instead of a raw pointer.
* hir/tree/rust-hir-expr.h: Add presence function for return
expression.
* hir/tree/rust-hir-item.h: Remove take_param_name.
* hir/tree/rust-hir.h: Make mapping getter const.
* typecheck/rust-hir-dot-operator.cc (MethodResolver::Select): Use
getter.
* typecheck/rust-hir-type-check-expr.cc: Likewise.
* typecheck/rust-hir-type-check-implitem.cc: Use FnParam vector instead
of std::pair of Pattern and BaseType.
* typecheck/rust-hir-type-check-item.cc: Likewise.
* typecheck/rust-hir-type-check.cc: Likewise.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Use getters.
(TypeCheckMethodCallExpr::check): Likewise.
* typecheck/rust-tyty-cmp.h: Likewise.
* typecheck/rust-tyty.cc: Use FnParam.
* typecheck/rust-tyty.h (class FnParam): Add FnParam to handle function
parameters instead of handling std::pairs.
* typecheck/rust-unify.cc (UnifyRules::expect_fndef): Use getters.
(UnifyRules::expect_fnptr): Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/hir/tree/rust-hir-expr.h')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-expr.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 692b9b4..c66b549 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -2238,6 +2238,7 @@ public: bool is_final_stmt (Stmt *stmt) { return statements.back ().get () == stmt; } + bool has_final_expr () { return expr != nullptr; } Expr &get_final_expr () { return *expr; } std::vector<std::unique_ptr<Stmt> > &get_statements () { return statements; } @@ -2785,6 +2786,7 @@ public: void accept_vis (HIRFullVisitor &vis) override; void accept_vis (HIRExpressionVisitor &vis) override; + bool has_expr () { return return_expr != nullptr; } Expr &get_expr () { return *return_expr; } ExprType get_expression_type () const override final |