diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-07 14:05:20 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-12 15:26:11 +0200 |
commit | be8f2ead95b292615d1c27f7c486384d32a70c49 (patch) | |
tree | 9b433fe0c0a3eae0ada4535073ec445a6c543809 | |
parent | d103151143aaeba14d3fceda8806a83157559c62 (diff) | |
download | gcc-be8f2ead95b292615d1c27f7c486384d32a70c49.zip gcc-be8f2ead95b292615d1c27f7c486384d32a70c49.tar.gz gcc-be8f2ead95b292615d1c27f7c486384d32a70c49.tar.bz2 |
privacy: reachability: Add base for visiting struct definitions
-rw-r--r-- | gcc/rust/privacy/rust-reachability.cc | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc index ea92fa5..ade026f 100644 --- a/gcc/rust/privacy/rust-reachability.cc +++ b/gcc/rust/privacy/rust-reachability.cc @@ -71,14 +71,32 @@ ReachabilityVisitor::visit (HIR::StructStruct &struct_item) struct_reach = ctx.update_reachability (struct_item.get_mappings (), struct_reach); - // FIXME: Do we need to also visit the fields as they might have their own set - // of reachability levels? Can they? + auto old_level = current_level; + current_level = struct_reach; - for (auto &field : struct_item.get_fields ()) - ctx.update_reachability (field.get_mappings (), struct_reach); + if (struct_reach != ReachLevel::Unreachable) + { + for (auto &field : struct_item.get_fields ()) + if (field.get_visibility ().is_public ()) + ctx.update_reachability (field.get_mappings (), struct_reach); + + // for (auto &generic : struct_item.get_generic_params ()) + // FIXME: How do we visit these generics's predicates with the + // reachability visitor? + + // FIXME: How do we get each generic's predicates from here? + // TypeContext? + + // for (auto &field : struct_item.get_fields ()) + // if (field.get_visibility ().is_public ()) + // FIXME: How do we visit these fields with the reachability + // visitor? + } // FIXME: How do we get the constructor from `struct_item`? We need to update // its visibility as well. Probably by keeping a reference to the TypeCtx? + + current_level = old_level; } void @@ -112,5 +130,8 @@ ReachabilityVisitor::visit (HIR::ImplBlock &impl) void ReachabilityVisitor::visit (HIR::ExternBlock &block) {} + +// FIXME: How can we visit Blocks in the current configuration? Have a full +// visitor? } // namespace Privacy } // namespace Rust |