Skip to content

Commit b36a90a

Browse files
authored
Merge pull request diffblue#1851 from tautschnig/remove-expr-listt
Include list where using a std::list and drop forall_expr_list macro
2 parents 07e0d58 + 13b77d8 commit b36a90a

20 files changed

+56
-43
lines changed

src/analyses/uninitialized_domain.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Date: January 2010
1616
#include <util/std_expr.h>
1717
#include <util/std_code.h>
1818

19+
#include <list>
20+
1921
void uninitialized_domaint::transform(
2022
locationt from,
2123
locationt to,
@@ -43,10 +45,12 @@ void uninitialized_domaint::transform(
4345
std::list<exprt> read=expressions_read(*from);
4446
std::list<exprt> written=expressions_written(*from);
4547

46-
forall_expr_list(it, written) assign(*it);
48+
for(const auto &expr : written)
49+
assign(expr);
4750

4851
// we only care about the *first* uninitalized use
49-
forall_expr_list(it, read) assign(*it);
52+
for(const auto &expr : read)
53+
assign(expr);
5054
}
5155
}
5256
}

src/ansi-c/ansi_c_parse_tree.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include "ansi_c_declaration.h"
1414

15+
#include <list>
16+
1517
class ansi_c_parse_treet
1618
{
1719
public:

src/ansi-c/c_typecast.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/namespace.h>
1414
#include <util/expr.h>
1515

16+
#include <list>
17+
1618
// try a type cast from expr.type() to type
1719
//
1820
// false: typecast successful, expr modified

src/ansi-c/printf_formatter.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Author: Daniel Kroening, [email protected]
1515
#include <util/expr.h>
1616
#include <util/namespace.h>
1717

18+
#include <list>
19+
1820
class printf_formattert
1921
{
2022
public:

src/cbmc/bmc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ void bmct::do_conversion()
139139
{
140140
status() << "converting constraints" << eom;
141141

142-
forall_expr_list(it, bmc_constraints)
143-
prop_conv.set_to_true(*it);
142+
for(const auto &constraint : bmc_constraints)
143+
prop_conv.set_to_true(constraint);
144144
}
145145
// hook for cegis to freeze synthesis program vars
146146
freeze_program_variables();

src/cbmc/bmc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class bmct:public safety_checkert
6060
virtual ~bmct() { }
6161

6262
// additional stuff
63-
expr_listt bmc_constraints;
63+
std::list<exprt> bmc_constraints;
6464

6565
void set_ui(ui_message_handlert::uit _ui) { ui=_ui; }
6666

src/cpp/cpp_parse_tree.h

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include "cpp_item.h"
1616

17+
#include <list>
18+
1719
class cpp_parse_treet
1820
{
1921
public:

src/cpp/cpp_token_buffer.h

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include "cpp_token.h"
1616

17+
#include <list>
18+
1719
class cpp_token_buffert
1820
{
1921
public:

src/goto-instrument/accelerate/acceleration_utils.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Matt Lewis
1212
#ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H
1313
#define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H
1414

15+
#include <list>
1516
#include <map>
1617
#include <set>
1718

@@ -30,6 +31,7 @@ Author: Matt Lewis
3031
#include "cone_of_influence.h"
3132

3233
typedef std::unordered_map<exprt, exprt, irep_hash> expr_mapt;
34+
typedef std::list<exprt> expr_listt;
3335

3436
class acceleration_utilst
3537
{

src/goto-instrument/uninitialized.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ void uninitializedt::get_tracking(goto_programt::const_targett i_it)
4747
{
4848
std::list<exprt> objects=objects_read(*i_it);
4949

50-
forall_expr_list(o_it, objects)
50+
for(const auto &object : objects)
5151
{
52-
if(o_it->id()==ID_symbol)
52+
if(object.id() == ID_symbol)
5353
{
54-
const irep_idt &identifier=to_symbol_expr(*o_it).get_identifier();
54+
const irep_idt &identifier = to_symbol_expr(object).get_identifier();
5555
const std::set<irep_idt> &uninitialized=
5656
uninitialized_analysis[i_it].uninitialized;
5757
if(uninitialized.find(identifier)!=uninitialized.end())
5858
tracking.insert(identifier);
5959
}
60-
else if(o_it->id()==ID_dereference)
60+
else if(object.id() == ID_dereference)
6161
{
6262
}
6363
}
@@ -142,11 +142,11 @@ void uninitializedt::add_assertions(goto_programt &goto_program)
142142
uninitialized_analysis[i_it].uninitialized;
143143

144144
// check tracking variables
145-
forall_expr_list(it, read)
145+
for(const auto &object : read)
146146
{
147-
if(it->id()==ID_symbol)
147+
if(object.id() == ID_symbol)
148148
{
149-
const irep_idt &identifier=to_symbol_expr(*it).get_identifier();
149+
const irep_idt &identifier = to_symbol_expr(object).get_identifier();
150150

151151
if(uninitialized.find(identifier)!=uninitialized.end())
152152
{
@@ -169,11 +169,11 @@ void uninitializedt::add_assertions(goto_programt &goto_program)
169169
}
170170

171171
// set tracking variables
172-
forall_expr_list(it, written)
172+
for(const auto &object : written)
173173
{
174-
if(it->id()==ID_symbol)
174+
if(object.id() == ID_symbol)
175175
{
176-
const irep_idt &identifier=to_symbol_expr(*it).get_identifier();
176+
const irep_idt &identifier = to_symbol_expr(object).get_identifier();
177177

178178
if(tracking.find(identifier)!=tracking.end())
179179
{

src/goto-programs/goto_convert.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1898,9 +1898,9 @@ void goto_convertt::generate_conditional_branch(
18981898
std::list<exprt> op;
18991899
collect_operands(guard, guard.id(), op);
19001900

1901-
forall_expr_list(it, op)
1901+
for(const auto &expr : op)
19021902
generate_conditional_branch(
1903-
boolean_negate(*it), target_false, source_location, dest);
1903+
boolean_negate(expr), target_false, source_location, dest);
19041904

19051905
goto_programt::targett t_true=dest.add_instruction();
19061906
t_true->make_goto(target_true);
@@ -1921,9 +1921,8 @@ void goto_convertt::generate_conditional_branch(
19211921
std::list<exprt> op;
19221922
collect_operands(guard, guard.id(), op);
19231923

1924-
forall_expr_list(it, op)
1925-
generate_conditional_branch(
1926-
*it, target_true, source_location, dest);
1924+
for(const auto &expr : op)
1925+
generate_conditional_branch(expr, target_true, source_location, dest);
19271926

19281927
goto_programt::targett t_false=dest.add_instruction();
19291928
t_false->make_goto(target_false);

src/goto-programs/goto_program.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ std::list<exprt> objects_read(
358358

359359
std::list<exprt> dest;
360360

361-
forall_expr_list(it, expressions)
362-
objects_read(*it, dest);
361+
for(const auto &expr : expressions)
362+
objects_read(expr, dest);
363363

364364
return dest;
365365
}
@@ -385,8 +385,8 @@ std::list<exprt> objects_written(
385385

386386
std::list<exprt> dest;
387387

388-
forall_expr_list(it, expressions)
389-
objects_written(*it, dest);
388+
for(const auto &expr : expressions)
389+
objects_written(expr, dest);
390390

391391
return dest;
392392
}

src/goto-programs/goto_program_template.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <cassert>
1616
#include <iosfwd>
17+
#include <list>
1718
#include <set>
1819
#include <limits>
1920
#include <sstream>

src/goto-symex/slice.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ void symex_slicet::get_symbols(const typet &type)
3333

3434
void symex_slicet::slice(
3535
symex_target_equationt &equation,
36-
const expr_listt &exprs)
36+
const std::list<exprt> &exprs)
3737
{
3838
// collect dependencies
39-
forall_expr_list(expr_it, exprs)
40-
get_symbols(*expr_it);
39+
for(const auto &expr : exprs)
40+
get_symbols(expr);
4141

4242
slice(equation);
4343
}
@@ -229,8 +229,9 @@ void collect_open_variables(
229229
/// \param equation: symex trace to be sliced
230230
/// \param expression: list of expressions, targets for slicing
231231
/// \return None. But equation is modified as a side-effect.
232-
void slice(symex_target_equationt &equation,
233-
const expr_listt &expressions)
232+
void slice(
233+
symex_target_equationt &equation,
234+
const std::list<exprt> &expressions)
234235
{
235236
symex_slicet symex_slice;
236237
symex_slice.slice(equation, expressions);

src/goto-symex/slice.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include "symex_target_equation.h"
1616

17+
#include <list>
18+
1719
// slice an equation with respect to the assertions contained therein
1820
void slice(symex_target_equationt &equation);
1921

2022
// this simply slices away anything after the last assertion
2123
void simple_slice(symex_target_equationt &equation);
2224

2325
// Slice the symex trace with respect to a list of given expressions
24-
void slice(symex_target_equationt &equation,
25-
const expr_listt &expressions);
26+
void slice(
27+
symex_target_equationt &equation,
28+
const std::list<exprt> &expressions);
2629

2730
// Collects "open" variables that are used but not assigned
2831

src/goto-symex/symex_slice_class.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class symex_slicet
2020
public:
2121
void slice(symex_target_equationt &equation);
2222

23-
void slice(symex_target_equationt &equation,
24-
const expr_listt &expressions);
23+
void slice(symex_target_equationt &, const std::list<exprt> &);
2524

2625
void collect_open_variables(
2726
const symex_target_equationt &equation,

src/pointer-analysis/add_failed_symbols.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Author: Daniel Kroening, [email protected]
1515
#include <util/namespace.h>
1616
#include <util/std_expr.h>
1717

18+
#include <list>
19+
1820
/// Get the name of the special symbol used to denote an unknown referee pointed
1921
/// to by a given pointer-typed symbol.
2022
/// \param id: base symbol id

src/pointer-analysis/value_set_fi.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H
1414
#define CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H
1515

16+
#include <list>
1617
#include <map>
1718
#include <set>
1819
#include <unordered_set>

src/util/expr.h

-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ Author: Daniel Kroening, [email protected]
3434
for(exprt::operandst::iterator it=(expr).begin(); \
3535
it!=(expr).end(); ++it)
3636

37-
#define forall_expr_list(it, expr) \
38-
for(expr_listt::const_iterator it=(expr).begin(); \
39-
it!=(expr).end(); ++it)
40-
41-
#define Forall_expr_list(it, expr) \
42-
for(expr_listt::iterator it=(expr).begin(); \
43-
it!=(expr).end(); ++it)
44-
4537
class depth_iteratort;
4638
class const_depth_iteratort;
4739
class const_unique_depth_iteratort;
@@ -180,8 +172,6 @@ class exprt:public irept
180172
const_unique_depth_iteratort unique_depth_cend() const;
181173
};
182174

183-
typedef std::list<exprt> expr_listt;
184-
185175
class expr_visitort
186176
{
187177
public:

src/util/std_code.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111
#define CPROVER_UTIL_STD_CODE_H
1212

1313
#include <cassert>
14+
#include <list>
1415

1516
#include "expr.h"
1617
#include "expr_cast.h"

0 commit comments

Comments
 (0)