public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] privacy: reachability: Add base for visiting struct definitions
@ 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:be8f2ead95b292615d1c27f7c486384d32a70c49

commit be8f2ead95b292615d1c27f7c486384d32a70c49
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Thu Apr 7 14:05:20 2022 +0200

    privacy: reachability: Add base for visiting struct definitions

Diff:
---
 gcc/rust/privacy/rust-reachability.cc | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc
index ea92fa50fef..ade026f20da 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


^ 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 base for visiting struct definitions 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).