Skip to content

Commit 6a33e7e

Browse files
compiler: remove Array_index_expression::is_lvalue_
As of CL 77510 it is never true. Change-Id: I77eac8bd13701060ffe2a697f4e61838d8023f54 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/394695 Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent fbadca0 commit 6a33e7e

File tree

4 files changed

+8
-44
lines changed

4 files changed

+8
-44
lines changed

go/expressions.cc

+5-8
Original file line numberDiff line numberDiff line change
@@ -7671,8 +7671,7 @@ Expression::comparison(Translate_context* context, Type* result_type,
76717671
&& left_type->array_type()->length() == NULL)
76727672
{
76737673
Array_type* at = left_type->array_type();
7674-
bool is_lvalue = false;
7675-
left = at->get_value_pointer(context->gogo(), left, is_lvalue);
7674+
left = at->get_value_pointer(context->gogo(), left);
76767675
}
76777676
else if (left_type->interface_type() != NULL)
76787677
{
@@ -9276,7 +9275,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function,
92769275
Type* unsafe_ptr_type = Type::make_pointer_type(Type::make_void_type());
92779276
Expression* a1 = Expression::make_type_descriptor(element_type, loc);
92789277
Expression* a2 = Expression::make_temporary_reference(s1tmp, loc);
9279-
a2 = slice_type->array_type()->get_value_pointer(gogo, a2, false);
9278+
a2 = slice_type->array_type()->get_value_pointer(gogo, a2);
92809279
a2 = Expression::make_cast(unsafe_ptr_type, a2, loc);
92819280
Expression* a3 = Expression::make_temporary_reference(l1tmp, loc);
92829281
Expression* a4 = Expression::make_temporary_reference(c1tmp, loc);
@@ -13848,9 +13847,8 @@ Array_index_expression::do_get_backend(Translate_context* context)
1384813847
}
1384913848
else
1385013849
{
13851-
Expression* valptr =
13852-
array_type->get_value_pointer(gogo, this->array_,
13853-
this->is_lvalue_);
13850+
Expression* valptr = array_type->get_value_pointer(gogo,
13851+
this->array_);
1385413852
Bexpression* ptr = valptr->get_backend(context);
1385513853
ptr = gogo->backend()->pointer_offset_expression(ptr, start, loc);
1385613854

@@ -13891,8 +13889,7 @@ Array_index_expression::do_get_backend(Translate_context* context)
1389113889
Bexpression* offset = gogo->backend()->conditional_expression(bfn, int_btype,
1389213890
cond, zero,
1389313891
start, loc);
13894-
Expression* valptr = array_type->get_value_pointer(gogo, this->array_,
13895-
this->is_lvalue_);
13892+
Expression* valptr = array_type->get_value_pointer(gogo, this->array_);
1389613893
Bexpression* val = valptr->get_backend(context);
1389713894
val = gogo->backend()->pointer_offset_expression(val, offset, loc);
1389813895

go/expressions.h

+1-15
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ class Array_index_expression : public Expression
30553055
Expression* end, Expression* cap, Location location)
30563056
: Expression(EXPRESSION_ARRAY_INDEX, location),
30573057
array_(array), start_(start), end_(end), cap_(cap), type_(NULL),
3058-
is_lvalue_(false), needs_bounds_check_(true), is_flattened_(false)
3058+
needs_bounds_check_(true), is_flattened_(false)
30593059
{ }
30603060

30613061
// Return the array.
@@ -3087,18 +3087,6 @@ class Array_index_expression : public Expression
30873087
end() const
30883088
{ return this->end_; }
30893089

3090-
// Return whether this array index expression appears in an lvalue
3091-
// (left hand side of assignment) context.
3092-
bool
3093-
is_lvalue() const
3094-
{ return this->is_lvalue_; }
3095-
3096-
// Update this array index expression to indicate that it appears
3097-
// in a left-hand-side or lvalue context.
3098-
void
3099-
set_is_lvalue()
3100-
{ this->is_lvalue_ = true; }
3101-
31023090
void
31033091
set_needs_bounds_check(bool b)
31043092
{ this->needs_bounds_check_ = b; }
@@ -3174,8 +3162,6 @@ class Array_index_expression : public Expression
31743162
Expression* cap_;
31753163
// The type of the expression.
31763164
Type* type_;
3177-
// Whether expr appears in an lvalue context.
3178-
bool is_lvalue_;
31793165
// Whether bounds check is needed.
31803166
bool needs_bounds_check_;
31813167
// Whether this has already been flattened.

go/types.cc

+1-20
Original file line numberDiff line numberDiff line change
@@ -7815,7 +7815,7 @@ Array_type::finish_backend_element(Gogo* gogo)
78157815
// Return an expression for a pointer to the values in ARRAY.
78167816

78177817
Expression*
7818-
Array_type::get_value_pointer(Gogo*, Expression* array, bool is_lvalue) const
7818+
Array_type::get_value_pointer(Gogo*, Expression* array) const
78197819
{
78207820
if (this->length() != NULL)
78217821
{
@@ -7828,25 +7828,6 @@ Array_type::get_value_pointer(Gogo*, Expression* array, bool is_lvalue) const
78287828
}
78297829

78307830
// Slice.
7831-
7832-
if (is_lvalue)
7833-
{
7834-
Temporary_reference_expression* tref =
7835-
array->temporary_reference_expression();
7836-
Var_expression* ve = array->var_expression();
7837-
if (tref != NULL)
7838-
{
7839-
tref = tref->copy()->temporary_reference_expression();
7840-
tref->set_is_lvalue();
7841-
array = tref;
7842-
}
7843-
else if (ve != NULL)
7844-
{
7845-
ve = new Var_expression(ve->named_object(), ve->location());
7846-
array = ve;
7847-
}
7848-
}
7849-
78507831
return Expression::make_slice_info(array,
78517832
Expression::SLICE_INFO_VALUE_POINTER,
78527833
array->location());

go/types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2800,7 +2800,7 @@ class Array_type : public Type
28002800

28012801
// Return an expression for the pointer to the values in an array.
28022802
Expression*
2803-
get_value_pointer(Gogo*, Expression* array, bool is_lvalue) const;
2803+
get_value_pointer(Gogo*, Expression* array) const;
28042804

28052805
// Return an expression for the length of an array with this type.
28062806
Expression*

0 commit comments

Comments
 (0)