Go patch committed: Remove the traverse_assignments code

Message ID CAOyqgcXa-YSZDONvOPW6qhr0GOJV9qkJ-635zrnk3Jy5JnhHkg@mail.gmail.com
State Unresolved
Headers
Series Go patch committed: Remove the traverse_assignments code |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Ian Lance Taylor Oct. 23, 2023, 1:48 a.m. UTC
  This patch to the Go frontend removes the traverse_assignments
support.  The last caller was removed in https://go.dev/cl/18261 in
2016.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
a6e74b0b3316f3f0b2096d6a175c31bed58ae4ed
  

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index d31fb336e41..398d2671b64 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-75b08794cb1485c955d13784c53a89174764af55
+c201fa2a684ada551ca9a0825a3075a0a69498de
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index b43f1393e33..91c7627a0e3 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -64,16 +64,6 @@  Statement::traverse_contents(Traverse* traverse)
   return this->do_traverse(traverse);
 }
 
-// Traverse assignments.
-
-bool
-Statement::traverse_assignments(Traverse_assignments* tassign)
-{
-  if (this->classification_ == STATEMENT_ERROR)
-    return false;
-  return this->do_traverse_assignments(tassign);
-}
-
 // Traverse an expression in a statement.  This is a helper function
 // for child classes.
 
@@ -288,17 +278,6 @@  Variable_declaration_statement::do_traverse(Traverse*)
   return TRAVERSE_CONTINUE;
 }
 
-// Traverse the assignments in a variable declaration.  Note that this
-// traversal is different from the usual traversal.
-
-bool
-Variable_declaration_statement::do_traverse_assignments(
-    Traverse_assignments* tassign)
-{
-  tassign->initialize_variable(this->var_);
-  return true;
-}
-
 // Lower the variable's initialization expression.
 
 Statement*
@@ -510,17 +489,6 @@  Temporary_statement::do_traverse(Traverse* traverse)
     return this->traverse_expression(traverse, &this->init_);
 }
 
-// Traverse assignments.
-
-bool
-Temporary_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  if (this->init_ == NULL)
-    return false;
-  tassign->value(&this->init_, true, true);
-  return true;
-}
-
 // Determine types.
 
 void
@@ -889,13 +857,6 @@  Assignment_statement::do_traverse(Traverse* traverse)
   return this->traverse_expression(traverse, &this->rhs_);
 }
 
-bool
-Assignment_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  tassign->assignment(&this->lhs_, &this->rhs_);
-  return true;
-}
-
 // Lower an assignment to a map index expression to a runtime function
 // call.  Mark some slice assignments as not requiring a write barrier.
 
@@ -1212,10 +1173,6 @@  class Assignment_operation_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1365,10 +1322,6 @@  class Tuple_assignment_statement : public Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1511,10 +1464,6 @@  public:
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1719,10 +1668,6 @@  class Tuple_receive_assignment_statement : public Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1862,10 +1807,6 @@  class Tuple_type_guard_assignment_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -2277,10 +2218,6 @@  class Inc_dec_statement : public Statement
   do_traverse(Traverse* traverse)
   { return this->traverse_expression(traverse, &this->expr_); }
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -2412,18 +2349,6 @@  Thunk_statement::do_traverse(Traverse* traverse)
   return this->traverse_expression(traverse, &this->call_);
 }
 
-// We implement traverse_assignment for a thunk statement because it
-// effectively copies the function call.
-
-bool
-Thunk_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  Expression* fn = this->call_->call_expression()->fn();
-  Expression* fn2 = fn;
-  tassign->value(&fn2, true, false);
-  return true;
-}
-
 // Determine types in a thunk statement.
 
 void
@@ -3148,23 +3073,6 @@  Statement::make_defer_statement(Call_expression* call,
 
 // Class Return_statement.
 
-// Traverse assignments.  We treat each return value as a top level
-// RHS in an expression.
-
-bool
-Return_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  Expression_list* vals = this->vals_;
-  if (vals != NULL)
-    {
-      for (Expression_list::iterator p = vals->begin();
-	   p != vals->end();
-	   ++p)
-	tassign->value(&*p, true, true);
-    }
-  return true;
-}
-
 // Lower a return statement.  If we are returning a function call
 // which returns multiple values which match the current function,
 // split up the call's results.  If the return statement lists
diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h
index 9ef63cb9a61..5fac01b916e 100644
--- a/gcc/go/gofrontend/statements.h
+++ b/gcc/go/gofrontend/statements.h
@@ -55,42 +55,6 @@  class Bstatement;
 class Bvariable;
 class Ast_dump_context;
 
-// This class is used to traverse assignments made by a statement
-// which makes assignments.
-
-class Traverse_assignments
-{
- public:
-  Traverse_assignments()
-  { }
-
-  virtual ~Traverse_assignments()
-  { }
-
-  // This is called for a variable initialization.
-  virtual void
-  initialize_variable(Named_object*) = 0;
-
-  // This is called for each assignment made by the statement.  PLHS
-  // points to the left hand side, and PRHS points to the right hand
-  // side.  PRHS may be NULL if there is no associated expression, as
-  // in the bool set by a non-blocking receive.
-  virtual void
-  assignment(Expression** plhs, Expression** prhs) = 0;
-
-  // This is called for each expression which is not passed to the
-  // assignment function.  This is used for some of the statements
-  // which assign two values, for which there is no expression which
-  // describes the value.  For ++ and -- the value is passed to both
-  // the assignment method and the rhs method.  IS_STORED is true if
-  // this value is being stored directly.  It is false if the value is
-  // computed but not stored.  IS_LOCAL is true if the value is being
-  // stored in a local variable or this is being called by a return
-  // statement.
-  virtual void
-  value(Expression**, bool is_stored, bool is_local) = 0;
-};
-
 // A single statement.
 
 class Statement
@@ -292,13 +256,6 @@  class Statement
   int
   traverse_contents(Traverse*);
 
-  // If this statement assigns some values, it calls a function for
-  // each value to which this statement assigns a value, and returns
-  // true.  If this statement does not assign any values, it returns
-  // false.
-  bool
-  traverse_assignments(Traverse_assignments* tassign);
-
   // Lower a statement.  This is called immediately after parsing to
   // simplify statements for further processing.  It returns the same
   // Statement or a new one.  FUNCTION is the function containing this
@@ -486,12 +443,6 @@  class Statement
   virtual int
   do_traverse(Traverse*) = 0;
 
-  // Implemented by child class: traverse assignments.  Any statement
-  // which includes an assignment should implement this.
-  virtual bool
-  do_traverse_assignments(Traverse_assignments*)
-  { return false; }
-
   // Implemented by the child class: lower this statement to a simpler
   // one.
   virtual Statement*
@@ -633,9 +584,6 @@  class Assignment_statement : public Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*);
-
   virtual Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -753,9 +701,6 @@  class Temporary_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*);
-
   void
   do_determine_types(Gogo*);
 
@@ -820,9 +765,6 @@  class Variable_declaration_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*);
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -869,9 +811,6 @@  class Return_statement : public Statement
   do_traverse(Traverse* traverse)
   { return this->traverse_expression_list(traverse, this->vals_); }
 
-  bool
-  do_traverse_assignments(Traverse_assignments*);
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1383,9 +1322,6 @@  class Thunk_statement : public Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*);
-
   void
   do_determine_types(Gogo*);
 
@@ -1719,10 +1655,6 @@  class For_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1783,10 +1715,6 @@  class For_range_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);