-
Notifications
You must be signed in to change notification settings - Fork 278
C++ front-end: use ranged for #3066
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,8 @@ void cpp_idt::print(std::ostream &out, unsigned indent) const | |
|
||
if(!sub.empty()) | ||
{ | ||
for(cpp_id_mapt::const_iterator it=sub.begin(); | ||
it!=sub.end(); | ||
it++) | ||
it->second.print(out, indent+2); | ||
for(const auto &s : sub) | ||
s.second.print(out, indent + 2); | ||
|
||
out << '\n'; | ||
} | ||
|
@@ -63,22 +61,16 @@ void cpp_idt::print_fields(std::ostream &out, unsigned indent) const | |
for(unsigned i=0; i<indent; i++) out << ' '; | ||
out << " class_identifier=" << class_identifier << '\n'; | ||
|
||
for(scope_listt::const_iterator | ||
it=secondary_scopes.begin(); | ||
it!=secondary_scopes.end(); | ||
it++) | ||
for(const auto &s : secondary_scopes) | ||
{ | ||
for(unsigned i=0; i<indent; i++) out << ' '; | ||
out << " secondary_scope=" << (*it)->identifier << '\n'; | ||
out << " secondary_scope=" << s->identifier << '\n'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could further simplify this loop by using |
||
} | ||
|
||
for(scope_listt::const_iterator | ||
it=using_scopes.begin(); | ||
it!=using_scopes.end(); | ||
it++) | ||
for(const auto &s : using_scopes) | ||
{ | ||
for(unsigned i=0; i<indent; i++) out << ' '; | ||
out << " using_scope=" << (*it)->identifier << '\n'; | ||
out << " using_scope=" << s->identifier << '\n'; | ||
} | ||
|
||
for(unsigned i=0; i<indent; i++) out << ' '; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,9 @@ Author: Daniel Kroening, [email protected] | |
|
||
bool cpp_typecheck_fargst::has_class_type() const | ||
{ | ||
for(exprt::operandst::const_iterator it=operands.begin(); | ||
it!=operands.end(); | ||
it++) | ||
for(const auto &op : operands) | ||
{ | ||
if(it->type().id()==ID_struct) | ||
if(op.type().id() == ID_struct) | ||
return true; | ||
} | ||
|
||
|
@@ -40,8 +38,8 @@ void cpp_typecheck_fargst::build( | |
operands.clear(); | ||
operands.reserve(function_call.op1().operands().size()); | ||
|
||
for(std::size_t i=0; i<function_call.op1().operands().size(); i++) | ||
operands.push_back(function_call.op1().operands()[i]); | ||
for(const auto &op : function_call.op1().operands()) | ||
operands.push_back(op); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrite this (and some lines above) as |
||
} | ||
|
||
bool cpp_typecheck_fargst::match( | ||
|
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.
I think we can get rid of this loop entirely if using a 3-argument constructor for
function_call
above.