Skip to content

Commit 2c11501

Browse files
authored
Merge pull request #5785 from tautschnig/forall-irep
Remove {f,F}orall_irep
2 parents de755e7 + 3db58c9 commit 2c11501

24 files changed

+103
-104
lines changed

.clang-format

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ ForEachMacros: [
3838
'Forall_operands',
3939
'forall_expr',
4040
'Forall_expr',
41-
'forall_irep',
42-
'Forall_irep',
4341
'forall_symbol_base_map',
4442
'forall_subtypes',
4543
'Forall_subtypes']

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,26 +433,30 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
433433
expr.add(ID_generic_associations).get_sub();
434434

435435
// first typecheck all types
436-
Forall_irep(it, generic_associations)
437-
if(it->get(ID_type_arg)!=ID_default)
436+
for(auto &irep : generic_associations)
437+
{
438+
if(irep.get(ID_type_arg) != ID_default)
438439
{
439-
typet &type=static_cast<typet &>(it->add(ID_type_arg));
440+
typet &type = static_cast<typet &>(irep.add(ID_type_arg));
440441
typecheck_type(type);
441442
}
443+
}
442444

443445
// first try non-default match
444446
exprt default_match=nil_exprt();
445447
exprt assoc_match=nil_exprt();
446448

447449
const typet &op_type = follow(op.type());
448450

449-
forall_irep(it, generic_associations)
451+
for(const auto &irep : generic_associations)
450452
{
451-
if(it->get(ID_type_arg)==ID_default)
452-
default_match=static_cast<const exprt &>(it->find(ID_value));
453-
else if(op_type==
454-
follow(static_cast<const typet &>(it->find(ID_type_arg))))
455-
assoc_match=static_cast<const exprt &>(it->find(ID_value));
453+
if(irep.get(ID_type_arg) == ID_default)
454+
default_match = static_cast<const exprt &>(irep.find(ID_value));
455+
else if(
456+
op_type == follow(static_cast<const typet &>(irep.find(ID_type_arg))))
457+
{
458+
assoc_match = static_cast<const exprt &>(irep.find(ID_value));
459+
}
456460
}
457461

458462
if(assoc_match.is_nil())

src/ansi-c/parser_static.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ static void adjust_KnR_parameters(
410410

411411
// we just do a linear search over the parameters
412412
// this could be improved with a hash map
413-
Forall_irep(a_it, parameters.get_sub())
413+
for(auto &parameter : parameters.get_sub())
414414
{
415415
ansi_c_declarationt &p_decl=
416-
to_ansi_c_declaration(static_cast<exprt &>(*a_it));
416+
to_ansi_c_declaration(static_cast<exprt &>(parameter));
417417

418418
if(p_decl.declarator().get_base_name()==base_name)
419419
{

src/cpp/cpp_convert_type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ void cpp_convert_typet::read_template(const typet &type)
129129

130130
irept &arguments=t.add(ID_arguments);
131131

132-
Forall_irep(it, arguments.get_sub())
132+
for(auto &argument : arguments.get_sub())
133133
{
134-
exprt &decl=static_cast<exprt &>(*it);
134+
exprt &decl = static_cast<exprt &>(argument);
135135

136136
// may be type or expression
137137
bool is_type=decl.get_bool(ID_is_type);

src/cpp/cpp_declarator_converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ irep_idt cpp_declarator_convertert::get_pretty_name()
572572

573573
std::string result=scope->prefix+id2string(base_name)+"(";
574574

575-
forall_irep(it, parameters)
575+
for(auto it = parameters.begin(); it != parameters.end(); ++it)
576576
{
577-
const typet &parameter_type=((exprt &)*it).type();
577+
const typet &parameter_type = ((exprt &)*it).type();
578578

579579
if(it!=parameters.begin())
580580
result+=", ";

src/cpp/cpp_enum_type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ irep_idt cpp_enum_typet::generate_anon_tag() const
2626

2727
std::string result="#anonE";
2828

29-
forall_irep(it, b)
29+
for(const auto &value : b)
3030
{
3131
result+='#';
32-
result+=id2string(it->get(ID_name));
32+
result += id2string(value.get(ID_name));
3333
}
3434

3535
return result;

src/cpp/cpp_name.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ void cpp_namet::convert(
4444
std::string &identifier,
4545
std::string &base_name) const
4646
{
47-
forall_irep(it, get_sub())
47+
for(const auto &irep : get_sub())
4848
{
49-
const irep_idt id=it->id();
49+
const irep_idt id = irep.id();
5050

5151
std::string name_component;
5252

5353
if(id==ID_name)
54-
name_component=it->get_string(ID_identifier);
54+
name_component = irep.get_string(ID_identifier);
5555
else if(id==ID_template_args)
5656
{
5757
std::stringstream ss;
@@ -60,7 +60,7 @@ void cpp_namet::convert(
6060
throw ss.str();
6161
}
6262
else
63-
name_component=it->id_string();
63+
name_component = irep.id_string();
6464

6565
identifier+=name_component;
6666

@@ -76,14 +76,14 @@ std::string cpp_namet::to_string() const
7676
{
7777
std::string str;
7878

79-
forall_irep(it, get_sub())
79+
for(const auto &irep : get_sub())
8080
{
81-
if(it->id()=="::")
82-
str += it->id_string();
83-
else if(it->id()==ID_template_args)
81+
if(irep.id() == "::")
82+
str += irep.id_string();
83+
else if(irep.id() == ID_template_args)
8484
str += "<...>";
8585
else
86-
str+=it->get_string(ID_identifier);
86+
str += irep.get_string(ID_identifier);
8787
}
8888

8989
return str;

src/cpp/cpp_name.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ class cpp_namet:public irept
108108

109109
bool is_qualified() const
110110
{
111-
forall_irep(it, get_sub())
112-
if(it->id()=="::")
111+
for(const auto &irep : get_sub())
112+
{
113+
if(irep.id() == "::")
113114
return true;
115+
}
114116
return false;
115117
}
116118

@@ -121,9 +123,11 @@ class cpp_namet:public irept
121123

122124
bool has_template_args() const
123125
{
124-
forall_irep(it, get_sub())
125-
if(it->id()==ID_template_args)
126+
for(const auto &irep : get_sub())
127+
{
128+
if(irep.id() == ID_template_args)
126129
return true;
130+
}
127131

128132
return false;
129133
}

src/cpp/cpp_type2name.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ static std::string irep2name(const irept &irep)
8484
}
8585
}
8686

87-
forall_irep(it, irep.get_sub())
87+
for(const auto &sub : irep.get_sub())
8888
{
8989
if(first)
9090
first=false;
9191
else
9292
result+=',';
93-
result += irep2name(*it);
93+
result += irep2name(sub);
9494
}
9595

9696
result+=')';

src/cpp/cpp_typecheck_bases.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
2222

2323
irept::subt &bases_irep=type.add(ID_bases).get_sub();
2424

25-
Forall_irep(base_it, bases_irep)
25+
for(auto &base : bases_irep)
2626
{
27-
const cpp_namet &name=
28-
to_cpp_name(base_it->find(ID_name));
27+
const cpp_namet &name = to_cpp_name(base.find(ID_name));
2928

3029
exprt base_symbol_expr=
3130
resolve(
@@ -68,8 +67,8 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
6867
throw 0;
6968
}
7069

71-
bool virtual_base = base_it->get_bool(ID_virtual);
72-
irep_idt class_access = base_it->get(ID_protection);
70+
bool virtual_base = base.get_bool(ID_virtual);
71+
irep_idt class_access = base.get(ID_protection);
7372

7473
if(class_access.empty())
7574
class_access = default_class_access;
@@ -80,7 +79,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
8079
if(virtual_base)
8180
base_symbol_expr.set(ID_virtual, true);
8281

83-
base_it->swap(base_symbol_expr);
82+
base.swap(base_symbol_expr);
8483

8584
// Add base scopes as parents to the current scope
8685
cpp_scopes.current_scope().add_secondary_scope(

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,10 @@ void cpp_typecheckt::move_member_initializers(
12571257
value = code_blockt{{to_code(value)}};
12581258

12591259
exprt::operandst::iterator o_it=value.operands().begin();
1260-
forall_irep(it, initializers.get_sub())
1260+
for(const auto &initializer : initializers.get_sub())
12611261
{
1262-
o_it=value.operands().insert(o_it, static_cast<const exprt &>(*it));
1262+
o_it =
1263+
value.operands().insert(o_it, static_cast<const exprt &>(initializer));
12631264
o_it++;
12641265
}
12651266
}
@@ -1620,10 +1621,8 @@ bool cpp_typecheckt::check_component_access(
16201621
// check friendship
16211622
const irept::subt &friends = struct_union_type.find(ID_C_friends).get_sub();
16221623

1623-
forall_irep(f_it, friends)
1624+
for(const auto &friend_symb : friends)
16241625
{
1625-
const irept &friend_symb=*f_it;
1626-
16271626
const cpp_scopet &friend_scope =
16281627
cpp_scopes.get_scope(friend_symb.get(ID_identifier));
16291628

src/cpp/cpp_typecheck_constructor.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,8 @@ void cpp_typecheckt::check_member_initializers(
423423
{
424424
assert(initializers.id()==ID_member_initializers);
425425

426-
forall_irep(init_it, initializers.get_sub())
426+
for(const auto &initializer : initializers.get_sub())
427427
{
428-
const irept &initializer=*init_it;
429428
assert(initializer.is_not_nil());
430429

431430
const cpp_namet &member_name=
@@ -601,10 +600,8 @@ void cpp_typecheckt::full_member_initialization(
601600
// explicitly calls the parent constructor.
602601
bool found=false;
603602

604-
forall_irep(m_it, initializers.get_sub())
603+
for(irept initializer : initializers.get_sub())
605604
{
606-
irept initializer=*m_it;
607-
608605
const cpp_namet &member_name=
609606
to_cpp_name(initializer.find(ID_member));
610607

@@ -715,10 +712,8 @@ void cpp_typecheckt::full_member_initialization(
715712
// Check if the initialization list of the constructor
716713
// explicitly initializes the data member
717714
bool found=false;
718-
Forall_irep(m_it, initializers.get_sub())
715+
for(auto &initializer : initializers.get_sub())
719716
{
720-
irept &initializer=*m_it;
721-
722717
if(initializer.get(ID_member)!=ID_cpp_name)
723718
continue;
724719
cpp_namet &member_name=(cpp_namet&) initializer.add(ID_member);

src/cpp/cpp_typecheck_enum_type.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
3030

3131
mp_integer i=0;
3232

33-
Forall_irep(it, components)
33+
for(auto &component : components)
3434
{
35-
const irep_idt &name=it->get(ID_name);
35+
const irep_idt &name = component.get(ID_name);
3636

37-
if(it->find(ID_value).is_not_nil())
37+
if(component.find(ID_value).is_not_nil())
3838
{
39-
exprt &value=static_cast<exprt &>(it->add(ID_value));
39+
exprt &value = static_cast<exprt &>(component.add(ID_value));
4040
typecheck_expr(value);
4141
implicit_typecast(value, c_enum_type.subtype());
4242
make_constant(value);
@@ -56,8 +56,8 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
5656
symbol.name=id2string(enum_symbol.name)+"::"+id2string(name);
5757
symbol.base_name=name;
5858
symbol.value=value_expr;
59-
symbol.location=
60-
static_cast<const source_locationt &>(it->find(ID_C_source_location));
59+
symbol.location = static_cast<const source_locationt &>(
60+
component.find(ID_C_source_location));
6161
symbol.mode = enum_symbol.mode;
6262
symbol.module=module;
6363
symbol.type=enum_tag_type;

src/cpp/expr2cpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ std::string expr2cppt::convert_rec(
232232

233233
const irept::subt &arguments=src.find(ID_arguments).get_sub();
234234

235-
forall_irep(it, arguments)
235+
for(auto it = arguments.begin(); it != arguments.end(); ++it)
236236
{
237237
if(it!=arguments.begin())
238238
dest+=", ";

src/cpp/parse.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,14 @@ bool Parser::rOtherDeclaration(
17561756
assert(!type_name.get_sub().empty());
17571757

17581758
bool is_destructor=false;
1759-
forall_irep(it, type_name.get_sub())
1760-
if(it->id()=="~")
1759+
for(const auto &irep : type_name.get_sub())
1760+
{
1761+
if(irep.id() == "~")
17611762
{
17621763
is_destructor=true;
17631764
break;
17641765
}
1766+
}
17651767

17661768
cpp_declaratort constructor_declarator;
17671769
typet trailing_return_type;

src/cpp/template_map.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void template_mapt::apply(typet &type) const
5454

5555
irept::subt &parameters=type.add(ID_parameters).get_sub();
5656

57-
Forall_irep(it, parameters)
57+
for(auto &parameter : parameters)
5858
{
59-
if(it->id()==ID_parameter)
60-
apply(static_cast<typet &>(it->add(ID_type)));
59+
if(parameter.id() == ID_parameter)
60+
apply(static_cast<typet &>(parameter.add(ID_type)));
6161
}
6262
}
6363
else if(type.id()==ID_merged_type)

src/goto-instrument/dump_c.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,26 +436,27 @@ void dump_ct::convert_compound(
436436

437437
const irept &bases = type.find(ID_bases);
438438
std::stringstream base_decls;
439-
forall_irep(parent_it, bases.get_sub())
439+
for(const auto &parent : bases.get_sub())
440440
{
441441
UNREACHABLE;
442-
/*
443-
assert(parent_it->id() == ID_base);
444-
assert(parent_it->get(ID_type) == ID_struct_tag);
442+
(void)parent;
443+
#if 0
444+
assert(parent.id() == ID_base);
445+
assert(parent.get(ID_type) == ID_struct_tag);
445446

446447
const irep_idt &base_id=
447-
parent_it->find(ID_type).get(ID_identifier);
448+
parent.find(ID_type).get(ID_identifier);
448449
const irep_idt &renamed_base_id=global_renaming[base_id];
449450
const symbolt &parsymb=ns.lookup(renamed_base_id);
450451

451452
convert_compound_rec(parsymb.type, os);
452453

453454
base_decls << id2string(renamed_base_id) +
454455
(parent_it+1==bases.get_sub().end()?"":", ");
455-
*/
456+
#endif
456457
}
457458

458-
/*
459+
#if 0
459460
// for the constructor
460461
string constructor_args;
461462
string constructor_body;
@@ -471,7 +472,7 @@ void dump_ct::convert_compound(
471472
constructor_args += "const " + type_to_string(compo.type()) + "& " + component_name;
472473

473474
constructor_body += indent + indent + "this->"+component_name + " = " + component_name + ";\n";
474-
*/
475+
#endif
475476

476477
std::stringstream struct_body;
477478

0 commit comments

Comments
 (0)