This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dwarf2 cleanup patch


Previously, we were silently providing a default value for nonexistent
attributes.  This is fragile.

2000-08-24  Jason Merrill  <jason@redhat.com>

	* dwarf2out.c (AT_flag, AT_int, AT_unsigned, AT_string, AT_ref,
	AT_loc, AT_addr, AT_lbl): Abort on unsuitable input.
	(get_AT_low_pc, get_AT_hi_pc, get_AT_string, get_AT_flag, 
	get_AT_unsigned, get_AT_ref): Don't call them if get_AT fails.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.196
diff -c -p -r1.196 dwarf2out.c
*** dwarf2out.c	2000/08/14 20:55:11	1.196
--- dwarf2out.c	2000/08/24 20:36:44
*************** AT_flag (a)
*** 4125,4131 ****
    if (a && AT_class (a) == dw_val_class_flag)
      return a->dw_attr_val.v.val_flag;
  
!   return 0;
  }
  
  /* Add a signed integer attribute value to a DIE.  */
--- 4125,4131 ----
    if (a && AT_class (a) == dw_val_class_flag)
      return a->dw_attr_val.v.val_flag;
  
!   abort ();
  }
  
  /* Add a signed integer attribute value to a DIE.  */
*************** AT_int (a)
*** 4153,4159 ****
    if (a && AT_class (a) == dw_val_class_const)
      return a->dw_attr_val.v.val_int;
  
!   return 0;
  }
  
  /* Add an unsigned integer attribute value to a DIE.  */
--- 4153,4159 ----
    if (a && AT_class (a) == dw_val_class_const)
      return a->dw_attr_val.v.val_int;
  
!   abort ();
  }
  
  /* Add an unsigned integer attribute value to a DIE.  */
*************** AT_unsigned (a)
*** 4181,4187 ****
    if (a && AT_class (a) == dw_val_class_unsigned_const)
      return a->dw_attr_val.v.val_unsigned;
  
!   return 0;
  }
  
  /* Add an unsigned double integer attribute value to a DIE.  */
--- 4181,4187 ----
    if (a && AT_class (a) == dw_val_class_unsigned_const)
      return a->dw_attr_val.v.val_unsigned;
  
!   abort ();
  }
  
  /* Add an unsigned double integer attribute value to a DIE.  */
*************** AT_string (a)
*** 4247,4253 ****
    if (a && AT_class (a) == dw_val_class_str)
      return a->dw_attr_val.v.val_str;
  
!   return NULL;
  }
  
  /* Add a DIE reference attribute value to a DIE.  */
--- 4247,4253 ----
    if (a && AT_class (a) == dw_val_class_str)
      return a->dw_attr_val.v.val_str;
  
!   abort ();
  }
  
  /* Add a DIE reference attribute value to a DIE.  */
*************** AT_ref (a)
*** 4275,4281 ****
    if (a && AT_class (a) == dw_val_class_die_ref)
      return a->dw_attr_val.v.val_die_ref;
  
!   return NULL;
  }
  
  /* Add an FDE reference attribute value to a DIE.  */
--- 4275,4281 ----
    if (a && AT_class (a) == dw_val_class_die_ref)
      return a->dw_attr_val.v.val_die_ref;
  
!   abort ();
  }
  
  /* Add an FDE reference attribute value to a DIE.  */
*************** AT_loc (a)
*** 4320,4326 ****
    if (a && AT_class (a) == dw_val_class_loc)
      return a->dw_attr_val.v.val_loc;
  
!   return NULL;
  }
  
  /* Add an address constant attribute value to a DIE.  */
--- 4320,4326 ----
    if (a && AT_class (a) == dw_val_class_loc)
      return a->dw_attr_val.v.val_loc;
  
!   abort ();
  }
  
  /* Add an address constant attribute value to a DIE.  */
*************** AT_addr (a)
*** 4348,4354 ****
    if (a && AT_class (a) == dw_val_class_addr)
      return a->dw_attr_val.v.val_addr;
  
!   return NULL;
  }
  
  /* Add a label identifier attribute value to a DIE.  */
--- 4348,4354 ----
    if (a && AT_class (a) == dw_val_class_addr)
      return a->dw_attr_val.v.val_addr;
  
!   abort ();
  }
  
  /* Add a label identifier attribute value to a DIE.  */
*************** AT_lbl (a)
*** 4394,4400 ****
  	    || AT_class (a) == dw_val_class_lbl_offset))
      return a->dw_attr_val.v.val_lbl_id;
  
!   return NULL;
  }
  
  /* Get the attribute of type attr_kind.  */
--- 4394,4400 ----
  	    || AT_class (a) == dw_val_class_lbl_offset))
      return a->dw_attr_val.v.val_lbl_id;
  
!   abort ();
  }
  
  /* Get the attribute of type attr_kind.  */
*************** get_AT_low_pc (die)
*** 4436,4442 ****
       register dw_die_ref die;
  {
    register dw_attr_ref a = get_AT (die, DW_AT_low_pc);
!   return AT_lbl (a);
  }
  
  /* Return the "high pc" attribute value, typically associated with
--- 4436,4442 ----
       register dw_die_ref die;
  {
    register dw_attr_ref a = get_AT (die, DW_AT_low_pc);
!   return a ? AT_lbl (a) : NULL;
  }
  
  /* Return the "high pc" attribute value, typically associated with
*************** get_AT_hi_pc (die)
*** 4449,4455 ****
       register dw_die_ref die;
  {
    register dw_attr_ref a = get_AT (die, DW_AT_high_pc);
!   return AT_lbl (a);
  }
  
  /* Return the value of the string attribute designated by ATTR_KIND, or
--- 4449,4455 ----
       register dw_die_ref die;
  {
    register dw_attr_ref a = get_AT (die, DW_AT_high_pc);
!   return a ? AT_lbl (a) : NULL;
  }
  
  /* Return the value of the string attribute designated by ATTR_KIND, or
*************** get_AT_string (die, attr_kind)
*** 4461,4467 ****
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return AT_string (a);
  }
  
  /* Return the value of the flag attribute designated by ATTR_KIND, or -1
--- 4461,4467 ----
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return a ? AT_string (a) : NULL;
  }
  
  /* Return the value of the flag attribute designated by ATTR_KIND, or -1
*************** get_AT_flag (die, attr_kind)
*** 4473,4479 ****
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return AT_flag (a);
  }
  
  /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
--- 4473,4479 ----
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return a ? AT_flag (a) : 0;
  }
  
  /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
*************** get_AT_unsigned (die, attr_kind)
*** 4485,4491 ****
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return AT_unsigned (a);
  }
  
  static inline dw_die_ref
--- 4485,4491 ----
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return a ? AT_unsigned (a) : 0;
  }
  
  static inline dw_die_ref
*************** get_AT_ref (die, attr_kind)
*** 4494,4500 ****
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return AT_ref (a);
  }
  
  static inline int
--- 4494,4500 ----
       register enum dwarf_attribute attr_kind;
  {
    register dw_attr_ref a = get_AT (die, attr_kind);
!   return a ? AT_ref (a) : NULL;
  }
  
  static inline int

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]