]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Come up with is_empty for hash_{table,map,set}.
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2019 12:37:22 +0000 (12:37 +0000)
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2019 12:37:22 +0000 (12:37 +0000)
2019-05-03  Martin Liska  <mliska@suse.cz>

* hash-map.h: Add is_empty function.
* hash-set.h: Likewise.
* hash-table.h: Likewise.
* dwarf2out.c (dwarf2out_finish): Use is_empty instead of
elements () == 0 (and similar usages).
* gimple-ssa-store-merging.c (pass_store_merging::terminate_and_process_all_chains): Likewise.
* gimplify.c (gimplify_bind_expr): Likewise.
(gimplify_switch_expr): Likewise.
* hash-map-tests.c (test_map_of_strings_to_int): Likewise.
* ipa-icf.c (sem_item_optimizer::remove_symtab_node): Likewise.
* postreload-gcse.c (dump_hash_table): Likewise.
(gcse_after_reload_main): Likewise.
* predict.c (combine_predictions_for_bb): Likewise.
* tree-parloops.c (reduction_phi): Likewise.
(separate_decls_in_region): Likewise.
(transform_to_exit_first_loop): Likewise.
(gen_parallel_loop): Likewise.
(gather_scalar_reductions): Likewise.
(try_create_reduction_list): Likewise.
* var-tracking.c (dump_vars): Likewise.
(emit_notes_for_changes): Likewise.
(vt_emit_notes): Likewise.
2019-05-03  Martin Liska  <mliska@suse.cz>

* call.c (build_aggr_conv): Use is_empty instead of
elements () == 0 (and similar usages).
* parser.c (cp_parser_lambda_introducer): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270851 138bc75d-0d04-0410-961f-82ee72b054a4

16 files changed:
gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/parser.c
gcc/dwarf2out.c
gcc/gimple-ssa-store-merging.c
gcc/gimplify.c
gcc/hash-map-tests.c
gcc/hash-map.h
gcc/hash-set.h
gcc/hash-table.h
gcc/ipa-icf.c
gcc/postreload-gcse.c
gcc/predict.c
gcc/tree-parloops.c
gcc/var-tracking.c

index d656ad76ab93c348778d723ff169208a19e01e25..ac134c60419c13bc927b84a8367d13eb0e3f7703 100644 (file)
@@ -1,3 +1,28 @@
+2019-05-03  Martin Liska  <mliska@suse.cz>
+
+       * hash-map.h: Add is_empty function.
+       * hash-set.h: Likewise.
+       * hash-table.h: Likewise.
+       * dwarf2out.c (dwarf2out_finish): Use is_empty instead of
+       elements () == 0 (and similar usages).
+       * gimple-ssa-store-merging.c (pass_store_merging::terminate_and_process_all_chains): Likewise.
+       * gimplify.c (gimplify_bind_expr): Likewise.
+       (gimplify_switch_expr): Likewise.
+       * hash-map-tests.c (test_map_of_strings_to_int): Likewise.
+       * ipa-icf.c (sem_item_optimizer::remove_symtab_node): Likewise.
+       * postreload-gcse.c (dump_hash_table): Likewise.
+       (gcse_after_reload_main): Likewise.
+       * predict.c (combine_predictions_for_bb): Likewise.
+       * tree-parloops.c (reduction_phi): Likewise.
+       (separate_decls_in_region): Likewise.
+       (transform_to_exit_first_loop): Likewise.
+       (gen_parallel_loop): Likewise.
+       (gather_scalar_reductions): Likewise.
+       (try_create_reduction_list): Likewise.
+       * var-tracking.c (dump_vars): Likewise.
+       (emit_notes_for_changes): Likewise.
+       (vt_emit_notes): Likewise.
+
 2019-05-03  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/90316
