[C++ PATCH] Random cleanups

2017-05-30 Thread Nathan Sidwell
Some random cleanups.  Mainly fixing stale comments and awkward 
whitespacing.  Rename some name-lookup internal workers to the do_FOO form.


natan
--
Nathan Sidwell
2017-05-30  Nathan Sidwell  

	* cp-tree.def (OVERLOAD): Fix comment.
	* cp-tree.h: Fix comments and whitespace.
	* error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope.
	* name-lookup.c (add_decl_to_level): Assert not class.
	(check_local_shadow): Use OVL_P.
	(pushdecl_with_scope_1): Rename to ...
	(do_pushdecl_with_Scope): ... here.
	(do_nonmember_using_decl): Use qualified_namespace_lookup return
	value.
	(push_class_level_binding_1): Use OVL_P.
	(pushdecl_namespace_level): Use do_pushdecl_with_scope.
	(pushtag_1): Rename to ...
	(do_pushtag): ... here.  Adjust do_pushdecl_with_scope call.
	(pushtag): Adjust.
	(store_class_bindings): Do not time here.
	* name-lookup.h (pushdecl_outermost_localscope): Reorder.
	* pt.c (listify): Declare argvec at point of initialization.

Index: cp-tree.def
===
--- cp-tree.def	(revision 248689)
+++ cp-tree.def	(working copy)
@@ -228,8 +228,7 @@ DEFTREECODE (DEFERRED_NOEXCEPT, "deferre
member template, the template may be an IDENTIFIER_NODE.  */
 DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", tcc_expression, 2)
 
-/* A list-like node for chaining overloading candidates. TREE_TYPE is
-   the original name, and the parameter is the FUNCTION_DECL.  */
+/* One of a set of overloaded functions.  */
 DEFTREECODE (OVERLOAD, "overload", tcc_exceptional, 0)
 
 /* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or
Index: cp-tree.h
===
--- cp-tree.h	(revision 248689)
+++ cp-tree.h	(working copy)
@@ -692,7 +692,8 @@ struct GTY(()) tree_overload {
   tree function;
 };
 
-/* Iterator for a 1 dimensional overload. */
+/* Iterator for a 1 dimensional overload.  Permits iterating over the
+   outer level of a 2-d overload when explicitly enabled.  */
 
 class ovl_iterator 
 {
@@ -970,7 +971,7 @@ enum GTY(()) abstract_class_use {
   (LANG_IDENTIFIER_CAST (NODE)->class_template_info)
 
 /* The IDENTIFIER_BINDING is the innermost cxx_binding for the
-identifier.  It's PREVIOUS is the next outermost binding.  Each
+identifier.  Its PREVIOUS is the next outermost binding.  Each
 VALUE field is a DECL for the associated declaration.  Thus,
 name lookup consists simply of pulling off the node at the front
 of the list (modulo oddities for looking up the names of types,
@@ -1454,6 +1455,7 @@ union GTY((desc ("cp_tree_node_structure
 userdef_literal;
 };
 
+
 /* Global state.  */
 
 struct GTY(()) saved_scope {
@@ -2496,9 +2498,9 @@ struct GTY(()) lang_decl_fn {
   unsigned static_function : 1;
   unsigned pure_virtual : 1;
   unsigned defaulted_p : 1;
-
   unsigned has_in_charge_parm_p : 1;
   unsigned has_vtt_parm_p : 1;
+  
   unsigned pending_inline_p : 1;
   unsigned nonconverting : 1;
   unsigned thunk_p : 1;
Index: error.c
===
--- error.c	(revision 248689)
+++ error.c	(working copy)
@@ -1146,7 +1146,7 @@ dump_decl (cxx_pretty_printer *pp, tree
 
 case SCOPE_REF:
   dump_type (pp, TREE_OPERAND (t, 0), flags);
-  pp_colon_colon (pp);
+  pp_cxx_colon_colon (pp);
   dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME);
   break;
 
@@ -1193,8 +1193,7 @@ dump_decl (cxx_pretty_printer *pp, tree
 case OVERLOAD:
   if (!OVL_SINGLE_P (t))
 	{
-	  t = OVL_FIRST (t);
-	  tree ctx = CP_DECL_CONTEXT (t);
+	  tree ctx = ovl_scope (t);
 	  if (ctx != global_namespace)
 	{
 	  if (TYPE_P (ctx))
@@ -1203,7 +1202,7 @@ dump_decl (cxx_pretty_printer *pp, tree
 		dump_decl (pp, ctx, flags);
 	  pp_cxx_colon_colon (pp);
 	}
-	  dump_decl (pp, DECL_NAME (t), flags);
+	  dump_decl (pp, OVL_NAME (t), flags);
 	  break;
 	}
 
Index: name-lookup.c
===
--- name-lookup.c	(revision 248689)
+++ name-lookup.c	(working copy)
@@ -120,13 +120,12 @@ find_namespace_value (tree ns, tree name
 static void
 add_decl_to_level (cp_binding_level *b, tree decl)
 {
-  /* We used to record virtual tables as if they were ordinary
- variables, but no longer do so.  */
-  gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl)));
+  gcc_assert (b->kind != sk_class);
 
-  if (TREE_CODE (decl) == NAMESPACE_DECL
-  && !DECL_NAMESPACE_ALIAS (decl))
+  if (TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl))
 {
+  /* Inner namespaces get their own chain, to make walking
+	 simpler.  */
   DECL_CHAIN (decl) = b->namespaces;
   b->namespaces = decl;
 }
@@ -2132,8 +2131,7 @@ check_local_shadow (tree decl)
 
 	/* Warn if a variable shadows a non-function, or the variable
 	   is a function or a pointer-to-function.  */
-	if ((TREE_CODE (member) != FUNCTION_DECL
-	 && TREE_CODE (member) != OVERLOAD)

[PATCH] Random cleanups

2013-04-09 Thread Richard Biener

from my local tree.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-04-09  Richard Biener  

java/
* expr.c (build_java_binop): Pass a type to build_int_cst.

* tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa): Avoid
work that is not necessary.

Index: gcc/java/expr.c
===
--- gcc/java/expr.c (revision 197621)
+++ gcc/java/expr.c (working copy)
@@ -1531,7 +1531,7 @@ build_java_binop (enum tree_code op, tre
   }
 case LSHIFT_EXPR:
 case RSHIFT_EXPR:
-  mask = build_int_cst (NULL_TREE,
+  mask = build_int_cst (int_type_node,
TYPE_PRECISION (TREE_TYPE (arg1)) - 1);
   arg2 = fold_build2 (BIT_AND_EXPR, int_type_node, arg2, mask);
   break;
Index: gcc/tree-ssa-loop-manip.c
===
--- gcc/tree-ssa-loop-manip.c   (revision 197621)
+++ gcc/tree-ssa-loop-manip.c   (working copy)
@@ -489,7 +489,6 @@ find_uses_to_rename (bitmap changed_bbs,
 void
 rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag)
 {
-  bitmap *loop_exits;
   bitmap *use_blocks;
   bitmap names_to_rename;
 
@@ -505,11 +504,6 @@ rewrite_into_loop_closed_ssa (bitmap cha
 
   names_to_rename = BITMAP_ALLOC (&loop_renamer_obstack);
 
-  /* An array of bitmaps where LOOP_EXITS[I] is the set of basic blocks
- that are the destination of an edge exiting loop number I.  */
-  loop_exits = XNEWVEC (bitmap, number_of_loops ());
-  get_loops_exits (loop_exits);
-
   /* Uses of names to rename.  We don't have to initialize this array,
  because we know that we will only have entries for the SSA names
  in NAMES_TO_RENAME.  */
@@ -518,17 +512,26 @@ rewrite_into_loop_closed_ssa (bitmap cha
   /* Find the uses outside loops.  */
   find_uses_to_rename (changed_bbs, use_blocks, names_to_rename);
 
-  /* Add the PHI nodes on exits of the loops for the names we need to
- rewrite.  */
-  add_exit_phis (names_to_rename, use_blocks, loop_exits);
+  if (!bitmap_empty_p (names_to_rename))
+{
+  /* An array of bitmaps where LOOP_EXITS[I] is the set of basic blocks
+that are the destination of an edge exiting loop number I.  */
+  bitmap *loop_exits = XNEWVEC (bitmap, number_of_loops ());
+  get_loops_exits (loop_exits);
+
+  /* Add the PHI nodes on exits of the loops for the names we need to
+rewrite.  */
+  add_exit_phis (names_to_rename, use_blocks, loop_exits);
+
+  free (loop_exits);
+
+  /* Fix up all the names found to be used outside their original
+loops.  */
+  update_ssa (TODO_update_ssa);
+}
 
   bitmap_obstack_release (&loop_renamer_obstack);
   free (use_blocks);
-  free (loop_exits);
-
-  /* Fix up all the names found to be used outside their original
- loops.  */
-  update_ssa (TODO_update_ssa);
 }
 
 /* Check invariants of the loop closed ssa form for the USE in BB.  */


Re: [patch] Random cleanups

2012-09-06 Thread Richard Guenther
On Wed, Sep 5, 2012 at 10:34 PM, Steven Bosscher  wrote:
> Hello,
>
> Just some cleanups I did while working on something bigger.
>
> OK for trunk?

Ok.

Thanks,
Richard.

> Ciao!
> Steven
>
> * graphite.c (print_global_statistics): Use EDGE_COUNT instead
> of VEC_length.
> (print_graphite_scop_statistics): Likewise.
> * graphite-scop-detection.c (get_bb_type): Use single_succ_p.
> (print_graphite_scop_statistics): Use EDGE_COUNT, not VEC_length.
> (canonicalize_loop_closed_ssa): Use single_pred_p.
>
> * alias.c (reg_seen): Make this an sbitmap.
> (record_set, init_alias_analysis): Update.


[patch] Random cleanups

2012-09-05 Thread Steven Bosscher
Hello,

Just some cleanups I did while working on something bigger.

OK for trunk?

Ciao!
Steven

* graphite.c (print_global_statistics): Use EDGE_COUNT instead
of VEC_length.
(print_graphite_scop_statistics): Likewise.
* graphite-scop-detection.c (get_bb_type): Use single_succ_p.
(print_graphite_scop_statistics): Use EDGE_COUNT, not VEC_length.
(canonicalize_loop_closed_ssa): Use single_pred_p.

* alias.c (reg_seen): Make this an sbitmap.
(record_set, init_alias_analysis): Update.


random_cleanups.diff
Description: Binary data