diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/privacy/rust-privacy-ctx.h | 4 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-reachability.cc | 7 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-reachability.h | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/gcc/rust/privacy/rust-privacy-ctx.h b/gcc/rust/privacy/rust-privacy-ctx.h index 2f10fd3..2a11b56 100644 --- a/gcc/rust/privacy/rust-privacy-ctx.h +++ b/gcc/rust/privacy/rust-privacy-ctx.h @@ -28,8 +28,8 @@ namespace Privacy { */ enum ReachLevel { - Private, - Public, + Unreachable, + Reachable, }; class PrivacyContext diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc index 3d6ae82..5cab439 100644 --- a/gcc/rust/privacy/rust-reachability.cc +++ b/gcc/rust/privacy/rust-reachability.cc @@ -56,16 +56,19 @@ ReachabilityVisitor::visit (HIR::TypeAlias &type_alias) void ReachabilityVisitor::visit (HIR::StructStruct &struct_item) { - auto struct_reach = ReachLevel::Private; + 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 ().get_vis_type () == HIR::Visibility::NONE) - struct_reach = ReachLevel::Public; + struct_reach = ReachLevel::Reachable; // FIXME: Here we want to update only if the visibility is higher ctx.insert_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 + for (auto &field : struct_item.get_fields ()) ctx.insert_reachability (field.get_mappings (), struct_reach); diff --git a/gcc/rust/privacy/rust-reachability.h b/gcc/rust/privacy/rust-reachability.h index 157ef74..6d8edc4 100644 --- a/gcc/rust/privacy/rust-reachability.h +++ b/gcc/rust/privacy/rust-reachability.h @@ -37,7 +37,7 @@ class ReachabilityVisitor : public HIR::HIRVisItemVisitor { public: ReachabilityVisitor (PrivacyContext &ctx) - : current_level (ReachLevel::Private), ctx (ctx) + : current_level (ReachLevel::Unreachable), ctx (ctx) {} virtual void visit (HIR::Module &mod); |