Skip to content

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

Merged
merged 1 commit into from
Feb 14, 2019
Merged

Conversation

kroening
Copy link
Member

No change to code, documentation only.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • n/a Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • n/a My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@@ -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();
Copy link
Collaborator

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?

Copy link
Member Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turn_into_skip

Copy link
Member Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turn_into_skip

Copy link
Member Author

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;
};
Copy link
Collaborator

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;
};
Copy link
Collaborator

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));
Copy link
Collaborator

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?

Copy link
Member Author

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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above: use add

Copy link
Member Author

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));
Copy link
Collaborator

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));
Copy link
Collaborator

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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use add

Copy link
Contributor

@allredj allredj left a 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.
@kroening kroening force-pushed the deprecate_old_instructiont_API branch from 02f68bb to 7d64d7e Compare February 13, 2019 16:02
@kroening
Copy link
Member Author

@tautschnig The lambdas can definitively go away once we're agreed that .function isn't abused any more.

@kroening
Copy link
Member Author

(Moving the actual code changes recommended here into a new PR).

@kroening kroening mentioned this pull request Feb 13, 2019
3 tasks
@kroening kroening force-pushed the deprecate_old_instructiont_API branch from d449057 to 09fde0d Compare February 13, 2019 17:49
Copy link
Contributor

@allredj allredj left a 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

@kroening kroening merged commit c033898 into develop Feb 14, 2019
@kroening kroening deleted the deprecate_old_instructiont_API branch February 14, 2019 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants