-
Notifications
You must be signed in to change notification settings - Fork 274
Cleanup of operands() accesses #23
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
9c5a1ae
to
f907248
Compare
f907248
to
bad02a1
Compare
bad02a1
to
bd098eb
Compare
bd098eb
to
a4145aa
Compare
a4145aa
to
b4e83a7
Compare
b4e83a7
to
5498001
Compare
5498001
to
a01e3a1
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.
This is an old PR so may be too distant for you to remember it's purpose!I've had a look through and changes all look like they don't change behaviour just improve type correctness and better for loops.
Main changes are consistency with prefix vs. post fix increamentors and a couple of places that can use range based for.
This also needs to be rebased - which may be more effort than it is worth.
@@ -2578,25 +2578,26 @@ void cpp_typecheckt::typecheck_function_call_arguments( | |||
} | |||
} | |||
|
|||
for(std::size_t i=0; i<parameters.size(); i++) | |||
exprt::operandst::iterator arg_it=expr.arguments().begin(); | |||
for(std::size_t i=0; i<parameters.size(); i++, ++arg_it) |
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 either prefix or postfix to increment these.
@@ -2634,10 +2635,12 @@ void cpp_typecheck_resolvet::resolve_with_arguments( | |||
const cpp_typecheck_fargst &fargs) | |||
{ | |||
// not clear what this is good for | |||
for(std::size_t i=0; i<fargs.operands.size(); i++) | |||
for(exprt::operandst::const_iterator it=fargs.operands.begin(); |
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.
Can use a ranged for here
|
||
for(std::size_t i=1; i<operands.size(); i++) | ||
for(exprt::operandst::const_iterator |
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.
Range based for.
@@ -282,7 +282,7 @@ class code_assumet:public codet | |||
inline code_assumet():codet(ID_assume) | |||
{ | |||
// will change to resize(1) in the future | |||
operands().reserve(1); | |||
reserve_operands(1); |
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.
Is the comment above still relevant/correct? Is reserve_operands
what resize
ended up being called?
a01e3a1
to
e1b120b
Compare
I have now refreshed/rebased this pull request, and have taken into account all the comments as far as applicable. |
@thk123, can you please check whether your comments have been taken into account? |
@peterschrammel I think these (1, 3) comments are still outstanding. Are there reasons for not addressing them @tautschnig? |
e1b120b
to
e76a3a3
Compare
I have addressed the remaining comments, which induced some further cleanup. |
e76a3a3
to
383a9de
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.
Last few changes - apologies about wrongly saying should use op0()
rather than front()
, should have checked was an exprt
not an operandst
- I have removed this comment.
|
||
exprt temporary; | ||
new_temporary(expr.arguments()[i].source_location(), | ||
parameters[i].type().subtype(), | ||
new_temporary(arg_it->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.
The parameter should be on the next line. It might be worth rebasing again so you get the lint output from just modified lines.
@@ -109,7 +109,8 @@ bool cpp_typecheck_fargst::match( | |||
return false; | |||
} | |||
|
|||
for(std::size_t i=0; i<ops.size(); i++) | |||
exprt::operandst::iterator it=ops.begin(); | |||
for(std::size_t i=0; i<ops.size(); i++, ++it) |
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.
Still mixing post fix and prefix incrementing. Maybe this isn't really a problem (I think it looks weird but it isn't in the coding guidelines) but I thought I'd see this being picked up in other PR reviews.
return op0(); | ||
} | ||
|
||
inline bool has_return_value() const | ||
{ | ||
return operands().size()==1; | ||
if(operands().empty()) return false; // backwards compatibility |
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.
False on the new line.
if(operands().empty())
return false; // backwards compatibility
Use iterators instead of indexed access. This may re-enable std::list support (for exprt::operandst) if taken further.
383a9de
to
e527f64
Compare
Thanks a lot for the careful scrutiny! I believe I have addressed the issues, but looking at the cpplint run yields some rather unrelated problems. @thk123 Could you please take a look at the travis output? |
@tautschnig You seem to be based off a commit that is before the script that just checks the modified lines, if you rebase I imagine they will go away (or at least the only ones left should be legitimate errors). It should also fix the python crash at the end. |
…ession-broken Fixed taint configuration
abstraction: put all functions into one namespace/class
Although USE_LIST is gone as of r3530, there are a number of cases where iterators are preferable over indexed access to elements.
This is a duplicate of #9 after restoring all links to the SVN.