This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 060/238] [index] varobj.c: -Wshadow fix


To ChangeLog:
	* varobj.c (varobj_get_handle): Rename index to idx(-Wshadow).
	(install_dynamic_child): Ditto.
	(install_variable): Ditto.
	(uninstall_variable): Ditto.
	(create_child_with_value): Ditto.
	(name_of_child): Ditto.
	(value_of_child): Ditto.
	(create_child): Ditto.
	(c_describe_child): Ditto.
	(c_name_of_child): Ditto.
	(c_value_of_child): Ditto.
	(c_type_of_child): Ditto.
	(match_accessibility): Ditto.
	(cplus_describe_child): Ditto.
	(cplus_name_of_child): Ditto.
	(cplus_value_of_child): Ditto.
	(cplus_type_of_child): Ditto.
	(java_name_of_child): Ditto.
	(java_value_of_child): Ditto.
	(java_type_of_child): Ditto.
	(ada_name_of_child): Ditto.
	(ada_value_of_child): Ditto.
	(ada_type_of_child): Ditto.

	* varobj.c (create_child): Remove trailing whitespace.
	(c_describe_child): Ditto.
	(c_name_of_child): Ditto.
	(c_value_of_child): Ditto.
---
 gdb/varobj.c |  144 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/gdb/varobj.c b/gdb/varobj.c
