Skip to content

added code_blockt::statements(), which is a vector of codet #3080

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
Oct 7, 2018

Conversation

kroening
Copy link
Member

@kroening kroening commented Oct 2, 2018

The key benefit is that clients no longer need to do conversion of the
operands to codet.

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@kroening kroening requested review from smowton and tautschnig October 2, 2018 10:14
@kroening kroening changed the title added code_blockt::statenents(), which is a vector of codet added code_blockt::statements(), which is a vector of codet Oct 2, 2018
@kroening kroening force-pushed the code_blockt_operands branch from 380ad23 to bc925a1 Compare October 2, 2018 10:14
while(child_iter!=this_block.operands().end() &&
to_code(*child_iter).get_statement()==ID_decl)
while(child_iter != this_block.statements().end() &&
to_code(*child_iter).get_statement() == ID_decl)
Copy link
Contributor

Choose a reason for hiding this comment

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

to_code not longer needed

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

assert(tree.branch.size()==this_block_children.size());
for(auto blockidx=child_offset, blocklim=child_offset+nblocks;
blockidx!=blocklim;
++blockidx)
newblock.move_to_operands(this_block_children[blockidx]);

// Relabel the inner header:
to_code_label(to_code(newblock.operands()[0])).set_label(new_label_irep);
to_code_label(to_code(newblock.statements()[0])).set_label(new_label_irep);
Copy link
Contributor

Choose a reason for hiding this comment

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

to_code

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@@ -1845,7 +1845,7 @@ codet java_bytecode_convert_methodt::convert_instructions(

if(c.get_statement()!=ID_skip)
{
auto &lastlabel=to_code_label(to_code(root_block.operands().back()));
auto &lastlabel = to_code_label(to_code(root_block.statements().back()));
Copy link
Contributor

Choose a reason for hiding this comment

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

to_code

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@kroening kroening force-pushed the code_blockt_operands branch from bc925a1 to 4a6119a Compare October 2, 2018 10:20
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: 4a6119a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86588721

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Overall ok with me, some more suggestions below.

to_code(block.operands().back()).get_statement()!=ID_label)
if(
!block.has_operands() ||
block.statements().back().get_statement() != ID_label)
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: please add braces for readability

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

return to_code(initializer);
else
{
block.move_to_operands(initializer);
block.add(to_code(initializer));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be worth moving this use of to_code further up.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok


code_operandst &statements()
{
return (code_operandst &)get_sub();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use static_cast

Copy link
Member Author

Choose a reason for hiding this comment

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

That doesn't work, the C++ type system isn't that elaborate.

@kroening kroening removed their assignment Oct 2, 2018
The key benefit is that clients no longer need to do conversion of the
operands to codet.
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: 7d8b70c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86610791

explicit code_blockt(const std::list<codet> &_list):codet(ID_block)
{
operandst &o=operands();
auto &o = statements();
Copy link
Member

Choose a reason for hiding this comment

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

ois probably not the best variable name anymore here.

@@ -22,10 +22,8 @@ static bool insert_at_label(
const irep_idt &label,
code_blockt &dest)
{
Forall_operands(it, dest)
for(auto &c : dest.statements())
Copy link
Member

Choose a reason for hiding this comment

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

What does c stand for?

@peterschrammel peterschrammel removed their assignment Oct 6, 2018
@kroening kroening merged commit 2dc9574 into develop Oct 7, 2018
@kroening kroening deleted the code_blockt_operands branch October 7, 2018 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants