Skip to content

Commit 69d82ca

Browse files
Remove guardt default constructor
This makes the code clearer when it assumes that the default guard corresponds to true.
1 parent a71d19c commit 69d82ca

14 files changed

+22
-32
lines changed

src/analyses/goto_check.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ void goto_checkt::check_rec(const exprt &expr, guardt &guard, bool address)
16321632

16331633
void goto_checkt::check(const exprt &expr)
16341634
{
1635-
guardt guard;
1635+
guardt guard{true_exprt{}};
16361636
check_rec(expr, guard, false);
16371637
}
16381638

@@ -1762,7 +1762,7 @@ void goto_checkt::goto_check(
17621762
"pointer dereference",
17631763
i.source_location,
17641764
pointer,
1765-
guardt());
1765+
guardt(true_exprt()));
17661766
}
17671767
}
17681768

@@ -1800,7 +1800,7 @@ void goto_checkt::goto_check(
18001800
"pointer dereference",
18011801
i.source_location,
18021802
pointer,
1803-
guardt());
1803+
guardt(true_exprt()));
18041804
}
18051805

18061806
// this has no successor
@@ -1881,7 +1881,7 @@ void goto_checkt::goto_check(
18811881
"memory-leak",
18821882
source_location,
18831883
eq,
1884-
guardt());
1884+
guardt(true_exprt()));
18851885
}
18861886
}
18871887

src/analyses/goto_rw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class rw_guarded_range_set_value_sett:public rw_range_set_value_sett
370370
get_modet mode,
371371
const exprt &expr) override
372372
{
373-
guard = guardt();
373+
guard = guardt(true_exprt());
374374

375375
rw_range_set_value_sett::get_objects_rec(_function, _target, mode, expr);
376376
}
@@ -384,7 +384,7 @@ class rw_guarded_range_set_value_sett:public rw_range_set_value_sett
384384
}
385385

386386
protected:
387-
guardt guard;
387+
guardt guard = guardt(true_exprt());
388388

389389
using rw_range_sett::get_objects_rec;
390390

src/goto-instrument/rw_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void _rw_set_loct::compute()
7979
void _rw_set_loct::assign(const exprt &lhs, const exprt &rhs)
8080
{
8181
read(rhs);
82-
read_write_rec(lhs, false, true, "", guardt());
82+
read_write_rec(lhs, false, true, "", guardt(true_exprt()));
8383
}
8484

8585
void _rw_set_loct::read_write_rec(

src/goto-instrument/rw_set.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class _rw_set_loct:public rw_set_baset
149149

150150
void read(const exprt &expr)
151151
{
152-
read_write_rec(expr, true, false, "", guardt());
152+
read_write_rec(expr, true, false, "", guardt(true_exprt()));
153153
}
154154

155155
void read(const exprt &expr, const guardt &guard)
@@ -159,7 +159,7 @@ class _rw_set_loct:public rw_set_baset
159159

160160
void write(const exprt &expr)
161161
{
162-
read_write_rec(expr, false, true, "", guardt());
162+
read_write_rec(expr, false, true, "", guardt(true_exprt()));
163163
}
164164

165165
void compute();

src/goto-symex/goto_symex_state.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ bool goto_symex_statet::l2_thread_read_encoding(
389389
// see whether we are within an atomic section
390390
if(atomic_section_id!=0)
391391
{
392-
guardt write_guard;
393-
write_guard.add(false_exprt());
392+
guardt write_guard{false_exprt{}};
394393

395394
const auto a_s_writes = written_in_atomic_section.find(ssa_l1);
396395
if(a_s_writes!=written_in_atomic_section.end())
@@ -414,8 +413,7 @@ bool goto_symex_statet::l2_thread_read_encoding(
414413
// we cannot determine for sure that there has been a write already
415414
// so generate a read even if l1_identifier has been written on
416415
// all branches flowing into this read
417-
guardt read_guard;
418-
read_guard.add(false_exprt());
416+
guardt read_guard{false_exprt{}};
419417

420418
a_s_r_entryt &a_s_read=read_in_atomic_section[ssa_l1];
421419
for(const auto &a_s_read_guard : a_s_read.second)
@@ -433,11 +431,7 @@ bool goto_symex_statet::l2_thread_read_encoding(
433431

434432
guardt cond = read_guard;
435433
if(!no_write.op().is_false())
436-
{
437-
guardt no_write_guard;
438-
no_write_guard.add(no_write.op());
439-
cond |= no_write_guard;
440-
}
434+
cond |= guardt{no_write.op()};
441435

442436
if_exprt tmp(cond.as_expr(), ssa_l1, ssa_l1);
443437
set_l2_indices(to_ssa_expr(tmp.true_case()), ns);

src/goto-symex/goto_symex_state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class goto_symex_statet final
5454
/// distance from entry
5555
unsigned depth;
5656

57-
guardt guard;
57+
guardt guard{true_exprt{}};
5858
symex_targett::sourcet source;
5959
symex_target_equationt *symex_target;
6060

@@ -254,7 +254,7 @@ class goto_symex_statet final
254254
struct threadt
255255
{
256256
goto_programt::const_targett pc;
257-
guardt guard;
257+
guardt guard{true_exprt{}};
258258
call_stackt call_stack;
259259
std::map<irep_idt, unsigned> function_frame;
260260
unsigned atomic_section_id = 0;

src/goto-symex/symex_assign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void goto_symext::symex_assign(
8989
if(state.source.pc->source_location.get_hide())
9090
assignment_type=symex_targett::assignment_typet::HIDDEN;
9191

92-
guardt guard; // NOT the state guard!
92+
guardt guard{true_exprt{}}; // NOT the state guard!
9393
symex_assign_rec(state, lhs, nil_exprt(), rhs, guard, assignment_type);
9494
}
9595
}

src/goto-symex/symex_dereference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void goto_symext::dereference(
384384
state.rename(expr, ns, goto_symex_statet::L1);
385385

386386
// start the recursion!
387-
guardt guard;
387+
guardt guard{true_exprt{}};
388388
dereference_rec(expr, state, guard, write);
389389
// dereferencing may introduce new symbol_exprt
390390
// (like __CPROVER_memory)

src/goto-symex/symex_function_call.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void goto_symext::parameter_assignments(
139139
clean_expr(lhs, state, true);
140140
clean_expr(rhs, state, false);
141141

142-
guardt guard;
142+
guardt guard{true_exprt{}};
143143
symex_assign_rec(state, lhs, nil_exprt(), rhs, guard, assignment_type);
144144
}
145145

src/goto-symex/symex_goto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void goto_symext::symex_goto(statet &state)
249249
state.rename(new_lhs, ns, goto_symex_statet::L1);
250250
state.assignment(new_lhs, new_rhs, ns, true, false);
251251

252-
guardt guard;
252+
guardt guard{true_exprt{}};
253253

254254
log.conditional_output(
255255
log.debug(),

src/goto-symex/symex_other.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void goto_symext::symex_other(
275275
dereference_exprt object(code.op0(), empty_typet());
276276
clean_expr(object, state, true);
277277

278-
havoc_rec(state, guardt(), object);
278+
havoc_rec(state, guardt(true_exprt()), object);
279279
}
280280
else
281281
UNREACHABLE;

src/goto-symex/symex_start_thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void goto_symext::symex_start_thread(statet &state)
8181
// make copy
8282
ssa_exprt rhs=c_it->second.first;
8383

84-
guardt guard;
84+
guardt guard{true_exprt{}};
8585
const bool record_events=state.record_events;
8686
state.record_events=false;
8787
symex_assign_symbol(
@@ -120,7 +120,7 @@ void goto_symext::symex_start_thread(statet &state)
120120
rhs = *zero;
121121
}
122122

123-
guardt guard;
123+
guardt guard{true_exprt{}};
124124
symex_assign_symbol(
125125
state,
126126
lhs,

src/pointer-analysis/goto_program_dereference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void goto_program_dereferencet::dereference_expr(
251251
const bool checks_only,
252252
const value_set_dereferencet::modet mode)
253253
{
254-
guardt guard;
254+
guardt guard{true_exprt{}};
255255

256256
if(checks_only)
257257
{

src/util/guard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ Author: Daniel Kroening, [email protected]
1919
class guardt
2020
{
2121
public:
22-
guardt() : expr(true_exprt())
23-
{
24-
}
25-
2622
explicit guardt(const exprt &e) : expr(e)
2723
{
2824
}

0 commit comments

Comments
 (0)