Skip to content

Commit 111d05f

Browse files
committed
Refactor formatting of code_declt to use initial_value()
To avoid directly accessing the operands.
1 parent 541cd8a commit 111d05f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util/format_expr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,13 @@ std::ostream &format_rec(std::ostream &os, const exprt &expr)
354354
{
355355
return os << "dead " << format(to_code_dead(code).symbol()) << ";";
356356
}
357-
else if(statement == ID_decl)
357+
else if(const auto decl = expr_try_dynamic_cast<code_declt>(code))
358358
{
359-
const auto &declaration_symb = to_code_decl(code).symbol();
359+
const auto &declaration_symb = decl->symbol();
360360
os << "decl " << format(declaration_symb.type()) << " "
361361
<< format(declaration_symb);
362-
if(code.operands().size() > 1)
363-
os << " = " << format(code.op1());
362+
if(const optionalt<exprt> initial_value = decl->initial_value())
363+
os << " = " << format(*initial_value);
364364
return os << ";";
365365
}
366366
else if(statement == ID_function_call)

0 commit comments

Comments
 (0)