-
Notifications
You must be signed in to change notification settings - Fork 274
Deprecate old instructiont API #4177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -211,7 +211,7 @@ bool remove_instanceoft::lower_instanceof( | |||
// GOTO programs before the target instruction without inserting into the | |||
// wrong basic block. | |||
goto_program.insert_before_swap(target); | |||
target->make_skip(); | |||
*target = goto_programt::make_skip(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not turn_into_skip
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a new instruction; now passing directly to insert_before_swap
.
@@ -915,7 +914,7 @@ void disjunctive_polynomial_accelerationt::build_fixed() | |||
if(loop.find(t)==loop.end()) | |||
{ | |||
// This instruction isn't part of the loop... Just remove it. | |||
fixedt->make_skip(); | |||
*fixedt = goto_programt::make_skip(fixedt->source_location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn_into_skip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -269,7 +269,7 @@ void sat_path_enumeratort::build_fixed() | |||
if(loop.find(t)==loop.end()) | |||
{ | |||
// This instruction isn't part of the loop... Just remove it. | |||
fixedt->make_skip(); | |||
*fixedt = goto_programt::make_skip(fixedt->source_location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn_into_skip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
auto add_instruction = [&]() { | ||
auto instruction = function.body.add_instruction(); | ||
auto add_instruction = [&](goto_programt::instructiont &&i) { | ||
auto instruction = function.body.add(std::move(i)); | ||
instruction->source_location = function_symbol.location; | ||
return instruction; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this lambda still have any value left in it? The make_*
calls would now also take a source location.
auto add_instruction = [&]() { | ||
auto instruction = function.body.add_instruction(); | ||
auto add_instruction = [&](goto_programt::instructiont &&i) { | ||
auto instruction = function.body.add(std::move(i)); | ||
instruction->source_location = function_symbol.location; | ||
instruction->source_location.set_function(function_name); | ||
return instruction; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above: I'm not sure this Lambda adds value. Though there also is #2149...
code_deadt removal(var_a); | ||
instructions.back().make_dead(); | ||
instructions.back().code = removal; | ||
instructions.emplace_back(goto_programt::make_dead(var_a)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use add
instead so as to avoid use of an implementation detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
instructions.emplace_back(goto_program_instruction_typet::DECL); | ||
code_declt declaration(var_a); | ||
instructions.back().make_decl(declaration); | ||
instructions.emplace_back(goto_programt::make_decl(var_a)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above: use add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -33,11 +33,10 @@ SCENARIO( | |||
|
|||
goto_functiont goto_function; | |||
auto &instructions = goto_function.body.instructions; | |||
instructions.emplace_back(goto_program_instruction_typet::ASSERT); | |||
instructions.back().make_assertion(x_le_10); | |||
instructions.emplace_back(goto_programt::make_assertion(x_le_10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use add
@@ -34,8 +34,7 @@ SCENARIO( | |||
|
|||
goto_functiont goto_function; | |||
auto &instructions = goto_function.body.instructions; | |||
instructions.emplace_back(goto_program_instruction_typet::ASSERT); | |||
instructions.back().make_assertion(x_le_10); | |||
instructions.emplace_back(goto_programt::make_assertion(x_le_10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use add
@@ -33,8 +33,7 @@ SCENARIO( | |||
|
|||
goto_functiont goto_function; | |||
auto &instructions = goto_function.body.instructions; | |||
instructions.emplace_back(goto_program_instruction_typet::ASSERT); | |||
instructions.back().make_assertion(x_le_10); | |||
instructions.emplace_back(goto_programt::make_assertion(x_le_10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 02f68bb).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100783282
We now avoid construction followed by overwriting, and construct the final object directly.
02f68bb
to
7d64d7e
Compare
@tautschnig The lambdas can definitively go away once we're agreed that .function isn't abused any more. |
(Moving the actual code changes recommended here into a new PR). |
d449057
to
09fde0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 09fde0d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100823060
No change to code, documentation only.