public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] privacy: reachability: Add better implementation for StructStruct
@ 2022-06-08 12:29 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:29 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6db5c9fb19f0ee0223ee7cea75e91f923f0104a9
commit 6db5c9fb19f0ee0223ee7cea75e91f923f0104a9
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Apr 7 11:52:11 2022 +0200
privacy: reachability: Add better implementation for StructStruct
Diff:
---
gcc/rust/privacy/rust-reachability.cc | 9 +++------
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 bbd04341b59..ea92fa50fef 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 6d8edc409cc..7518ad9aeb9 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:29 [gcc/devel/rust/master] privacy: reachability: Add better implementation for StructStruct Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).