Skip to content

Commit defc456

Browse files
author
Daniel Kroening
committed
extend make_assignment and make_function_call APIs
This permits constructing assignments and function calls without code_assignt and code_function_callt, respectively, in the same style as the existing API for declarations, returns etc.
1 parent 7b3f0c1 commit defc456

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/goto-programs/goto_program.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,26 +945,52 @@ class goto_programt
945945
{_target});
946946
}
947947

948+
/// Create an assignment instruction
948949
static instructiont make_assignment(
949950
const code_assignt &_code,
950951
const source_locationt &l = source_locationt::nil())
951952
{
952953
return instructiont(_code, l, ASSIGN, nil_exprt(), {});
953954
}
954955

956+
/// Create an assignment instruction
957+
static instructiont make_assignment(
958+
exprt lhs,
959+
exprt rhs,
960+
const source_locationt &l = source_locationt::nil())
961+
{
962+
return instructiont(
963+
code_assignt(std::move(lhs), std::move(rhs)), l, ASSIGN, nil_exprt(), {});
964+
}
965+
955966
static instructiont make_decl(
956967
const code_declt &_code,
957968
const source_locationt &l = source_locationt::nil())
958969
{
959970
return instructiont(_code, l, DECL, nil_exprt(), {});
960971
}
961972

973+
/// Create a function call instruction
962974
static instructiont make_function_call(
963975
const code_function_callt &_code,
964976
const source_locationt &l = source_locationt::nil())
965977
{
966978
return instructiont(_code, l, FUNCTION_CALL, nil_exprt(), {});
967979
}
980+
981+
/// Create a function call instruction
982+
static instructiont make_function_call(
983+
exprt function,
984+
code_function_callt::argumentst arguments,
985+
const source_locationt &l = source_locationt::nil())
986+
{
987+
return instructiont(
988+
code_function_callt(std::move(function), std::move(arguments)),
989+
l,
990+
FUNCTION_CALL,
991+
nil_exprt(),
992+
{});
993+
}
968994
};
969995

970996
/// Get control-flow successors of a given instruction. The instruction is

0 commit comments

Comments
 (0)