diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-07 11:52:11 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-12 15:26:08 +0200 |
commit | 6db5c9fb19f0ee0223ee7cea75e91f923f0104a9 (patch) | |
tree | 77eee933a1b1798d36eba90edffccaef2a1bb5af | |
parent | 3bb4d746a037f9ebea8f91a32b8785223c4e2d33 (diff) | |
download | gcc-6db5c9fb19f0ee0223ee7cea75e91f923f0104a9.zip gcc-6db5c9fb19f0ee0223ee7cea75e91f923f0104a9.tar.gz gcc-6db5c9fb19f0ee0223ee7cea75e91f923f0104a9.tar.bz2 |
privacy: reachability: Add better implementation for StructStruct
-rw-r--r-- | gcc/rust/privacy/rust-reachability.cc | 9 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-reachability.h | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc index bbd0434..ea92fa5 100644 --- a/gcc/rust/privacy/rust-reachability.cc +++ b/gcc/rust/privacy/rust-reachability.cc @@ -65,17 +65,14 @@ void ReachabilityVisitor::visit (HIR::StructStruct &struct_item) { auto struct_reach = ReachLevel::Unreachable; - // FIXME: This feels very wrong. Should we check for `has_visibility` - // beforehand? Is it just private otherwise? Should the `HIR::Visibility` also - // keep variants for private items? if (struct_item.get_visibility ().is_public ()) - struct_reach = ReachLevel::Reachable; + struct_reach = current_level; struct_reach = ctx.update_reachability (struct_item.get_mappings (), struct_reach); - // FIXME: We need to also visit the fields as they might have their own set - // of reachability levels + // FIXME: Do we need to also visit the fields as they might have their own set + // of reachability levels? Can they? for (auto &field : struct_item.get_fields ()) ctx.update_reachability (field.get_mappings (), struct_reach); diff --git a/gcc/rust/privacy/rust-reachability.h b/gcc/rust/privacy/rust-reachability.h index 6d8edc4..7518ad9 100644 --- a/gcc/rust/privacy/rust-reachability.h +++ b/gcc/rust/privacy/rust-reachability.h @@ -33,11 +33,15 @@ namespace Privacy { // to reach more and more nodes until nothing has changed anymore. // Do we need to reproduce this behavior? How long does it take to do this? +/** + * The ReachabilityVisitor tries to reach all items possible in the crate, + * according to their privacy level. + */ class ReachabilityVisitor : public HIR::HIRVisItemVisitor { public: ReachabilityVisitor (PrivacyContext &ctx) - : current_level (ReachLevel::Unreachable), ctx (ctx) + : current_level (ReachLevel::Reachable), ctx (ctx) {} virtual void visit (HIR::Module &mod); |