From 2e3e60036006200ab00e556a7e501a6d6a8d766a Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Tue, 17 Oct 2023 16:21:56 +0200 Subject: [PATCH] hir: Rename ComoundAssignment getters Use more a consistent name. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Rename method. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-expr.h: Rename method. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method. * typecheck/rust-tyty.h: Rename method. --- gcc/rust/backend/rust-compile-expr.cc | 8 ++++---- .../checks/errors/privacy/rust-privacy-reporter.cc | 4 ++-- gcc/rust/checks/errors/rust-const-checker.cc | 4 ++-- gcc/rust/checks/errors/rust-unsafe-checker.cc | 4 ++-- gcc/rust/hir/rust-hir-dump.cc | 2 +- gcc/rust/hir/tree/rust-hir-expr.h | 4 ++-- gcc/rust/typecheck/rust-hir-type-check-expr.cc | 10 ++++------ gcc/rust/typecheck/rust-tyty.h | 2 ++ 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 351d5d7242fd..5f4ce5411cee 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -184,8 +184,8 @@ void CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) { auto op = expr.get_expr_type (); - auto lhs = CompileExpr::Compile (expr.get_left_expr ().get (), ctx); - auto rhs = CompileExpr::Compile (expr.get_right_expr ().get (), ctx); + auto lhs = CompileExpr::Compile (expr.get_lhs ().get (), ctx); + auto rhs = CompileExpr::Compile (expr.get_rhs ().get (), ctx); // this might be an operator overload situation lets check TyTy::FnType *fntype; @@ -198,8 +198,8 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) expr.get_expr_type ()); auto compound_assignment = resolve_operator_overload (lang_item_type, expr, lhs, rhs, - expr.get_left_expr ().get (), - expr.get_right_expr ().get ()); + expr.get_lhs ().get (), + expr.get_rhs ().get ()); ctx->add_statement (compound_assignment); return; diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc index 6bdc2fa17a70..81f678dabaaa 100644 --- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc +++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc @@ -375,8 +375,8 @@ PrivacyReporter::visit (HIR::AssignmentExpr &expr) void PrivacyReporter::visit (HIR::CompoundAssignmentExpr &expr) { - expr.get_left_expr ()->accept_vis (*this); - expr.get_right_expr ()->accept_vis (*this); + expr.get_lhs ()->accept_vis (*this); + expr.get_rhs ()->accept_vis (*this); } void diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index 22668d5d7bb7..032a8ec9f3aa 100644 --- a/gcc/rust/checks/errors/rust-const-checker.cc +++ b/gcc/rust/checks/errors/rust-const-checker.cc @@ -214,8 +214,8 @@ ConstChecker::visit (AssignmentExpr &expr) void ConstChecker::visit (CompoundAssignmentExpr &expr) { - expr.get_left_expr ()->accept_vis (*this); - expr.get_right_expr ()->accept_vis (*this); + expr.get_lhs ()->accept_vis (*this); + expr.get_rhs ()->accept_vis (*this); } void diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.cc b/gcc/rust/checks/errors/rust-unsafe-checker.cc index d5b772b2063d..bee446f57060 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.cc +++ b/gcc/rust/checks/errors/rust-unsafe-checker.cc @@ -327,8 +327,8 @@ UnsafeChecker::visit (AssignmentExpr &expr) void UnsafeChecker::visit (CompoundAssignmentExpr &expr) { - expr.get_left_expr ()->accept_vis (*this); - expr.get_right_expr ()->accept_vis (*this); + expr.get_lhs ()->accept_vis (*this); + expr.get_rhs ()->accept_vis (*this); } void diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index c3e1cd3c07a6..8e31f2774382 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -983,7 +983,7 @@ Dump::visit (CompoundAssignmentExpr &e) begin ("CompoundAssignmentExpr"); do_operatorexpr (e); - visit_field ("right_expr", *e.get_right_expr ()); + visit_field ("right_expr", *e.get_rhs ()); std::string str; diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index abed61c1222a..c5abeaa23a05 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -762,9 +762,9 @@ class CompoundAssignmentExpr : public OperatorExpr void accept_vis (HIRFullVisitor &vis) override; void accept_vis (HIRExpressionVisitor &vis) override; - std::unique_ptr &get_left_expr () { return main_or_left_expr; } + std::unique_ptr &get_lhs () { return main_or_left_expr; } - std::unique_ptr &get_right_expr () { return right_expr; } + std::unique_ptr &get_rhs () { return right_expr; } void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); } void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); } diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 3a63d3b9e5d9..9f1ee012851a 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -249,16 +249,14 @@ TypeCheckExpr::visit (HIR::CompoundAssignmentExpr &expr) { infered = TyTy::TupleType::get_unit_type (expr.get_mappings ().get_hirid ()); - auto lhs = TypeCheckExpr::Resolve (expr.get_left_expr ().get ()); - auto rhs = TypeCheckExpr::Resolve (expr.get_right_expr ().get ()); + auto lhs = TypeCheckExpr::Resolve (expr.get_lhs ().get ()); + auto rhs = TypeCheckExpr::Resolve (expr.get_rhs ().get ()); // we dont care about the result of the unify from a compound assignment // since this is a unit-type expr coercion_site (expr.get_mappings ().get_hirid (), - TyTy::TyWithLocation (lhs, - expr.get_left_expr ()->get_locus ()), - TyTy::TyWithLocation (rhs, - expr.get_right_expr ()->get_locus ()), + TyTy::TyWithLocation (lhs, expr.get_lhs ()->get_locus ()), + TyTy::TyWithLocation (rhs, expr.get_rhs ()->get_locus ()), expr.get_locus ()); auto lang_item_type diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 6391bd7be73f..212ebc975704 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -1012,6 +1012,8 @@ class ArrayType : public BaseType private: TyVar element_type; + // FIXME: I dont think this should be in tyty - tyty should already be const + // evaluated HIR::Expr &capacity_expr; };