aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-27 12:00:22 +0000
committerGitHub <noreply@github.com>2021-06-27 12:00:22 +0000
commit54e0d0171932b7c43e69f685e5fe41d473ddf5bf (patch)
tree4377b51b6e97974561e71d148b73b31cc3fe3426 /gcc/rust
parent51d86210d3dcbbf4dea14149f90ad9087b006f6a (diff)
parent5ff37842fb091ebc79d87b5e7770bc335f2a8591 (diff)
downloadgcc-54e0d0171932b7c43e69f685e5fe41d473ddf5bf.zip
gcc-54e0d0171932b7c43e69f685e5fe41d473ddf5bf.tar.gz
gcc-54e0d0171932b7c43e69f685e5fe41d473ddf5bf.tar.bz2
Merge #529
529: Marking live symbol in break, return, while, whilelet, for expr r=philberty a=thomasyonug Marking live symbol in break, return, while, whilelet, for expr without test case for last two due to unimplemented. Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h4
-rw-r--r--gcc/rust/lint/rust-lint-marklive.h35
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index f718a61..681ccf8 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -3387,6 +3387,8 @@ public:
void accept_vis (HIRVisitor &vis) override;
+ std::unique_ptr<Expr> &get_cond () { return condition; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -3450,6 +3452,8 @@ public:
void accept_vis (HIRVisitor &vis) override;
+ std::unique_ptr<Expr> &get_iterator_expr () { return iterator_expr; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h
index 67dd76a..d34587d 100644
--- a/gcc/rust/lint/rust-lint-marklive.h
+++ b/gcc/rust/lint/rust-lint-marklive.h
@@ -103,11 +103,46 @@ public:
}
}
+ void visit (HIR::LoopExpr &expr) override
+ {
+ expr.get_loop_block ()->accept_vis (*this);
+ }
+
+ void visit (HIR::BreakExpr &expr) override
+ {
+ if (expr.has_break_expr ())
+ expr.get_expr ()->accept_vis (*this);
+ }
+
+ void visit (HIR::WhileLoopExpr &expr) override
+ {
+ expr.get_loop_block ()->accept_vis (*this);
+ expr.get_predicate_expr ()->accept_vis (*this);
+ }
+
void visit (HIR::Function &function) override
{
function.get_definition ().get ()->accept_vis (*this);
}
+ void visit (HIR::ReturnExpr &expr) override
+ {
+ if (expr.has_return_expr ())
+ expr.get_expr ()->accept_vis (*this);
+ }
+
+ void visit (HIR::WhileLetLoopExpr &expr) override
+ {
+ expr.get_loop_block ()->accept_vis (*this);
+ expr.get_cond ()->accept_vis (*this);
+ }
+
+ void visit (HIR::ForLoopExpr &expr) override
+ {
+ expr.get_loop_block ()->accept_vis (*this);
+ expr.get_iterator_expr ()->accept_vis (*this);
+ }
+
void visit (HIR::ExprStmtWithoutBlock &stmt) override
{
stmt.get_expr ()->accept_vis (*this);