From defc4562dca00a5bb2dda49b50efa7614ea811b1 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Wed, 13 Feb 2019 13:14:51 +0000 Subject: [PATCH] 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. --- src/goto-programs/goto_program.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index 4d83f1aca78..05eff4316a9 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -945,6 +945,7 @@ class goto_programt {_target}); } + /// Create an assignment instruction static instructiont make_assignment( const code_assignt &_code, const source_locationt &l = source_locationt::nil()) @@ -952,6 +953,16 @@ class goto_programt return instructiont(_code, l, ASSIGN, nil_exprt(), {}); } + /// Create an assignment instruction + static instructiont make_assignment( + exprt lhs, + exprt rhs, + const source_locationt &l = source_locationt::nil()) + { + return instructiont( + code_assignt(std::move(lhs), std::move(rhs)), l, ASSIGN, nil_exprt(), {}); + } + static instructiont make_decl( const code_declt &_code, const source_locationt &l = source_locationt::nil()) @@ -959,12 +970,27 @@ class goto_programt return instructiont(_code, l, DECL, nil_exprt(), {}); } + /// Create a function call instruction static instructiont make_function_call( const code_function_callt &_code, const source_locationt &l = source_locationt::nil()) { return instructiont(_code, l, FUNCTION_CALL, nil_exprt(), {}); } + + /// Create a function call instruction + static instructiont make_function_call( + exprt function, + code_function_callt::argumentst arguments, + const source_locationt &l = source_locationt::nil()) + { + return instructiont( + code_function_callt(std::move(function), std::move(arguments)), + l, + FUNCTION_CALL, + nil_exprt(), + {}); + } }; /// Get control-flow successors of a given instruction. The instruction is