index 7c68a93..0bca297 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -719,15 +719,15 @@ varobj_get_handle (char *objname)
 {
   struct vlist *cv;
   const char *chp;
-  unsigned int index = 0;
+  unsigned int idx = 0;
   unsigned int i = 1;
 
   for (chp = objname; *chp; chp++)
     {
-      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
+      idx = (idx + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
     }
 
-  cv = *(varobj_table + index);
+  cv = *(varobj_table + idx);
   while ((cv != NULL) && (strcmp (cv->var->obj_name, objname) != 0))
     cv = cv->next;
 
@@ -951,11 +951,11 @@ install_dynamic_child (struct varobj *var,
 		       VEC (varobj_p) **new,
 		       VEC (varobj_p) **unchanged,
 		       int *cchanged,
-		       int index,
+		       int idx,
 		       const char *name,
 		       struct value *value)
 {
-  if (VEC_length (varobj_p, var->children) < index + 1)
+  if (VEC_length (varobj_p, var->children) < idx + 1)
     {
       /* There's no child yet.  */
       struct varobj *child = varobj_add_child (var, name, value);
@@ -968,7 +968,7 @@ install_dynamic_child (struct varobj *var,
     }
   else 
     {
-      varobj_p existing = VEC_index (varobj_p, var->children, index);
+      varobj_p existing = VEC_index (varobj_p, var->children, idx);
 
       if (install_new_value (existing, value, 0))
 	{
@@ -2052,15 +2052,15 @@ install_variable (struct varobj *var)
   struct vlist *cv;
   struct vlist *newvl;
   const char *chp;
-  unsigned int index = 0;
+  unsigned int idx = 0;
   unsigned int i = 1;
 
   for (chp = var->obj_name; *chp; chp++)
     {
-      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
+      idx = (idx + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
     }
 
-  cv = *(varobj_table + index);
+  cv = *(varobj_table + idx);
   while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
     cv = cv->next;
 
@@ -2069,9 +2069,9 @@ install_variable (struct varobj *var)
 
   /* Add varobj to hash table.  */
   newvl = xmalloc (sizeof (struct vlist));
-  newvl->next = *(varobj_table + index);
+  newvl->next = *(varobj_table + idx);
   newvl->var = var;
-  *(varobj_table + index) = newvl;
+  *(varobj_table + idx) = newvl;
 
   /* If root, add varobj to root list.  */
   if (is_root_p (var))
@@ -2096,16 +2096,16 @@ uninstall_variable (struct varobj *var)
   struct varobj_root *cr;
   struct varobj_root *prer;
   const char *chp;
-  unsigned int index = 0;
+  unsigned int idx = 0;
   unsigned int i = 1;
 
   /* Remove varobj from hash table.  */
   for (chp = var->obj_name; *chp; chp++)
     {
-      index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
+      idx = (idx + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
     }
 
-  cv = *(varobj_table + index);
+  cv = *(varobj_table + idx);
   prev = NULL;
   while ((cv != NULL) && (strcmp (cv->var->obj_name, var->obj_name) != 0))
     {
@@ -2125,7 +2125,7 @@ uninstall_variable (struct varobj *var)
     }
 
   if (prev == NULL)
-    *(varobj_table + index) = cv->next;
+    *(varobj_table + idx) = cv->next;
   else
     prev->next = cv->next;
 
@@ -2164,14 +2164,14 @@ uninstall_variable (struct varobj *var)
 
 /* Create and install a child of the parent of the given name.  */
 static struct varobj *
-create_child (struct varobj *parent, int index, char *name)
+create_child (struct varobj *parent, int idx, char *name)
 {
-  return create_child_with_value (parent, index, name, 
-				  value_of_child (parent, index));
+  return create_child_with_value (parent, idx, name,
+				  value_of_child (parent, idx));
 }
 
 static struct varobj *
-create_child_with_value (struct varobj *parent, int index, const char *name,
+create_child_with_value (struct varobj *parent, int idx, const char *name,
 			 struct value *value)
 {
   struct varobj *child;
@@ -2182,7 +2182,7 @@ create_child_with_value (struct varobj *parent, int index, const char *name,
   /* Name is allocated by name_of_child.  */
   /* FIXME: xstrdup should not be here.  */
   child->name = xstrdup (name);
-  child->index = index;
+  child->index = idx;
   child->parent = parent;
   child->root = parent->root;
   childs_name = xstrprintf ("%s.%s", parent->obj_name, name);
@@ -2462,9 +2462,9 @@ name_of_variable (struct varobj *var)
 /* What is the name of the INDEX'th child of VAR? Returns a malloc'd
    string.  */
 static char *
-name_of_child (struct varobj *var, int index)
+name_of_child (struct varobj *var, int idx)
 {
-  return (*var->root->lang->name_of_child) (var, index);
+  return (*var->root->lang->name_of_child) (var, idx);
 }
 
 /* What is the ``struct value *'' of the root variable VAR?
@@ -2546,11 +2546,11 @@ value_of_root (struct varobj **var_handle, int *type_changed)
 
 /* What is the ``struct value *'' for the INDEX'th child of PARENT?  */
 static struct value *
-value_of_child (struct varobj *parent, int index)
+value_of_child (struct varobj *parent, int idx)
 {
   struct value *value;
 
-  value = (*parent->root->lang->value_of_child) (parent, index);
+  value = (*parent->root->lang->value_of_child) (parent, idx);
 
   return value;
 }
@@ -2937,7 +2937,7 @@ value_struct_element_index (struct value *value, int type_index)
    information cannot be determined, set *CNAME, *CVALUE, or *CTYPE
    to NULL.  */
 static void 
-c_describe_child (struct varobj *parent, int index,
+c_describe_child (struct varobj *parent, int idx,
 		  char **cname, struct value **cvalue, struct type **ctype,
 		  char **cfull_expression)
 {
@@ -2964,13 +2964,13 @@ c_describe_child (struct varobj *parent, int index,
     case TYPE_CODE_ARRAY:
       if (cname)
 	*cname
-	  = xstrdup (int_string (index 
+	  = xstrdup (int_string (idx
 				 + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
 				 10, 1, 0, 0));
 
       if (cvalue && value)
 	{
-	  int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
+	  int real_index = idx + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
 
 	  gdb_value_subscript (value, real_index, cvalue);
 	}
@@ -2981,7 +2981,7 @@ c_describe_child (struct varobj *parent, int index,
       if (cfull_expression)
 	*cfull_expression = 
 	  xstrprintf ("(%s)[%s]", parent_expression, 
-		      int_string (index
+		      int_string (idx
 				  + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
 				  10, 1, 0, 0));
 
@@ -2991,23 +2991,23 @@ c_describe_child (struct varobj *parent, int index,
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
       if (cname)
-	*cname = xstrdup (TYPE_FIELD_NAME (type, index));
+	*cname = xstrdup (TYPE_FIELD_NAME (type, idx));
 
       if (cvalue && value)
 	{
 	  /* For C, varobj index is the same as type index.  */
-	  *cvalue = value_struct_element_index (value, index);
+	  *cvalue = value_struct_element_index (value, idx);
 	}
 
       if (ctype)
-	*ctype = TYPE_FIELD_TYPE (type, index);
+	*ctype = TYPE_FIELD_TYPE (type, idx);
 
       if (cfull_expression)
 	{
 	  char *join = was_ptr ? "->" : ".";
 
 	  *cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, join,
-					  TYPE_FIELD_NAME (type, index));
+					  TYPE_FIELD_NAME (type, idx));
 	}
 
       break;
@@ -3046,11 +3046,11 @@ c_describe_child (struct varobj *parent, int index,
 }
 
 static char *
-c_name_of_child (struct varobj *parent, int index)
+c_name_of_child (struct varobj *parent, int idx)
 {
   char *name;
 
-  c_describe_child (parent, index, &name, NULL, NULL, NULL);
+  c_describe_child (parent, idx, &name, NULL, NULL, NULL);
   return name;
 }
 
@@ -3136,20 +3136,20 @@ c_value_of_root (struct varobj **var_handle)
 }
 
 static struct value *
-c_value_of_child (struct varobj *parent, int index)
+c_value_of_child (struct varobj *parent, int idx)
 {
   struct value *value = NULL;
 
-  c_describe_child (parent, index, NULL, &value, NULL, NULL);
+  c_describe_child (parent, idx, NULL, &value, NULL, NULL);
   return value;
 }
 
 static struct type *
-c_type_of_child (struct varobj *parent, int index)
+c_type_of_child (struct varobj *parent, int idx)
 {
   struct type *type = NULL;
 
-  c_describe_child (parent, index, NULL, NULL, &type, NULL);
+  c_describe_child (parent, idx, NULL, NULL, &type, NULL);
   return type;
 }
 
@@ -3320,21 +3320,21 @@ enum accessibility { private_field, protected_field, public_field };
 /* Check if field INDEX of TYPE has the specified accessibility.
    Return 0 if so and 1 otherwise.  */
 static int 
-match_accessibility (struct type *type, int index, enum accessibility acc)
+match_accessibility (struct type *type, int idx, enum accessibility acc)
 {
-  if (acc == private_field && TYPE_FIELD_PRIVATE (type, index))
+  if (acc == private_field && TYPE_FIELD_PRIVATE (type, idx))
     return 1;
-  else if (acc == protected_field && TYPE_FIELD_PROTECTED (type, index))
+  else if (acc == protected_field && TYPE_FIELD_PROTECTED (type, idx))
     return 1;
-  else if (acc == public_field && !TYPE_FIELD_PRIVATE (type, index)
-	   && !TYPE_FIELD_PROTECTED (type, index))
+  else if (acc == public_field && !TYPE_FIELD_PRIVATE (type, idx)
+	   && !TYPE_FIELD_PROTECTED (type, idx))
     return 1;
   else
     return 0;
 }
 
 static void
-cplus_describe_child (struct varobj *parent, int index,
+cplus_describe_child (struct varobj *parent, int idx,
 		      char **cname, struct value **cvalue, struct type **ctype,
 		      char **cfull_expression)
 {
@@ -3393,13 +3393,13 @@ cplus_describe_child (struct varobj *parent, int index,
 	  else if (strcmp (parent->name, "protected") == 0)
 	    acc = protected_field;
 
-	  while (index >= 0)
+	  while (idx >= 0)
 	    {
 	      if ((type == basetype && type_index == vptr_fieldno)
 		  || TYPE_FIELD_ARTIFICIAL (type, type_index))
 		; /* ignore vptr */
 	      else if (match_accessibility (type, type_index, acc))
-		    --index;
+		    --idx;
 		  ++type_index;
 	    }
 	  --type_index;
@@ -3419,18 +3419,18 @@ cplus_describe_child (struct varobj *parent, int index,
 			    join, 
 			    TYPE_FIELD_NAME (type, type_index));
 	}
-      else if (index < TYPE_N_BASECLASSES (type))
+      else if (idx < TYPE_N_BASECLASSES (type))
 	{
 	  /* This is a baseclass.  */
 	  if (cname)
-	    *cname = xstrdup (TYPE_FIELD_NAME (type, index));
+	    *cname = xstrdup (TYPE_FIELD_NAME (type, idx));
 
 	  if (cvalue && value)
-	    *cvalue = value_cast (TYPE_FIELD_TYPE (type, index), value);
+	    *cvalue = value_cast (TYPE_FIELD_TYPE (type, idx), value);
 
 	  if (ctype)
 	    {
-	      *ctype = TYPE_FIELD_TYPE (type, index);
+	      *ctype = TYPE_FIELD_TYPE (type, idx);
 	    }
 
 	  if (cfull_expression)
@@ -3452,7 +3452,7 @@ cplus_describe_child (struct varobj *parent, int index,
 		 'class' keyword.  See PR mi/11912  */
 	      *cfull_expression = xstrprintf ("(%s(class %s%s) %s)", 
 					      ptr, 
-					      TYPE_FIELD_NAME (type, index),
+					      TYPE_FIELD_NAME (type, idx),
 					      ptr,
 					      parent_expression);
 	    }
@@ -3469,8 +3469,8 @@ cplus_describe_child (struct varobj *parent, int index,
 
 	     The special "fake" children are always output by varobj in
 	     this order.  So if INDEX == 2, it MUST be "protected".  */
-	  index -= TYPE_N_BASECLASSES (type);
-	  switch (index)
+	  idx -= TYPE_N_BASECLASSES (type);
+	  switch (idx)
 	    {
 	    case 0:
 	      if (children[v_public] > 0)
@@ -3509,16 +3509,16 @@ cplus_describe_child (struct varobj *parent, int index,
     }
   else
     {
-      c_describe_child (parent, index, cname, cvalue, ctype, cfull_expression);
+      c_describe_child (parent, idx, cname, cvalue, ctype, cfull_expression);
     }  
 }
 
 static char *
-cplus_name_of_child (struct varobj *parent, int index)
+cplus_name_of_child (struct varobj *parent, int idx)
 {
   char *name = NULL;
 
-  cplus_describe_child (parent, index, &name, NULL, NULL, NULL);
+  cplus_describe_child (parent, idx, &name, NULL, NULL, NULL);
   return name;
 }
 
@@ -3537,20 +3537,20 @@ cplus_value_of_root (struct varobj **var_handle)
 }
 
 static struct value *
-cplus_value_of_child (struct varobj *parent, int index)
+cplus_value_of_child (struct varobj *parent, int idx)
 {
   struct value *value = NULL;
 
-  cplus_describe_child (parent, index, NULL, &value, NULL, NULL);
+  cplus_describe_child (parent, idx, NULL, &value, NULL, NULL);
   return value;
 }
 
 static struct type *
-cplus_type_of_child (struct varobj *parent, int index)
+cplus_type_of_child (struct varobj *parent, int idx)
 {
   struct type *type = NULL;
 
-  cplus_describe_child (parent, index, NULL, NULL, &type, NULL);
+  cplus_describe_child (parent, idx, NULL, NULL, &type, NULL);
   return type;
 }
 
@@ -3596,11 +3596,11 @@ java_name_of_variable (struct varobj *parent)
 }
 
 static char *
-java_name_of_child (struct varobj *parent, int index)
+java_name_of_child (struct varobj *parent, int idx)
 {
   char *name, *p;
 
-  name = cplus_name_of_child (parent, index);
+  name = cplus_name_of_child (parent, idx);
   /* Escape any periods in the name...  */
   p = name;
 
@@ -3627,15 +3627,15 @@ java_value_of_root (struct varobj **var_handle)
 }
 
 static struct value *
-java_value_of_child (struct varobj *parent, int index)
+java_value_of_child (struct varobj *parent, int idx)
 {
-  return cplus_value_of_child (parent, index);
+  return cplus_value_of_child (parent, idx);
 }
 
 static struct type *
-java_type_of_child (struct varobj *parent, int index)
+java_type_of_child (struct varobj *parent, int idx)
 {
-  return cplus_type_of_child (parent, index);
+  return cplus_type_of_child (parent, idx);
 }
 
 static char *
@@ -3659,9 +3659,9 @@ ada_name_of_variable (struct varobj *parent)
 }
 
 static char *
-ada_name_of_child (struct varobj *parent, int index)
+ada_name_of_child (struct varobj *parent, int idx)
 {
-  return c_name_of_child (parent, index);
+  return c_name_of_child (parent, idx);
 }
 
 static char*
@@ -3677,15 +3677,15 @@ ada_value_of_root (struct varobj **var_handle)
 }
 
 static struct value *
-ada_value_of_child (struct varobj *parent, int index)
+ada_value_of_child (struct varobj *parent, int idx)
 {
-  return c_value_of_child (parent, index);
+  return c_value_of_child (parent, idx);
 }
 
 static struct type *
-ada_type_of_child (struct varobj *parent, int index)
+ada_type_of_child (struct varobj *parent, int idx)
 {
-  return c_type_of_child (parent, index);
+  return c_type_of_child (parent, idx);
 }
 
 static char *
-- 
1.7.5.4


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