Patchwork [gccgo] Use DECL_CHAIN where appropriate

login
register
mail settings
Submitter Ian Taylor
Date Nov. 4, 2010, 4:29 a.m.
Message ID <mcreib1iud4.fsf@google.com>
Download mbox | patch
Permalink /patch/70098/
State New
Headers show

Comments

Ian Taylor - Nov. 4, 2010, 4:29 a.m.
This patch changes gccgo to use DECL_CHAIN instead of TREE_CHAIN where
appropriate when walking tree structures.  In gccgo this is almost all
cases where it is walking through the fields of a struct type in tree
form.  Committed to gccgo branch.

Ian

Patch

diff -r 8177cf98764e go/expressions.cc
--- a/go/expressions.cc	Wed Nov 03 20:56:29 2010 -0700
+++ b/go/expressions.cc	Wed Nov 03 21:26:44 2010 -0700
@@ -250,14 +250,14 @@ 
       elt->value = fold_convert(TREE_TYPE(field), null_pointer_node);
 
       elt = VEC_quick_push(constructor_elt, init, NULL);
-      field = TREE_CHAIN(field);
+      field = DECL_CHAIN(field);
       gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
 			"__count") == 0);
       elt->index = field;
       elt->value = fold_convert(TREE_TYPE(field), integer_zero_node);
 
       elt = VEC_quick_push(constructor_elt, init, NULL);
-      field = TREE_CHAIN(field);
+      field = DECL_CHAIN(field);
       gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
 			"__capacity") == 0);
       elt->index = field;
@@ -370,7 +370,7 @@ 
   elt->value = fold_convert_loc(location, TREE_TYPE(field), first_field_value);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
   elt->index = field;
 
@@ -538,13 +538,13 @@ 
   // The second field is simply the object pointer.
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
   elt->index = field;
 
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
   gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
-  tree rhs_field = TREE_CHAIN(TYPE_FIELDS(rhs_type_tree));
+  tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
   elt->value = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field,
 		      NULL_TREE);
@@ -599,7 +599,7 @@ 
 
   // If the call succeeds, pull out the value.
   gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
-  tree rhs_field = TREE_CHAIN(TYPE_FIELDS(rhs_type_tree));
+  tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
   tree val = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field,
 		    NULL_TREE);
@@ -6653,7 +6653,7 @@ 
       tree field = TYPE_FIELDS(struct_tree);
       for (unsigned int index = farg->field_index(); index > 0; --index)
 	{
-	  field = TREE_CHAIN(field);
+	  field = DECL_CHAIN(field);
 	  gcc_assert(field != NULL_TREE);
 	}
       HOST_WIDE_INT offset_wide = int_byte_position (field);
@@ -8590,7 +8590,7 @@ 
   for (unsigned int i = 0; i < this->index_; ++i)
     {
       gcc_assert(field != NULL_TREE);
-      field = TREE_CHAIN(field);
+      field = DECL_CHAIN(field);
     }
   gcc_assert(field != NULL_TREE);
   return build3(COMPONENT_REF, TREE_TYPE(field), call_tree, field, NULL_TREE);
@@ -9021,13 +9021,13 @@ 
   elt->value = value_pointer;
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
   elt->index = field;
   elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_length_tree);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0);
   elt->index = field;
   elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_capacity_tree);
