[v3,4/9] Add field::is_public

Message ID 20231103-field-bits-v3-4-273c40bcaf3d@adacore.com
State New
Headers
Series Remove char-based bitfield macros |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Nov. 3, 2023, 4:09 p.m. UTC
  This adds a field::is_public convenience method, and updates one spot
to use it.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
---
 gdb/gdbtypes.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f5dd2b8076d..b6a693f1316 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -686,6 +686,10 @@  struct field
   enum accessibility accessibility () const
   { return m_accessibility; }
 
+  /* True if this field is 'public'.  */
+  bool is_public () const
+  { return m_accessibility == accessibility::PUBLIC; }
+
   /* True if this field is 'private'.  */
   bool is_private () const
   { return m_accessibility == accessibility::PRIVATE; }
@@ -1964,7 +1968,7 @@  extern void set_type_vptr_basetype (struct type *, struct type *);
 #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
 #define BASETYPE_VIA_PUBLIC(thistype, index) \
-  ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
+  ((thistype)->field (index).is_public ())
 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
 
 #define BASETYPE_VIA_VIRTUAL(thistype, index) \