Skip to content

Commit e4dfc6c

Browse files
authored
Merge pull request #4003 from diffblue/use_make_X3
Use goto_programt::make_X factories in two places
2 parents 2376058 + 84514d0 commit e4dfc6c

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

src/goto-programs/goto_convert_exceptions.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ void goto_convertt::convert_msc_leave(
8383
convert(d_code, dest, mode);
8484
}
8585

86-
goto_programt::targett t=dest.add_instruction();
87-
t->make_goto(targets.leave_target);
88-
t->source_location=code.source_location();
86+
dest.add(
87+
goto_programt::make_goto(targets.leave_target, code.source_location()));
8988
}
9089

9190
void goto_convertt::convert_try_catch(
@@ -112,8 +111,7 @@ void goto_convertt::convert_try_catch(
112111

113112
// add a SKIP target for the end of everything
114113
goto_programt end;
115-
goto_programt::targett end_target=end.add_instruction();
116-
end_target->make_skip();
114+
goto_programt::targett end_target = end.add(goto_programt::make_skip());
117115

118116
// the first operand is the 'try' block
119117
convert(to_code(code.op0()), dest, mode);
@@ -124,7 +122,7 @@ void goto_convertt::convert_try_catch(
124122
catch_pop_instruction->code=code_pop_catcht();
125123

126124
// add a goto to the end of the 'try' block
127-
dest.add_instruction()->make_goto(end_target);
125+
dest.add(goto_programt::make_goto(end_target));
128126

129127
for(std::size_t i=1; i<code.operands().size(); i++)
130128
{
@@ -140,7 +138,7 @@ void goto_convertt::convert_try_catch(
140138
dest.destructive_append(tmp);
141139

142140
// add a goto to the end of the 'catch' block
143-
dest.add_instruction()->make_goto(end_target);
141+
dest.add(goto_programt::make_goto(end_target));
144142
}
145143

146144
catch_push_instruction->code=push_catch_code;
@@ -205,19 +203,17 @@ void goto_convertt::convert_CPROVER_throw(
205203
code.source_location(), targets.throw_stack_size, dest, mode);
206204

207205
// add goto
208-
goto_programt::targett t=dest.add_instruction();
209-
t->make_goto(targets.throw_target);
210-
t->source_location=code.source_location();
206+
dest.add(
207+
goto_programt::make_goto(targets.throw_target, code.source_location()));
211208
}
212209
else // otherwise, we do a return
213210
{
214211
// need to process destructor stack
215212
unwind_destructor_stack(code.source_location(), 0, dest, mode);
216213

217214
// add goto
218-
goto_programt::targett t=dest.add_instruction();
219-
t->make_goto(targets.return_target);
220-
t->source_location=code.source_location();
215+
dest.add(
216+
goto_programt::make_goto(targets.return_target, code.source_location()));
221217
}
222218
}
223219

src/goto-programs/goto_inline_class.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ void goto_inlinet::parameter_assignments(
6161
{
6262
const symbolt &symbol=ns.lookup(identifier);
6363

64-
goto_programt::targett decl=dest.add_instruction();
65-
decl->make_decl();
66-
decl->code=code_declt(symbol.symbol_expr());
64+
goto_programt::targett decl = dest.add(
65+
goto_programt::make_decl(symbol.symbol_expr(), source_location));
6766
decl->code.add_source_location()=source_location;
68-
decl->source_location=source_location;
6967
decl->function=adjust_function?target->function:function_name;
7068
}
7169

@@ -169,11 +167,9 @@ void goto_inlinet::parameter_destruction(
169167
{
170168
const symbolt &symbol=ns.lookup(identifier);
171169

172-
goto_programt::targett dead=dest.add_instruction();
173-
dead->make_dead();
174-
dead->code=code_deadt(symbol.symbol_expr());
170+
goto_programt::targett dead = dest.add(
171+
goto_programt::make_dead(symbol.symbol_expr(), source_location));
175172
dead->code.add_source_location()=source_location;
176-
dead->source_location=source_location;
177173
dead->function=adjust_function?target->function:function_name;
178174
}
179175
}

0 commit comments

Comments
 (0)