@@ -9512,7 +9512,7 @@ 
   gcc_assert(field != NULL_TREE);
   for (unsigned int i = this->field_index_; i > 0; --i)
     {
-      field = TREE_CHAIN(field);
+      field = DECL_CHAIN(field);
       gcc_assert(field != NULL_TREE);
     }
   return build3(COMPONENT_REF, TREE_TYPE(field), struct_tree, field,
@@ -9552,9 +9552,9 @@ 
   gcc_assert(TREE_CODE(TREE_TYPE(table)) == RECORD_TYPE);
 
   std::string name = Gogo::unpack_hidden_name(this->name_);
-  for (field = TREE_CHAIN(TYPE_FIELDS(TREE_TYPE(table)));
+  for (field = DECL_CHAIN(TYPE_FIELDS(TREE_TYPE(table)));
        field != NULL_TREE;
-       field = TREE_CHAIN(field))
+       field = DECL_CHAIN(field))
     {
       if (name == IDENTIFIER_POINTER(DECL_NAME(field)))
 	break;
@@ -9578,7 +9578,7 @@ 
   tree expr_type = TREE_TYPE(expr);
   gcc_assert(TREE_CODE(expr_type) == RECORD_TYPE);
 
-  tree field = TREE_CHAIN(TYPE_FIELDS(expr_type));
+  tree field = DECL_CHAIN(TYPE_FIELDS(expr_type));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
 
   return build3(COMPONENT_REF, TREE_TYPE(field), expr, field, NULL_TREE);
@@ -10230,7 +10230,7 @@ 
   Expression_list::const_iterator pv = this->vals_->begin();
   for (tree field = TYPE_FIELDS(type_tree);
        field != NULL_TREE;
-       field = TREE_CHAIN(field), ++pf)
+       field = DECL_CHAIN(field), ++pf)
     {
       gcc_assert(pf != fields->end());
 
@@ -10689,13 +10689,13 @@ 
   elt->value = fold_convert(TREE_TYPE(field), space);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), length_tree);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),"__capacity") == 0);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), length_tree);
@@ -10858,7 +10858,7 @@ 
   id = get_identifier("__val");
   tree val_field = build_decl(loc, FIELD_DECL, id, val_type->get_tree(gogo));
   DECL_CONTEXT(val_field) = struct_type;
-  TREE_CHAIN(key_field) = val_field;
+  DECL_CHAIN(key_field) = val_field;
 
   layout_type(struct_type);
 
@@ -11991,7 +11991,7 @@ 
   Struct_field_list::const_iterator p;
   for (p = fields->begin();
        p != fields->end();
-       ++p, struct_field_tree = TREE_CHAIN(struct_field_tree))
+       ++p, struct_field_tree = DECL_CHAIN(struct_field_tree))
     {
       gcc_assert(struct_field_tree != NULL_TREE);
       if (&*p == this->field_)
diff -r 8177cf98764e go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed Nov 03 20:56:29 2010 -0700
+++ b/go/gogo-tree.cc	Wed Nov 03 21:26:44 2010 -0700
@@ -280,7 +280,7 @@ 
       elt->value = build_fold_addr_expr(decl);
 
       elt = VEC_quick_push(constructor_elt, init, NULL);
-      field = TREE_CHAIN(field);
+      field = DECL_CHAIN(field);
       elt->index = field;
       elt->value = DECL_SIZE_UNIT(decl);
 
@@ -299,7 +299,7 @@ 
   elt->value = fold_convert(TREE_TYPE(field), null_pointer_node);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   elt->index = field;
   elt->value = size_zero_node;
 
@@ -317,7 +317,7 @@ 
   elt->value = fold_convert(TREE_TYPE(field), null_pointer_node);
 
   elt = VEC_quick_push(constructor_elt, root_list_init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   elt->index = field;
   elt->value = build_constructor(array_type, roots_init);
 
@@ -1522,7 +1522,7 @@ 
 	      if (TREE_CODE(var) == INDIRECT_REF)
 		var = TREE_OPERAND(var, 0);
 	      gcc_assert(TREE_CODE(var) == VAR_DECL);
-	      TREE_CHAIN(var) = declare_vars;
+	      DECL_CHAIN(var) = declare_vars;
 	      declare_vars = var;
 	      *pp = parm_decl;
 	    }
@@ -1534,7 +1534,7 @@ 
 	      gcc_assert(TREE_CODE(*pp) == INDIRECT_REF);
 	      tree var_decl = TREE_OPERAND(*pp, 0);
 	      gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
-	      TREE_CHAIN(var_decl) = declare_vars;
+	      DECL_CHAIN(var_decl) = declare_vars;
 	      declare_vars = var_decl;
 	      *pp = parm_decl;
 	    }
