Skip to content

Commit ce60366

Browse files
authored
Merge pull request #4030 from tautschnig/raii-cleanup
Remove useless temporaries
2 parents 478d0ee + 0858a89 commit ce60366

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/analyses/flow_insensitive_analysis.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,9 @@ bool flow_insensitive_analysis_baset::do_function_call(
210210

211211
goto_programt temp;
212212

213-
exprt rhs =
214-
side_effect_expr_nondett(code.lhs().type(), l_call->source_location);
213+
goto_programt::targett r = temp.add(goto_programt::make_return(code_returnt(
214+
side_effect_expr_nondett(code.lhs().type(), l_call->source_location))));
215215

216-
goto_programt::targett r =
217-
temp.add(goto_programt::make_return(code_returnt(rhs)));
218216
r->function=f_it->first;
219217
r->location_number=0;
220218

src/analyses/goto_check.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,18 +1834,16 @@ void goto_checkt::goto_check(
18341834
if(local_bitvector_analysis->dirty(variable))
18351835
{
18361836
// need to mark the dead variable as dead
1837-
exprt address_of_expr=address_of_exprt(variable);
18381837
exprt lhs=ns.lookup(CPROVER_PREFIX "dead_object").symbol_expr();
1839-
address_of_expr =
1840-
typecast_exprt::conditional_cast(address_of_expr, lhs.type());
1841-
const if_exprt rhs(
1838+
exprt address_of_expr = typecast_exprt::conditional_cast(
1839+
address_of_exprt(variable), lhs.type());
1840+
if_exprt rhs(
18421841
side_effect_expr_nondett(bool_typet(), i.source_location),
1843-
address_of_expr,
1844-
lhs,
1845-
lhs.type());
1842+
std::move(address_of_expr),
1843+
lhs);
18461844
goto_programt::targett t =
18471845
new_code.add(goto_programt::make_assignment(
1848-
code_assignt(lhs, rhs), i.source_location));
1846+
code_assignt(std::move(lhs), std::move(rhs)), i.source_location));
18491847
t->code.add_source_location()=i.source_location;
18501848
}
18511849
}

src/goto-instrument/loop_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ void build_havoc_code(
4545
m_it++)
4646
{
4747
exprt lhs=*m_it;
48-
exprt rhs =
49-
side_effect_expr_nondett(lhs.type(), loop_head->source_location);
48+
side_effect_expr_nondett rhs(lhs.type(), loop_head->source_location);
5049

5150
goto_programt::targett t = dest.add(goto_programt::make_assignment(
52-
code_assignt(lhs, rhs), loop_head->source_location));
51+
code_assignt(std::move(lhs), std::move(rhs)),
52+
loop_head->source_location));
5353
t->function=loop_head->function;
5454
t->code.add_source_location()=loop_head->source_location;
5555
}

0 commit comments

Comments
 (0)