some tree struct marking
diff mbox series

Message ID fc557d70-11f9-8097-ffb1-c56729b19f93@acm.org
State New
Headers show
Series
  • some tree struct marking
Related show

Commit Message

Nathan Sidwell Sept. 10, 2019, 9:35 p.m. UTC
We were (still) not correctly marking the C++ tree structs.  This patch 
fixes that and
1) adds MARK_TS_TYPE_NON_COMMON, because we needed it.
2) sorts the order of marking nodes, so it's a little easier to figure 
where to put new ones.
3) reformats & sorts the common tree_node_structure_for_code to be a 
little clearer in what it's doing.

(these switch statements seem a fine exception to the usual formatting 
rules)

I'll commit to trunk shortly, as the non-c++ bits are sufficiently obvious.

nathan

Patch
diff mbox series

2019-09-10  Nathan Sidwell  <nathan@acm.org>

	gcc/
	* tree.h (MARK_TS_TYPE_NON_COMMON): New.
	* tree.c (tree_node_structure_for_code): Reformat and alphabetize.

	gcc/cp/
	* c-objcp-common.c (cp-objcp-common.c): Alphababetize and
	correctly mark all C++ nodes.
	* decl.c (cp_tree_node_structure): Alphabetize.

Index: gcc/cp/cp-objcp-common.c
===================================================================
--- gcc/cp/cp-objcp-common.c	(revision 275596)
+++ gcc/cp/cp-objcp-common.c	(working copy)
@@ -366,102 +366,111 @@  void
 cp_common_init_ts (void)
 {
-  MARK_TS_DECL_NON_COMMON (USING_DECL);
-  MARK_TS_DECL_COMMON (TEMPLATE_DECL);
-  MARK_TS_DECL_COMMON (WILDCARD_DECL);
+  /* With type.  */
+  MARK_TS_TYPED (PTRMEM_CST);
+  MARK_TS_TYPED (LAMBDA_EXPR);
+  MARK_TS_TYPED (TYPE_ARGUMENT_PACK);
 
-  MARK_TS_COMMON (TEMPLATE_TEMPLATE_PARM);
-  MARK_TS_COMMON (TEMPLATE_TYPE_PARM);
-  MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
+  /* Random new trees.  */
+  MARK_TS_COMMON (BASELINK);
+  MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (OVERLOAD);
+  MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
   MARK_TS_COMMON (TYPENAME_TYPE);
   MARK_TS_COMMON (TYPEOF_TYPE);
-  MARK_TS_COMMON (UNDERLYING_TYPE);
-  MARK_TS_COMMON (BASELINK);
-  MARK_TS_COMMON (TYPE_PACK_EXPANSION);
-  MARK_TS_COMMON (TYPE_ARGUMENT_PACK);
-  MARK_TS_COMMON (DECLTYPE_TYPE);
-  MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
+  MARK_TS_COMMON (UNDERLYING_TYPE);
 
-  MARK_TS_TYPED (SWITCH_STMT);
-  MARK_TS_TYPED (IF_STMT);
-  MARK_TS_TYPED (FOR_STMT);
-  MARK_TS_TYPED (RANGE_FOR_STMT);
-  MARK_TS_TYPED (EH_SPEC_BLOCK);
-  MARK_TS_TYPED (CLEANUP_STMT);
-  MARK_TS_TYPED (SCOPE_REF);
-  MARK_TS_TYPED (TRY_BLOCK);
-  MARK_TS_TYPED (HANDLER);
-  MARK_TS_TYPED (TYPE_ARGUMENT_PACK);
-  MARK_TS_TYPED (NOEXCEPT_EXPR);
-  MARK_TS_TYPED (WHILE_STMT);
-  MARK_TS_TYPED (BREAK_STMT);
-  MARK_TS_TYPED (DO_STMT);
-  MARK_TS_TYPED (CONTINUE_STMT);
-  MARK_TS_TYPED (PTRMEM_CST);
-  MARK_TS_TYPED (USING_STMT);
-  MARK_TS_TYPED (OMP_DEPOBJ);
+  /* New decls.  */
+  MARK_TS_DECL_COMMON (TEMPLATE_DECL);
+  MARK_TS_DECL_COMMON (WILDCARD_DECL);
+
+  MARK_TS_DECL_NON_COMMON (USING_DECL);
 
+  /* New Types.  */
+  MARK_TS_TYPE_NON_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
+  MARK_TS_TYPE_NON_COMMON (TEMPLATE_TEMPLATE_PARM);
+  MARK_TS_TYPE_NON_COMMON (TEMPLATE_TYPE_PARM);
+  MARK_TS_TYPE_NON_COMMON (TYPE_ARGUMENT_PACK);
+  MARK_TS_TYPE_NON_COMMON (TYPE_PACK_EXPANSION);
+
+  /* Statements.  */
+  MARK_TS_EXP (BREAK_STMT);
+  MARK_TS_EXP (CLEANUP_STMT);
+  MARK_TS_EXP (CONTINUE_STMT);
+  MARK_TS_EXP (DO_STMT);
+  MARK_TS_EXP (EH_SPEC_BLOCK);
+  MARK_TS_EXP (FOR_STMT);
+  MARK_TS_EXP (HANDLER);
+  MARK_TS_EXP (IF_STMT);
+  MARK_TS_EXP (OMP_DEPOBJ);
+  MARK_TS_EXP (RANGE_FOR_STMT);
+  MARK_TS_EXP (SWITCH_STMT);
+  MARK_TS_EXP (TRY_BLOCK);
+  MARK_TS_EXP (USING_STMT);
+  MARK_TS_EXP (WHILE_STMT);
+
+  /* Random expressions.  */
+  MARK_TS_EXP (ADDRESSOF_EXPR);
   MARK_TS_EXP (AGGR_INIT_EXPR);
+  MARK_TS_EXP (ALIGNOF_EXPR);
+  MARK_TS_EXP (ARROW_EXPR);
+  MARK_TS_EXP (AT_ENCODE_EXPR);
+  MARK_TS_EXP (CAST_EXPR);
+  MARK_TS_EXP (CONST_CAST_EXPR);
   MARK_TS_EXP (CTOR_INITIALIZER);
-  MARK_TS_EXP (EXPR_STMT);
-  MARK_TS_EXP (TAG_DEFN);
+  MARK_TS_EXP (DELETE_EXPR);
+  MARK_TS_EXP (DOTSTAR_EXPR);
+  MARK_TS_EXP (DYNAMIC_CAST_EXPR);
   MARK_TS_EXP (EMPTY_CLASS_EXPR);
+  MARK_TS_EXP (EXPR_STMT);
+  MARK_TS_EXP (IMPLICIT_CONV_EXPR);
+  MARK_TS_EXP (MEMBER_REF);
   MARK_TS_EXP (MODOP_EXPR);
-  MARK_TS_EXP (THROW_EXPR);
-  MARK_TS_EXP (CAST_EXPR);
-  MARK_TS_EXP (TYPE_EXPR);
+  MARK_TS_EXP (MUST_NOT_THROW_EXPR);
+  MARK_TS_EXP (NEW_EXPR);
+  MARK_TS_EXP (NOEXCEPT_EXPR);
+  MARK_TS_EXP (NON_DEPENDENT_EXPR);
+  MARK_TS_EXP (OFFSETOF_EXPR);
+  MARK_TS_EXP (OFFSET_REF);
+  MARK_TS_EXP (PSEUDO_DTOR_EXPR);
   MARK_TS_EXP (REINTERPRET_CAST_EXPR);
-  MARK_TS_EXP (CONST_CAST_EXPR);
+  MARK_TS_EXP (SCOPE_REF);
   MARK_TS_EXP (STATIC_CAST_EXPR);
-  MARK_TS_EXP (DYNAMIC_CAST_EXPR);
-  MARK_TS_EXP (IMPLICIT_CONV_EXPR);
+  MARK_TS_EXP (STMT_EXPR);
+  MARK_TS_EXP (TAG_DEFN);
   MARK_TS_EXP (TEMPLATE_ID_EXPR);
-  MARK_TS_EXP (ARROW_EXPR);
-  MARK_TS_EXP (UNARY_PLUS_EXPR);
+  MARK_TS_EXP (THROW_EXPR);
   MARK_TS_EXP (TRAIT_EXPR);
-
-  MARK_TS_EXP (NON_DEPENDENT_EXPR);
-  MARK_TS_EXP (NEW_EXPR);
-  MARK_TS_EXP (VEC_NEW_EXPR);
-  MARK_TS_EXP (MEMBER_REF);
-  MARK_TS_EXP (DOTSTAR_EXPR);
-  MARK_TS_EXP (DELETE_EXPR);
-  MARK_TS_EXP (VEC_DELETE_EXPR);
-  MARK_TS_EXP (PSEUDO_DTOR_EXPR);
   MARK_TS_EXP (TYPEID_EXPR);
-  MARK_TS_EXP (MUST_NOT_THROW_EXPR);
-  MARK_TS_EXP (STMT_EXPR);
-  MARK_TS_EXP (OFFSET_REF);
-  MARK_TS_EXP (OFFSETOF_EXPR);
-  MARK_TS_EXP (ADDRESSOF_EXPR);
+  MARK_TS_EXP (TYPE_EXPR);
+  MARK_TS_EXP (UNARY_PLUS_EXPR);
+  MARK_TS_EXP (VEC_DELETE_EXPR);
   MARK_TS_EXP (VEC_INIT_EXPR);
-  MARK_TS_EXP (LAMBDA_EXPR);
-
-  MARK_TS_EXP (ALIGNOF_EXPR);
-  MARK_TS_EXP (AT_ENCODE_EXPR);
+  MARK_TS_EXP (VEC_NEW_EXPR);
 
-  MARK_TS_EXP (NONTYPE_ARGUMENT_PACK);
+  /* Fold expressions.  */
+  MARK_TS_EXP (BINARY_LEFT_FOLD_EXPR);
+  MARK_TS_EXP (BINARY_RIGHT_FOLD_EXPR);
   MARK_TS_EXP (EXPR_PACK_EXPANSION);
+  MARK_TS_EXP (NONTYPE_ARGUMENT_PACK);
   MARK_TS_EXP (UNARY_LEFT_FOLD_EXPR);
   MARK_TS_EXP (UNARY_RIGHT_FOLD_EXPR);
-  MARK_TS_EXP (BINARY_LEFT_FOLD_EXPR);
-  MARK_TS_EXP (BINARY_RIGHT_FOLD_EXPR);
 
-  MARK_TS_EXP (REQUIRES_EXPR);
-  MARK_TS_EXP (SIMPLE_REQ);
-  MARK_TS_EXP (TYPE_REQ);
-  MARK_TS_EXP (COMPOUND_REQ);
-  MARK_TS_EXP (NESTED_REQ);
-  MARK_TS_EXP (PRED_CONSTR);
+  /* Constraints.  */
   MARK_TS_EXP (CHECK_CONSTR);
-  MARK_TS_EXP (EXPR_CONSTR);
-  MARK_TS_EXP (TYPE_CONSTR);
-  MARK_TS_EXP (ICONV_CONSTR);
+  MARK_TS_EXP (COMPOUND_REQ);
+  MARK_TS_EXP (CONJ_CONSTR);
   MARK_TS_EXP (DEDUCT_CONSTR);
+  MARK_TS_EXP (DISJ_CONSTR);
   MARK_TS_EXP (EXCEPT_CONSTR);
+  MARK_TS_EXP (EXPR_CONSTR);
+  MARK_TS_EXP (ICONV_CONSTR);
+  MARK_TS_EXP (NESTED_REQ);
   MARK_TS_EXP (PARM_CONSTR);
-  MARK_TS_EXP (CONJ_CONSTR);
-  MARK_TS_EXP (DISJ_CONSTR);
+  MARK_TS_EXP (PRED_CONSTR);
+  MARK_TS_EXP (REQUIRES_EXPR);
+  MARK_TS_EXP (SIMPLE_REQ);
+  MARK_TS_EXP (TYPE_CONSTR);
+  MARK_TS_EXP (TYPE_REQ);
 
   c_common_init_ts ();
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 275596)
+++ gcc/cp/decl.c	(working copy)
@@ -16828,18 +16828,18 @@  cp_tree_node_structure (union lang_tree_
   switch (TREE_CODE (&t->generic))
     {
-    case DEFERRED_PARSE:	return TS_CP_DEFERRED_PARSE;
+    case ARGUMENT_PACK_SELECT:  return TS_CP_ARGUMENT_PACK_SELECT;
+    case BASELINK:		return TS_CP_BASELINK;
+    case CONSTRAINT_INFO:       return TS_CP_CONSTRAINT_INFO;
     case DEFERRED_NOEXCEPT:	return TS_CP_DEFERRED_NOEXCEPT;
+    case DEFERRED_PARSE:	return TS_CP_DEFERRED_PARSE;
     case IDENTIFIER_NODE:	return TS_CP_IDENTIFIER;
+    case LAMBDA_EXPR:		return TS_CP_LAMBDA_EXPR;
     case OVERLOAD:		return TS_CP_OVERLOAD;
-    case TEMPLATE_PARM_INDEX:	return TS_CP_TPI;
     case PTRMEM_CST:		return TS_CP_PTRMEM;
-    case BASELINK:		return TS_CP_BASELINK;
-    case TEMPLATE_DECL:		return TS_CP_TEMPLATE_DECL;
     case STATIC_ASSERT:		return TS_CP_STATIC_ASSERT;
-    case ARGUMENT_PACK_SELECT:  return TS_CP_ARGUMENT_PACK_SELECT;
-    case TRAIT_EXPR:		return TS_CP_TRAIT_EXPR;
-    case LAMBDA_EXPR:		return TS_CP_LAMBDA_EXPR;
+    case TEMPLATE_DECL:		return TS_CP_TEMPLATE_DECL;
     case TEMPLATE_INFO:		return TS_CP_TEMPLATE_INFO;
-    case CONSTRAINT_INFO:       return TS_CP_CONSTRAINT_INFO;
+    case TEMPLATE_PARM_INDEX:	return TS_CP_TPI;
+    case TRAIT_EXPR:		return TS_CP_TRAIT_EXPR;
     case USERDEF_LITERAL:	return TS_CP_USERDEF_LITERAL;
     default:			return TS_CP_GENERIC;
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 275596)
+++ gcc/tree.c	(working copy)
@@ -456,69 +456,59 @@  tree_node_structure_for_code (enum tree_
     {
     case tcc_declaration:
-      {
-	switch (code)
-	  {
-	  case FIELD_DECL:
-	    return TS_FIELD_DECL;
-	  case PARM_DECL:
-	    return TS_PARM_DECL;
-	  case VAR_DECL:
-	    return TS_VAR_DECL;
-	  case LABEL_DECL:
-	    return TS_LABEL_DECL;
-	  case RESULT_DECL:
-	    return TS_RESULT_DECL;
-	  case DEBUG_EXPR_DECL:
-	    return TS_DECL_WRTL;
-	  case CONST_DECL:
-	    return TS_CONST_DECL;
-	  case TYPE_DECL:
-	    return TS_TYPE_DECL;
-	  case FUNCTION_DECL:
-	    return TS_FUNCTION_DECL;
-	  case TRANSLATION_UNIT_DECL:
-	    return TS_TRANSLATION_UNIT_DECL;
-	  default:
-	    return TS_DECL_NON_COMMON;
-	  }
-      }
-    case tcc_type:
-      return TS_TYPE_NON_COMMON;
-    case tcc_reference:
-    case tcc_comparison:
-    case tcc_unary:
+      switch (code)
+	{
+	case CONST_DECL:	return TS_CONST_DECL;
+	case DEBUG_EXPR_DECL:	return TS_DECL_WRTL;
+	case FIELD_DECL:	return TS_FIELD_DECL;
+	case FUNCTION_DECL:	return TS_FUNCTION_DECL;
+	case LABEL_DECL:	return TS_LABEL_DECL;
+	case PARM_DECL:		return TS_PARM_DECL;
+	case RESULT_DECL:	return TS_RESULT_DECL;
+	case TRANSLATION_UNIT_DECL: return TS_TRANSLATION_UNIT_DECL;
+	case TYPE_DECL:		return TS_TYPE_DECL;
+	case VAR_DECL:		return TS_VAR_DECL;
+	default: 		return TS_DECL_NON_COMMON;
+	}
+
+    case tcc_type:		return TS_TYPE_NON_COMMON;
+
     case tcc_binary:
+    case tcc_comparison:
     case tcc_expression:
+    case tcc_reference:
     case tcc_statement:
-    case tcc_vl_exp:
-      return TS_EXP;
+    case tcc_unary:
+    case tcc_vl_exp:		return TS_EXP;
+
     default:  /* tcc_constant and tcc_exceptional */
       break;
     }
+
   switch (code)
     {
       /* tcc_constant cases.  */
-    case VOID_CST:		return TS_TYPED;
+    case COMPLEX_CST:		return TS_COMPLEX;
+    case FIXED_CST:		return TS_FIXED_CST;
     case INTEGER_CST:		return TS_INT_CST;
     case POLY_INT_CST:		return TS_POLY_INT_CST;
     case REAL_CST:		return TS_REAL_CST;
-    case FIXED_CST:		return TS_FIXED_CST;
-    case COMPLEX_CST:		return TS_COMPLEX;
-    case VECTOR_CST:		return TS_VECTOR;
     case STRING_CST:		return TS_STRING;
+    case VECTOR_CST:		return TS_VECTOR;
+    case VOID_CST:		return TS_TYPED;
+
       /* tcc_exceptional cases.  */
-    case ERROR_MARK:		return TS_COMMON;
-    case IDENTIFIER_NODE:	return TS_IDENTIFIER;
-    case TREE_LIST:		return TS_LIST;
-    case TREE_VEC:		return TS_VEC;
-    case SSA_NAME:		return TS_SSA_NAME;
-    case PLACEHOLDER_EXPR:	return TS_COMMON;
-    case STATEMENT_LIST:	return TS_STATEMENT_LIST;
     case BLOCK:			return TS_BLOCK;
     case CONSTRUCTOR:		return TS_CONSTRUCTOR;
-    case TREE_BINFO:		return TS_BINFO;
+    case ERROR_MARK:		return TS_COMMON;
+    case IDENTIFIER_NODE:	return TS_IDENTIFIER;
     case OMP_CLAUSE:		return TS_OMP_CLAUSE;
     case OPTIMIZATION_NODE:	return TS_OPTIMIZATION;
+    case PLACEHOLDER_EXPR:	return TS_COMMON;
+    case SSA_NAME:		return TS_SSA_NAME;
+    case STATEMENT_LIST:	return TS_STATEMENT_LIST;
     case TARGET_OPTION_NODE:	return TS_TARGET_OPTION;
+    case TREE_BINFO:		return TS_BINFO;
+    case TREE_LIST:		return TS_LIST;
+    case TREE_VEC:		return TS_VEC;
 
     default:
Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 275596)
+++ gcc/tree.h	(working copy)
@@ -95,4 +95,8 @@  as_internal_fn (combined_fn code)
    tree_contains_struct[C][TS_TYPE_WITH_LANG_SPECIFIC] = true)
 
+#define MARK_TS_TYPE_NON_COMMON(C)			\
+  (MARK_TS_TYPE_WITH_LANG_SPECIFIC (C),			\
+   tree_contains_struct[C][TS_TYPE_NON_COMMON] = true)	\
+
 #define MARK_TS_DECL_MINIMAL(C)				\
   (MARK_TS_COMMON (C),					\