@@ -1542,7 +1542,7 @@ 
 	  if (*pp != error_mark_node)
 	    {
 	      gcc_assert(TREE_CODE(*pp) == PARM_DECL);
-	      pp = &TREE_CHAIN(*pp);
+	      pp = &DECL_CHAIN(*pp);
 	    }
 	}
       else if ((*p)->is_result_variable())
@@ -1554,7 +1554,7 @@ 
 	      var_decl = TREE_OPERAND(var_decl, 0);
 	    }
 	  gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
-	  TREE_CHAIN(var_decl) = declare_vars;
+	  DECL_CHAIN(var_decl) = declare_vars;
 	  declare_vars = var_decl;
 	}
     }
@@ -1589,7 +1589,7 @@ 
       tree fini = NULL_TREE;
 
       // Initialize variables if necessary.
-      for (tree v = declare_vars; v != NULL_TREE; v = TREE_CHAIN(v))
+      for (tree v = declare_vars; v != NULL_TREE; v = DECL_CHAIN(v))
 	{
 	  tree dv = build1(DECL_EXPR, void_type_node, v);
 	  SET_EXPR_LOCATION(dv, DECL_SOURCE_LOCATION(v));
@@ -1765,7 +1765,7 @@ 
       int index = 0;
       for (Typed_identifier_list::const_iterator pr = results->begin();
 	   pr != results->end();
-	   ++pr, ++index, field = TREE_CHAIN(field))
+	   ++pr, ++index, field = DECL_CHAIN(field))
 	{
 	  gcc_assert(field != NULL);
 	  tree val;
@@ -1874,7 +1874,7 @@ 
 		  gcc_assert(TREE_CODE(var) == VAR_DECL);
 		}
 	      *pp = var;
-	      pp = &TREE_CHAIN(*pp);
+	      pp = &DECL_CHAIN(*pp);
 	    }
 	}
     }
@@ -2108,7 +2108,7 @@ 
 	}
       tree field = build_decl(BUILTINS_LOCATION, FIELD_DECL,
 			      get_identifier(field_name), type);
-      TREE_CHAIN(field) = fields;
+      DECL_CHAIN(field) = fields;
       fields = field;
     }
 
@@ -2177,7 +2177,7 @@ 
 			    build_fold_addr_expr(str));
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__length") == 0);
   elt->index = field;
   elt->value = build_int_cst_type(TREE_TYPE(field), val.length());
@@ -2273,13 +2273,13 @@ 
       capacity = count;
     }
 
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
   elt = VEC_quick_push(constructor_elt, init, NULL);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), count);
 
-  field = TREE_CHAIN(field);
+  field = DECL_CHAIN(field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0);
   elt = VEC_quick_push(constructor_elt, init, NULL);
   elt->index = field;
@@ -2348,11 +2348,11 @@ 
   if (map_entry_type == error_mark_node)
     return error_mark_node;
 
-  tree map_entry_key_field = TREE_CHAIN(TYPE_FIELDS(map_entry_type));
+  tree map_entry_key_field = DECL_CHAIN(TYPE_FIELDS(map_entry_type));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_key_field)),
 		    "__key") == 0);
 
-  tree map_entry_val_field = TREE_CHAIN(map_entry_key_field);
+  tree map_entry_val_field = DECL_CHAIN(map_entry_key_field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_val_field)),
 		    "__val") == 0);
 
@@ -2361,13 +2361,13 @@ 
   tree map_descriptor_field = TYPE_FIELDS(struct_type);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_descriptor_field)),
 		    "__map_descriptor") == 0);
