Skip to content

Commit 3c4e26c

Browse files
tautschnigkroening
authored andcommitted
Statement-list front-end: do not use equal_exprt for assignments
We have `code_frontend_assignt` for this purpose.
1 parent 3a6341f commit 3c4e26c

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/statement-list/parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,8 @@ Param_Assignment:
10981098
Variable_Name TOK_ASSIGNMENT IL_Operand
10991099
{
11001100
newstack($$);
1101-
parser_stack($$) = equal_exprt{std::move(parser_stack($1)),
1102-
std::move(parser_stack($3))};
1101+
parser_stack($$) = code_frontend_assignt(std::move(parser_stack($1)),
1102+
std::move(parser_stack($3)));
11031103
}
11041104
;
11051105
Opt_Data_Block:

src/statement-list/statement_list_parse_tree_io.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ static void output_constant(std::ostream &os, const constant_exprt &constant)
4040
/// Prints the assignment of a module parameter to the given output stream.
4141
/// \param [out] os: Stream that should receive the result.
4242
/// \param assignment: Assignment that shall be printed.
43-
static void
44-
output_parameter_assignment(std::ostream &os, const equal_exprt &assignment)
43+
static void output_parameter_assignment(
44+
std::ostream &os,
45+
const code_frontend_assignt &assignment)
4546
{
4647
os << assignment.lhs().get(ID_identifier) << " := ";
4748
const constant_exprt *const constant =
@@ -246,11 +247,10 @@ void output_instruction(
246247
output_constant(os, *constant);
247248
continue;
248249
}
249-
const equal_exprt *const equal = expr_try_dynamic_cast<equal_exprt>(expr);
250-
if(equal)
250+
if(const auto assign = expr_try_dynamic_cast<code_frontend_assignt>(expr))
251251
{
252252
os << "\n\t";
253-
output_parameter_assignment(os, *equal);
253+
output_parameter_assignment(os, *assign);
254254
continue;
255255
}
256256
os << '\t' << expr.id();

src/statement-list/statement_list_typecheck.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,9 +1593,9 @@ void statement_list_typecheckt::typecheck_CPROVER_assert(
15931593
const codet &op_code,
15941594
symbolt &tia_element)
15951595
{
1596-
const equal_exprt *const assignment =
1597-
expr_try_dynamic_cast<equal_exprt>(op_code.op1());
1598-
if(assignment)
1596+
if(
1597+
const auto assignment =
1598+
expr_try_dynamic_cast<code_frontend_assignt>(op_code.op1()))
15991599
{
16001600
const code_assertt assertion{
16011601
typecheck_function_call_argument_rhs(tia_element, assignment->rhs())};
@@ -1612,9 +1612,9 @@ void statement_list_typecheckt::typecheck_CPROVER_assume(
16121612
const codet &op_code,
16131613
symbolt &tia_element)
16141614
{
1615-
const equal_exprt *const assignment =
1616-
expr_try_dynamic_cast<equal_exprt>(op_code.op1());
1617-
if(assignment)
1615+
if(
1616+
const auto assignment =
1617+
expr_try_dynamic_cast<code_frontend_assignt>(op_code.op1()))
16181618
{
16191619
const code_assumet assumption{
16201620
typecheck_function_call_argument_rhs(tia_element, assignment->rhs())};
@@ -1660,7 +1660,7 @@ void statement_list_typecheckt::typecheck_called_function(
16601660
const code_typet &called_type{to_code_type(called_function_sym.type)};
16611661

16621662
// Check if function name is followed by data block.
1663-
if(!can_cast_expr<equal_exprt>(op_code.op1()))
1663+
if(!can_cast_expr<code_frontend_assignt>(op_code.op1()))
16641664
{
16651665
error() << "Function calls should not address instance data blocks" << eom;
16661666
throw TYPECHECK_ERROR;
@@ -1669,11 +1669,11 @@ void statement_list_typecheckt::typecheck_called_function(
16691669
// Check if function interface matches the call and fill argument list.
16701670
const code_typet::parameterst &params{called_type.parameters()};
16711671
code_function_callt::argumentst args;
1672-
std::vector<equal_exprt> assignments;
1672+
std::vector<code_frontend_assignt> assignments;
16731673
for(const auto &expr : op_code.operands())
16741674
{
1675-
if(can_cast_expr<equal_exprt>(expr))
1676-
assignments.push_back(to_equal_expr(expr));
1675+
if(auto assign = expr_try_dynamic_cast<code_frontend_assignt>(expr))
1676+
assignments.push_back(*assign);
16771677
}
16781678

16791679
for(const code_typet::parametert &param : params)
@@ -1706,13 +1706,13 @@ void statement_list_typecheckt::typecheck_called_function_block(
17061706
}
17071707

17081708
exprt statement_list_typecheckt::typecheck_function_call_arguments(
1709-
const std::vector<equal_exprt> &assignments,
1709+
const std::vector<code_frontend_assignt> &assignments,
17101710
const code_typet::parametert &param,
17111711
const symbolt &tia_element)
17121712
{
17131713
const irep_idt &param_name = param.get_base_name();
17141714
const typet &param_type = param.type();
1715-
for(const equal_exprt &assignment : assignments)
1715+
for(const auto &assignment : assignments)
17161716
{
17171717
const symbol_exprt &lhs{to_symbol_expr(assignment.lhs())};
17181718
if(param_name == lhs.get_identifier())
@@ -1752,11 +1752,11 @@ exprt statement_list_typecheckt::typecheck_function_call_argument_rhs(
17521752
}
17531753

17541754
exprt statement_list_typecheckt::typecheck_return_value_assignment(
1755-
const std::vector<equal_exprt> &assignments,
1755+
const std::vector<code_frontend_assignt> &assignments,
17561756
const typet &return_type,
17571757
const symbolt &tia_element)
17581758
{
1759-
for(const equal_exprt &assignment : assignments)
1759+
for(const auto &assignment : assignments)
17601760
{
17611761
const symbol_exprt &lhs{to_symbol_expr(assignment.lhs())};
17621762
if(ID_statement_list_return_value_id == lhs.get_identifier())

src/statement-list/statement_list_typecheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ class statement_list_typecheckt : public typecheckt
719719
/// \param tia_element: Symbol representation of the TIA element.
720720
/// \return Expression including the assigned symbol's name and type.
721721
exprt typecheck_function_call_arguments(
722-
const std::vector<equal_exprt> &assignments,
722+
const std::vector<code_frontend_assignt> &assignments,
723723
const code_typet::parametert &param,
724724
const symbolt &tia_element);
725725

@@ -740,7 +740,7 @@ class statement_list_typecheckt : public typecheckt
740740
/// \param tia_element: Symbol representation of the TIA element.
741741
/// \return Expression including the assigned symbol's name and type.
742742
exprt typecheck_return_value_assignment(
743-
const std::vector<equal_exprt> &assignments,
743+
const std::vector<code_frontend_assignt> &assignments,
744744
const typet &return_type,
745745
const symbolt &tia_element);
746746

0 commit comments

Comments
 (0)