Don't include sys/personality.h in linux-low.cc anymore
[deliverable/binutils-gdb.git] / gdb / gdbtypes.h
index 88fb0e7a3936a877758eae4604c4ef260f6ec6a5..bb4d26eef1a1a842ec77c6a386e63d298b28eddb 100644 (file)
@@ -1,7 +1,7 @@
 
 /* Internal type definitions for GDB.
 
-   Copyright (C) 1992-2020 Free Software Foundation, Inc.
+   Copyright (C) 1992-2021 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
@@ -46,6 +46,7 @@
 
 #include "hashtab.h"
 #include "gdbsupport/array-view.h"
+#include "gdbsupport/gdb_optional.h"
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/underlying.h"
@@ -219,28 +220,6 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
 
 #define TYPE_NOTTEXT(t)        (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
 
-/* * Type owner.  If TYPE_OBJFILE_OWNED is true, the type is owned by
-   the objfile retrieved as TYPE_OBJFILE.  Otherwise, the type is
-   owned by an architecture; TYPE_OBJFILE is NULL in this case.  */
-
-#define TYPE_OBJFILE_OWNED(t) (TYPE_MAIN_TYPE (t)->flag_objfile_owned)
-#define TYPE_OWNER(t) TYPE_MAIN_TYPE(t)->owner
-#define TYPE_OBJFILE(t) (TYPE_OBJFILE_OWNED(t)? TYPE_OWNER(t).objfile : NULL)
-
-/* * True if this type was declared using the "class" keyword.  This is
-   only valid for C++ structure and enum types.  If false, a structure
-   was declared as a "struct"; if true it was declared "class".  For
-   enum types, this is true when "enum class" or "enum struct" was
-   used to declare the type..  */
-
-#define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
-
-/* * True if this type is a "flag" enum.  A flag enum is one where all
-   the values are pairwise disjoint when "and"ed together.  This
-   affects how enum values are printed.  */
-
-#define TYPE_FLAG_ENUM(t) (TYPE_MAIN_TYPE (t)->flag_flag_enum)
-
 /* * Constant type.  If this is set, the corresponding type has a
    const modifier.  */
 
@@ -816,18 +795,18 @@ struct main_type
   unsigned int m_flag_stub_supported : 1;
   unsigned int m_flag_gnu_ifunc : 1;
   unsigned int m_flag_fixed_instance : 1;
-  unsigned int flag_objfile_owned : 1;
+  unsigned int m_flag_objfile_owned : 1;
   unsigned int m_flag_endianity_not_default : 1;
 
   /* * True if this type was declared with "class" rather than
      "struct".  */
 
-  unsigned int flag_declared_class : 1;
+  unsigned int m_flag_declared_class : 1;
 
   /* * True if this is an enum type with disjoint values.  This
      affects how the enum is printed.  */
 
-  unsigned int flag_flag_enum : 1;
+  unsigned int m_flag_flag_enum : 1;
 
   /* * A discriminant telling us which field of the type_specific
      union is being used for this type, if any.  */
@@ -859,7 +838,7 @@ struct main_type
      this is somewhat ugly, but without major overhaul of the internal
      type system, it can't be avoided for now.  */
 
-  union type_owner owner;
+  union type_owner m_owner;
 
   /* * For a pointer type, describes the type of object pointed to.
      - For an array type, describes the type of the elements.
@@ -1194,6 +1173,37 @@ struct type
     this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
   }
 
+
+  /* True if this type was declared using the "class" keyword.  This is
+     only valid for C++ structure and enum types.  If false, a structure
+     was declared as a "struct"; if true it was declared "class".  For
+     enum types, this is true when "enum class" or "enum struct" was
+     used to declare the type.  */
+
+  bool is_declared_class () const
+  {
+    return this->main_type->m_flag_declared_class;
+  }
+
+  void set_is_declared_class (bool is_declared_class) const
+  {
+    this->main_type->m_flag_declared_class = is_declared_class;
+  }
+
+  /* True if this type is a "flag" enum.  A flag enum is one where all
+     the values are pairwise disjoint when "and"ed together.  This
+     affects how enum values are printed.  */
+
+  bool is_flag_enum () const
+  {
+    return this->main_type->m_flag_flag_enum;
+  }
+
+  void set_is_flag_enum (bool is_flag_enum)
+  {
+    this->main_type->m_flag_flag_enum = is_flag_enum;
+  }
+
   /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
      to this type's fixed_point_info.  */
 
@@ -1224,6 +1234,11 @@ struct type
 
   struct type *fixed_point_type_base_type ();
 
+  /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
+     factor.  */
+
+  const gdb_mpq &fixed_point_scaling_factor ();
+
   /* * Return the dynamic property of the requested KIND from this type's
      list of dynamic properties.  */
   dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
@@ -1237,6 +1252,60 @@ struct type
   /* * Remove dynamic property of kind KIND from this type, if it exists.  */
   void remove_dyn_prop (dynamic_prop_node_kind kind);
 