-  tree entry_size_field = TREE_CHAIN(map_descriptor_field);
+  tree entry_size_field = DECL_CHAIN(map_descriptor_field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(entry_size_field)),
 		    "__entry_size") == 0);
-  tree key_offset_field = TREE_CHAIN(entry_size_field);
+  tree key_offset_field = DECL_CHAIN(entry_size_field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(key_offset_field)),
 		    "__key_offset") == 0);
-  tree val_offset_field = TREE_CHAIN(key_offset_field);
+  tree val_offset_field = DECL_CHAIN(key_offset_field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(val_offset_field)),
 		    "__val_offset") == 0);
 
diff -r 8177cf98764e go/statements.cc
--- a/go/statements.cc	Wed Nov 03 20:56:29 2010 -0700
+++ b/go/statements.cc	Wed Nov 03 21:26:44 2010 -0700
@@ -382,7 +382,7 @@ 
       // in a BIND_EXPR.
       tree block_tree = context->block_tree();
       gcc_assert(block_tree != NULL_TREE);
-      TREE_CHAIN(decl) = BLOCK_VARS(block_tree);
+      DECL_CHAIN(decl) = BLOCK_VARS(block_tree);
       BLOCK_VARS(block_tree) = decl;
 
       this->decl_ = decl;
@@ -2590,7 +2590,7 @@ 
       Typed_identifier_list::const_iterator pr = results->begin();
       for (tree field = TYPE_FIELDS(rettype);
 	   field != NULL_TREE;
-	   ++pv, ++pr, field = TREE_CHAIN(field))
+	   ++pv, ++pr, field = DECL_CHAIN(field))
 	{
 	  gcc_assert(pv != this->vals_->end());
 	  tree val = (*pv)->get_tree(context);
diff -r 8177cf98764e go/types.cc
--- a/go/types.cc	Wed Nov 03 20:56:29 2010 -0700
+++ b/go/types.cc	Wed Nov 03 21:26:44 2010 -0700
@@ -2080,7 +2080,7 @@ 
 {
   tree string_type = TREE_TYPE(string);
   gcc_assert(TREE_CODE(string_type) == RECORD_TYPE);
-  tree length_field = TREE_CHAIN(TYPE_FIELDS(string_type));
+  tree length_field = DECL_CHAIN(TYPE_FIELDS(string_type));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(length_field)),
 		    "__length") == 0);
   return fold_build3(COMPONENT_REF, integer_type_node, string,
@@ -2115,7 +2115,7 @@ 
 
   for (tree field = TYPE_FIELDS(type_tree);
        field != NULL_TREE;
-       field = TREE_CHAIN(field))
+       field = DECL_CHAIN(field))
     {
       constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
       elt->index = field;
@@ -2551,7 +2551,7 @@ 
 				  field_type_tree);
 	  DECL_CONTEXT(field) = result;
 	  *pp = field;
-	  pp = &TREE_CHAIN(field);
+	  pp = &DECL_CHAIN(field);
 	}
       TYPE_FIELDS(result) = field_trees;
       layout_type(result);
@@ -3659,7 +3659,7 @@ 
 			      field_type_tree);
       DECL_CONTEXT(field) = type;
       *pp = field;
-      pp = &TREE_CHAIN(field);
+      pp = &DECL_CHAIN(field);
     }
 
   TYPE_FIELDS(type) = field_trees;
@@ -3694,7 +3694,7 @@ 
   Struct_field_list::const_iterator p = this->fields_->begin();
   for (tree field = TYPE_FIELDS(type_tree);
        field != NULL_TREE;
-       field = TREE_CHAIN(field), ++p)
+       field = DECL_CHAIN(field), ++p)
     {
       gcc_assert(p != this->fields_->end());
       tree value = p->type()->get_init_tree(gogo, is_clear);
@@ -4364,7 +4364,7 @@ 
 
       for (tree field = TYPE_FIELDS(type_tree);
 	   field != NULL_TREE;
-	   field = TREE_CHAIN(field))
+	   field = DECL_CHAIN(field))
 	{
 	  constructor_elt* elt = VEC_quick_push(constructor_elt, init,
 						NULL);
@@ -4414,7 +4414,7 @@ 
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(values_field)),
 		    "__values") == 0);
 
