diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2021-07-13 15:41:04 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2021-07-13 15:41:04 +0800 |
commit | 29d84b2c1477769100559f9427028001fd07b113 (patch) | |
tree | 5f51ad082be6cb31d191648b548a93f00cef4fa6 /gcc | |
parent | 9415a4b712371706d7f130695fd959fddb6506cc (diff) | |
download | gcc-29d84b2c1477769100559f9427028001fd07b113.zip gcc-29d84b2c1477769100559f9427028001fd07b113.tar.gz gcc-29d84b2c1477769100559f9427028001fd07b113.tar.bz2 |
add some comments about how scan dead code pass handle PathInExpression and PathExprSegment
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.cc b/gcc/rust/lint/rust-lint-marklive.cc index d436f1a..8339345 100644 --- a/gcc/rust/lint/rust-lint-marklive.cc +++ b/gcc/rust/lint/rust-lint-marklive.cc @@ -106,6 +106,8 @@ MarkLive::go (HIR::Crate &crate) void MarkLive::visit (HIR::PathInExpression &expr) { + // We should iterate every path segment in order to mark the function which is + // called in the expression expr.iterate_path_segments ([&] (HIR::PathExprSegment &seg) -> bool { return visit_path_segment (seg); }); @@ -121,6 +123,7 @@ MarkLive::visit (HIR::MethodCallExpr &expr) return true; }); + // Trying to find the method definition and mark it alive. NodeId ast_node_id = expr.get_mappings ().get_nodeid (); NodeId ref_node_id = UNKNOWN_NODEID; find_ref_node_id (ast_node_id, ref_node_id, expr.get_locus (), @@ -140,6 +143,14 @@ MarkLive::visit_path_segment (HIR::PathExprSegment seg) NodeId ast_node_id = seg.get_mappings ().get_nodeid (); NodeId ref_node_id = UNKNOWN_NODEID; + // There are two different kinds of segment for us. + // 1. function segment + // like the symbol "foo" in expression `foo()`. + // 2. type segment + // like the symbol "Foo" in expression `Foo{a: 1, b: 2}` + // + // We should mark them alive all and ignoring other kind of segments. + // If the segment we dont care then just return false is fine if (resolver->lookup_resolved_name (ast_node_id, &ref_node_id)) { Resolver::Definition def; |