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(

0 commit comments

Comments
 (0)