index 129a00a5314cf9807313fda3c80d5d9d8316683c..d9b7d2bb36ddfbf9d87bbcdc98ef8b912bbf3c57 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-03  Martin Liska  <mliska@suse.cz>
+
+       * call.c (build_aggr_conv): Use is_empty instead of
+       elements () == 0 (and similar usages).
+       * parser.c (cp_parser_lambda_introducer): Likewise.
+
 2019-05-02  Nathan Sidwell  <nathan@acm.org>
 
        * semantics.c (finish_id_expression_1): Remove unreachable code.
index 23898f0659fb73de4bb19b7b47b60abf356dc78b..1a79017eff460f36d9c5884d79e0ca7c2e844f45 100644 (file)
@@ -986,7 +986,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
       tree val;
       bool ok;
 
-      if (pset.elements () && field_in_pset (pset, field))
+      if (!pset.is_empty () && field_in_pset (pset, field))
        continue;
       if (i < CONSTRUCTOR_NELTS (ctor))
        {
index 3d908916ae3f7d4c1daaafc3b4858b4d9a94a74a..332f4bfcebd79e37a87a508cef728271324c799b 100644 (file)
@@ -10769,7 +10769,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
         Optimize for the zero or one explicit captures cases and only create
         the hash_set after adding second capture.  */
       bool found = false;
-      if (ids.elements ())
+      if (!ids.is_empty ())
        found = ids.add (capture_id);
       else if (first_capture_id == NULL_TREE)
        first_capture_id = capture_id;
index b9a624e1ac7fadffbdd82c12d18a3785b6483e20..366c904491adebc78e40674af75e93565b39b487 100644 (file)
@@ -31321,7 +31321,7 @@ dwarf2out_finish (const char *filename)
   flush_limbo_die_list ();
 
   if (inline_entry_data_table)
-    gcc_assert (inline_entry_data_table->elements () == 0);
+    gcc_assert (inline_entry_data_table->is_empty ());
 
   if (flag_checking)
     {
index 4a8cf6f847fd21296df3fb548db4a55ee8871fef..81e6269cc8a386419e3c18aeac82d947371fc0f0 100644 (file)
@@ -2150,7 +2150,7 @@ pass_store_merging::terminate_and_process_all_chains ()
   bool ret = false;
   while (m_stores_head)
     ret |= terminate_and_release_chain (m_stores_head);
-  gcc_assert (m_stores.elements () == 0);
+  gcc_assert (m_stores.is_empty ());
   gcc_assert (m_stores_head == NULL);
 
   return ret;
index e59f38261c3699d88199568c68a4a9ecf0de266e..b6c60855351cf3c0f21311d0d4765238c0a4bb79 100644 (file)
@@ -1423,7 +1423,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
 
                  oacc_declare_returns->remove (t);
 
-                 if (oacc_declare_returns->elements () == 0)
+                 if (oacc_declare_returns->is_empty ())
                    {
                      delete oacc_declare_returns;
                      oacc_declare_returns = NULL;
@@ -2418,7 +2418,7 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
 
       if (gimplify_ctxp->live_switch_vars)
        {
-         gcc_assert (gimplify_ctxp->live_switch_vars->elements () == 0);
+         gcc_assert (gimplify_ctxp->live_switch_vars->is_empty ());
          delete gimplify_ctxp->live_switch_vars;
        }
       gimplify_ctxp->live_switch_vars = saved_live_switch_vars;
index acbfdb9e9ab2b64ea86f98426aabb3faaa867ed8..b79c7821684497994836fc793a8e310b5bcc47e4 100644 (file)
@@ -53,7 +53,7 @@ test_map_of_strings_to_int ()
   const char *eric = "half a bee";
 
   /* A fresh hash_map should be empty.  */
-  ASSERT_EQ (0, m.elements ());
+  ASSERT_TRUE (m.is_empty ());
   ASSERT_EQ (NULL, m.get (ostrich));
 
   /* Populate the hash_map.  */
index 9d41696902e76b603ee925024b314e3e370a7f69..a3ef283a1f9b37f13b28e06a3dc6dd45240e0180 100644 (file)
@@ -211,6 +211,9 @@ public:
 
   void empty () { m_table.empty(); }
 
+  /* Return true when there are no elements in this hash map.  */
+  bool is_empty () const { return m_table.is_empty (); }
+
   class iterator
   {
   public:
index 8e1f38b1965fec920dff075702dded63fc5ccb4d..de3532f5f6806cf4fab1a11564724c42d789a056 100644 (file)
@@ -88,6 +88,9 @@ public:
 
   void empty () { m_table.empty (); }
 
+  /* Return true when there are no elements in this hash set.  */
+  bool is_empty () const { return m_table.is_empty (); }
+
   class iterator
   {
   public:
index 7ba6356f3aef0048a7936fecc9785ea33cace774..4178616478e2055da39367b45ba42c62fed316f9 100644 (file)
@@ -402,6 +402,9 @@ public:
   /* This function clears all entries in this hash table.  */
   void empty () { if (elements ()) empty_slow (); }
 
+  /* Return true when there are no elements in this hash table.  */
+  bool is_empty () const { return elements () == 0; }
+
   /* This function clears a specified SLOT in a hash table.  It is
      useful when you've already done the lookup and don't want to do it
      again. */
index e4c9dda0df1e6221f2c0406316f195789bd1493f..074181491da92ec2783143189a1a6c5f7fb5c0bd 100644 (file)
@@ -2475,7 +2475,7 @@ sem_item_optimizer::varpool_removal_hook (varpool_node *node, void *data)
 void
 sem_item_optimizer::remove_symtab_node (symtab_node *node)
 {
-  gcc_assert (!m_classes.elements ());
+  gcc_assert (m_classes.is_empty ());
 
   m_removed_items_set.add (node);
 }
index a165351ca961fdbc26c9e3c08d15f86e729e7a23..e47376708837b9d83f20723030381c5cede2ba4f 100644 (file)
@@ -504,7 +504,7 @@ dump_hash_table (FILE *file)
            (long) expr_table->size (),
            (long) expr_table->elements (),
            expr_table->collisions ());
-  if (expr_table->elements () > 0)
+  if (!expr_table->is_empty ())
     {
       fprintf (file, "\n\ntable entries:\n");
       expr_table->traverse <FILE *, dump_expr_hash_table_entry> (file);
@@ -1386,7 +1386,7 @@ gcse_after_reload_main (rtx f ATTRIBUTE_UNUSED)
   if (dump_file)
     dump_hash_table (dump_file);
 
-  if (expr_table->elements () > 0)
+  if (!expr_table->is_empty ())
     {
       /* Knowing which MEMs are transparent through a block can signifiantly
         increase the number of redundant loads found.  So compute transparency
index 60a19d7edd12f9e67025ea3c699f98323e1f0034..b010c20ff7d362cde0ca6a0036384a55d404bbf1 100644 (file)
@@ -1252,7 +1252,7 @@ combine_predictions_for_bb (basic_block bb, bool dry_run)
       if (dump_file)
        {
          fprintf (dump_file, "Predictions for bb %i\n", bb->index);
-         if (unlikely_edges.elements () == 0)
+         if (unlikely_edges.is_empty ())
            fprintf (dump_file,
                     "%i edges in bb %i predicted to even probabilities\n",
                     nedges, bb->index);
index 2fddc59beb21757412ba8f3b565425a24ffafab4..968368f7f441bb5f39197c425545acf3c40dca01 100644 (file)
@@ -238,7 +238,7 @@ reduction_phi (reduction_info_table_type *reduction_list, gimple *phi)
 {
   struct reduction_info tmpred, *red;
 
-  if (reduction_list->elements () == 0 || phi == NULL)
+  if (reduction_list->is_empty () || phi == NULL)
     return NULL;
 
   if (gimple_uid (phi) == (unsigned int)-1
@@ -1390,7 +1390,7 @@ separate_decls_in_region (edge entry, edge exit,
            }
        }
 
-  if (name_copies.elements () == 0 && reduction_list->elements () == 0)
+  if (name_copies.is_empty () && reduction_list->is_empty ())
     {
       /* It may happen that there is nothing to copy (if there are only
          loop carried and external variables in the loop).  */
@@ -1407,7 +1407,7 @@ separate_decls_in_region (edge entry, edge exit,
       TYPE_NAME (type) = type_name;
 
       name_copies.traverse <tree, add_field_for_name> (type);
-      if (reduction_list && reduction_list->elements () > 0)
+      if (reduction_list && !reduction_list->is_empty ())
        {
          /* Create the fields for reductions.  */
          reduction_list->traverse <tree, add_field_for_reduction> (type);
@@ -1430,7 +1430,7 @@ separate_decls_in_region (edge entry, edge exit,
 
       /* Load the calculation from memory (after the join of the threads).  */
 
-      if (reduction_list && reduction_list->elements () > 0)
+      if (reduction_list && !reduction_list->is_empty ())
        {
          reduction_list
            ->traverse <struct clsn_data *, create_stores_for_reduction>
@@ -1991,7 +1991,7 @@ transform_to_exit_first_loop (struct loop *loop,
          PHI_RESULT of this phi is the resulting value of the reduction
          variable when exiting the loop.  */
 
-      if (reduction_list->elements () > 0)
+      if (!reduction_list->is_empty ())
        {
          struct reduction_info *red;
 
@@ -2440,7 +2440,7 @@ gen_parallel_loop (struct loop *loop,
     }
 
   /* Generate initializations for reductions.  */
-  if (reduction_list->elements () > 0)
+  if (!reduction_list->is_empty ())
     reduction_list->traverse <struct loop *, initialize_reductions> (loop);
 
   /* Eliminate the references to local variables from the loop.  */
@@ -2476,7 +2476,7 @@ gen_parallel_loop (struct loop *loop,
     loc = gimple_location (cond_stmt);
   create_parallel_loop (loop, create_loop_fn (loc), arg_struct, new_arg_struct,
                        n_threads, loc, oacc_kernels_p);
-  if (reduction_list->elements () > 0)
+  if (!reduction_list->is_empty ())
     create_call_for_reduction (loop, reduction_list, &clsn_data);
 
   scev_reset ();
@@ -2679,7 +2679,7 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
     }
 
  gather_done:
-  if (reduction_list->elements () == 0)
+  if (reduction_list->is_empty ())
     return;
 
   /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
@@ -2806,7 +2806,7 @@ try_create_reduction_list (loop_p loop,
              fprintf (dump_file,
                       "  checking if it is part of reduction pattern:\n");
            }
-         if (reduction_list->elements () == 0)
+         if (reduction_list->is_empty ())
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                fprintf (dump_file,
index 55ff354c37c74b269e7333a4451069be48a47f4a..c9de93473d16ebd0ac081e01a575f02def51fd37 100644 (file)
@@ -7332,7 +7332,7 @@ dump_var (variable *var)
 static void
 dump_vars (variable_table_type *vars)
 {
-  if (vars->elements () > 0)
+  if (!vars->is_empty ())
     {
       fprintf (dump_file, "Variables:\n");
       vars->traverse <void *, dump_var_tracking_slot> (NULL);
@@ -9060,7 +9060,7 @@ emit_notes_for_changes (rtx_insn *insn, enum emit_note_where where,
   emit_note_data data;
   variable_table_type *htab = shared_hash_htab (vars);
 
-  if (!changed_variables->elements ())
+  if (changed_variables->is_empty ())
     return;
 
   if (MAY_HAVE_DEBUG_BIND_INSNS)
@@ -9538,7 +9538,7 @@ vt_emit_notes (void)
   basic_block bb;
   dataflow_set cur;
 
-  gcc_assert (!changed_variables->elements ());
+  gcc_assert (changed_variables->is_empty ());
 
   /* Free memory occupied by the out hash tables, as they aren't used
      anymore.  */