+  /* Return true if this type is owned by an objfile.  Return false if it is
+     owned by an architecture.  */
+  bool is_objfile_owned () const
+  {
+    return this->main_type->m_flag_objfile_owned;
+  }
+
+  /* Set the owner of the type to be OBJFILE.  */
+  void set_owner (objfile *objfile)
+  {
+    gdb_assert (objfile != nullptr);
+
+    this->main_type->m_owner.objfile = objfile;
+    this->main_type->m_flag_objfile_owned = true;
+  }
+
+  /* Set the owner of the type to be ARCH.  */
+  void set_owner (gdbarch *arch)
+  {
+    gdb_assert (arch != nullptr);
+
+    this->main_type->m_owner.gdbarch = arch;
+    this->main_type->m_flag_objfile_owned = false;
+  }
+
+  /* Return the objfile owner of this type.
+
+     Return nullptr if this type is not objfile-owned.  */
+  struct objfile *objfile_owner () const
+  {
+    if (!this->is_objfile_owned ())
+      return nullptr;
+
+    return this->main_type->m_owner.objfile;
+  }
+
+  /* Return the gdbarch owner of this type.
+
+     Return nullptr if this type is not gdbarch-owned.  */
+  gdbarch *arch_owner () const
+  {
+    if (this->is_objfile_owned ())
+      return nullptr;
+
+    return this->main_type->m_owner.gdbarch;
+  }
+
+  /* Return the type's architecture.  For types owned by an
+     architecture, that architecture is returned.  For types owned by an
+     objfile, that objfile's architecture is returned.
+
+     The return value is always non-nullptr.  */
+  gdbarch *arch () const;
+
   /* * Return true if this is an integer type whose logical (bit) size
      differs from its storage size; false otherwise.  Always return
      false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types.  */
@@ -2194,9 +2263,9 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
    when it is no longer needed.  */
 
 #define TYPE_ALLOC(t,size)                                              \
-  (obstack_alloc ((TYPE_OBJFILE_OWNED (t)                               \
-                  ? &TYPE_OBJFILE (t)->objfile_obstack                 \
-                  : gdbarch_obstack (TYPE_OWNER (t).gdbarch)),         \
+  (obstack_alloc (((t)->is_objfile_owned ()                             \
+                  ? &((t)->objfile_owner ()->objfile_obstack)          \
+                  : gdbarch_obstack ((t)->arch_owner ())),             \
                  size))
 
 
@@ -2213,12 +2282,6 @@ extern struct type *alloc_type (struct objfile *);
 extern struct type *alloc_type_arch (struct gdbarch *);
 extern struct type *alloc_type_copy (const struct type *);
 
-/* * Return the type's architecture.  For types owned by an
-   architecture, that architecture is returned.  For types owned by an
-   objfile, that objfile's architecture is returned.  */
-
-extern struct gdbarch *get_type_arch (const struct type *);
-
 /* * This returns the target type (or NULL) of TYPE, also skipping
    past typedefs.  */
 
@@ -2243,6 +2306,7 @@ extern struct type *init_float_type (struct objfile *, int, const char *,
                                     const struct floatformat **,
                                     enum bfd_endian = BFD_ENDIAN_UNKNOWN);
 extern struct type *init_decfloat_type (struct objfile *, int, const char *);
+extern bool can_create_complex_type (struct type *);
 extern struct type *init_complex_type (const char *, struct type *);
 extern struct type *init_pointer_type (struct objfile *, int, const char *,
                                       struct type *);
@@ -2460,7 +2524,21 @@ extern struct type *lookup_template_type (const char *, struct type *,
 
 extern int get_vptr_fieldno (struct type *, struct type **);
 
-extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
+/* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
+   TYPE.
+
+   Return true if the two bounds are available, false otherwise.  */
+
+extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
+                                LONGEST *highp);
+
+/* If TYPE's low bound is a known constant, return it, else return nullopt.  */
+
+extern gdb::optional<LONGEST> get_discrete_low_bound (struct type *type);
+
+/* If TYPE's high bound is a known constant, return it, else return nullopt.  */
+
+extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
 
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
@@ -2472,7 +2550,8 @@ extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
 extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
                              LONGEST *high_bound);
 
-extern int discrete_position (struct type *type, LONGEST val, LONGEST *pos);
+extern gdb::optional<LONGEST> discrete_position (struct type *type,
+                                                LONGEST val);
 
 extern int class_types_same_p (const struct type *, const struct type *);
 
@@ -2596,17 +2675,14 @@ extern int type_not_associated (const struct type *type);
    a range type whose base type is a TYPE_CODE_FIXED_POINT.  */
 extern bool is_fixed_point_type (struct type *type);
 
-/* Given TYPE, which is a fixed point type, return its scaling factor.  */
-extern const gdb_mpq &fixed_point_scaling_factor (struct type *type);
-
 /* Allocate a fixed-point type info for TYPE.  This should only be
    called by INIT_FIXED_POINT_SPECIFIC.  */
 extern void allocate_fixed_point_type_info (struct type *type);
 
 /* * When the type includes explicit byte ordering, return that.
-   Otherwise, the byte ordering from gdbarch_byte_order for 
-   get_type_arch is returned.  */
-   
+   Otherwise, the byte ordering from gdbarch_byte_order for
+   the type's arch is returned.  */
+
 extern enum bfd_endian type_byte_order (const struct type *type);
 
 /* A flag to enable printing of debugging information of C++
This page took 0.02831 seconds and 4 git commands to generate.