[4/7] Add field::is_public

Message ID 20230921-field-bits-v1-4-201285360900@adacore.com
State New
Headers
Series Remove char-based bitfield macros |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--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 Sept. 21, 2023, 6:01 p.m. UTC
  This adds a field::is_public convenience method, and updates one spot
to use it.
---
 gdb/gdbtypes.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index c72512b8204..53a8f7e803c 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -668,6 +668,12 @@  struct field
     m_loc.dwarf_block = dwarf_block;
   }
 
+  /* True if this field is 'public'.  */
+  bool is_public () const
+  {
+    return !m_private && !m_protected;
+  }
+
   /* True if this field is 'private'.  */
   bool is_private () const
   { return m_private; }
@@ -1961,7 +1967,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) \