gdb: remove FIELD_TYPE macro
[deliverable/binutils-gdb.git] / gdb / dwarf2 / attribute.h
index 483b805433b644d56dd51535df355fc06044d94c..ffb91e878f108216f823bf1afdb9c2f746bce39e 100644 (file)
@@ -46,6 +46,10 @@ struct attribute
      attribute's form into account.  */
   CORE_ADDR value_as_address () const;
 
+  /* If the attribute has a string form, return the string value;
+     otherwise return NULL.  */
+  const char *value_as_string () const;
+
   /* Return non-zero if ATTR's value is a section offset --- classes
      lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
      You may use DW_UNSND (attr) to retrieve such offsets.
@@ -59,7 +63,7 @@ struct attribute
 
   /* Return non-zero if ATTR's value falls in the 'constant' class, or
      zero otherwise.  When this function returns true, you can apply
-     dwarf2_get_attr_constant_value to it.
+     the constant_value method to it.
 
      However, note that for some attributes you must check
      attr_form_is_section_offset before using this test.  DW_FORM_data4
@@ -70,15 +74,24 @@ struct attribute
      section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
      taken as section offsets, not constants.
 
-     DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
-     cannot handle that.  */
+     DW_FORM_data16 is not considered as constant_value cannot handle
+     that.  */
 
   bool form_is_constant () const;
 
   /* DW_ADDR is always stored already as sect_offset; despite for the forms
      besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file.  */
 
-  bool form_is_ref () const;
+  bool form_is_ref () const
+  {
+    return (form == DW_FORM_ref_addr
+           || form == DW_FORM_ref1
+           || form == DW_FORM_ref2
+           || form == DW_FORM_ref4
+           || form == DW_FORM_ref8
+           || form == DW_FORM_ref_udata
+           || form == DW_FORM_GNU_ref_alt);
+  }
 
   /* Check if the attribute's form is a DW_FORM_block*
      if so return true else false.  */
@@ -88,7 +101,13 @@ struct attribute
   /* Return DIE offset of this attribute.  Return 0 with complaint if
      the attribute is not of the required kind.  */
 
-  sect_offset get_ref_die_offset () const;
+  sect_offset get_ref_die_offset () const
+  {
+    if (form_is_ref ())
+      return (sect_offset) u.unsnd;
+    get_ref_die_offset_complaint ();
+    return {};
+  }
 
   /* Return the constant value held by this attribute.  Return
      DEFAULT_VALUE if the value held by the attribute is not
@@ -115,6 +134,12 @@ struct attribute
       ULONGEST signature;
     }
   u;
+
+private:
+
+  /* Used by get_ref_die_offset to issue a complaint.  */
+
+  void get_ref_die_offset_complaint () const;
 };
 
 /* Get at parts of an attribute structure.  */
This page took 0.02415 seconds and 4 git commands to generate.