-  tree count_field = TREE_CHAIN(values_field);
+  tree count_field = DECL_CHAIN(values_field);
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(count_field)),
 		    "__count") == 0);
 
@@ -4600,7 +4600,7 @@ 
   tree type = TREE_TYPE(array);
   gcc_assert(TREE_CODE(type) == RECORD_TYPE);
 
-  tree field = TREE_CHAIN(TYPE_FIELDS(type));
+  tree field = DECL_CHAIN(TYPE_FIELDS(type));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
 
   tree ret = build3(COMPONENT_REF, TREE_TYPE(field), array, field, NULL_TREE);
@@ -4623,7 +4623,7 @@ 
   tree type = TREE_TYPE(array);
   gcc_assert(TREE_CODE(type) == RECORD_TYPE);
 
-  tree field = TREE_CHAIN(TREE_CHAIN(TYPE_FIELDS(type)));
+  tree field = DECL_CHAIN(DECL_CHAIN(TYPE_FIELDS(type)));
   gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0);
 
   return build3(COMPONENT_REF, TREE_TYPE(field), array, field, NULL_TREE);
@@ -4940,20 +4940,20 @@ 
       name = get_identifier("__element_count");
       field = build_decl(BUILTINS_LOCATION, FIELD_DECL, name, sizetype);
       DECL_CONTEXT(field) = struct_type;
-      TREE_CHAIN(last_field) = field;
+      DECL_CHAIN(last_field) = field;
       last_field = field;
 
       name = get_identifier("__bucket_count");
       field = build_decl(BUILTINS_LOCATION, FIELD_DECL, name, sizetype);
       DECL_CONTEXT(field) = struct_type;
-      TREE_CHAIN(last_field) = field;
+      DECL_CHAIN(last_field) = field;
       last_field = field;
 
       name = get_identifier("__buckets");
       field = build_decl(BUILTINS_LOCATION, FIELD_DECL, name,
 			 build_pointer_type(ptr_type_node));
       DECL_CONTEXT(field) = struct_type;
-      TREE_CHAIN(last_field) = field;
+      DECL_CHAIN(last_field) = field;
 
       layout_type(struct_type);
 
@@ -5858,7 +5858,7 @@ 
   TYPE_FIELDS(method_table) = field;
 
   std::string last_name = "";
-  tree* pp = &TREE_CHAIN(field);
+  tree* pp = &DECL_CHAIN(field);
   for (Typed_identifier_list::const_iterator p = this->methods_->begin();
        p != this->methods_->end();
        ++p)
@@ -5871,7 +5871,7 @@ 
       field = build_decl(this->location_, FIELD_DECL, name_tree, field_type);
       DECL_CONTEXT(field) = method_table;
       *pp = field;
-      pp = &TREE_CHAIN(field);
+      pp = &DECL_CHAIN(field);
       // Sanity check: the names should be sorted.
       gcc_assert(p->name() > last_name);
       last_name = p->name();
@@ -5887,7 +5887,7 @@ 
   field = build_decl(this->location_, FIELD_DECL, name_tree, mtype);
   DECL_CONTEXT(field) = type;
   *pp = field;
-  pp = &TREE_CHAIN(field);
+  pp = &DECL_CHAIN(field);
 
   name_tree = get_identifier("__object");
   field = build_decl(this->location_, FIELD_DECL, name_tree, ptr_type_node);
@@ -5912,7 +5912,7 @@ 
   VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 2);
   for (tree field = TYPE_FIELDS(type_tree);
        field != NULL_TREE;
-       field = TREE_CHAIN(field))
+       field = DECL_CHAIN(field))
     {
       constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
       elt->index = field;