Skip to content

Commit 256eeda

Browse files
authored
Merge pull request #4017 from tautschnig/single-guard
Store goto_symex::\guard in a single place [blocks: #3619]
2 parents bfe355c + 58bd9ed commit 256eeda

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

src/goto-symex/auto_objects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void goto_symext::trigger_auto_object(
8787
const ssa_exprt &ssa_expr=to_ssa_expr(expr);
8888
const irep_idt &obj_identifier=ssa_expr.get_object_name();
8989

90-
if(obj_identifier!="goto_symex::\\guard")
90+
if(obj_identifier != statet::guard_identifier())
9191
{
9292
const symbolt &symbol=
9393
ns.lookup(obj_identifier);

src/goto-symex/goto_symex.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class goto_symext
8484
target(_target),
8585
atomic_section_counter(0),
8686
log(mh),
87-
guard_identifier("goto_symex::\\guard"),
8887
path_storage(path_storage),
8988
path_segment_vccs(0),
9089
_total_vccs(std::numeric_limits<unsigned>::max()),
@@ -238,10 +237,6 @@ class goto_symext
238237
guardt &,
239238
bool keep_array);
240239

241-
// guards
242-
243-
const irep_idt guard_identifier;
244-
245240
virtual void symex_goto(statet &);
246241
virtual void symex_start_thread(statet &);
247242
virtual void symex_atomic_begin(statet &);

src/goto-symex/goto_symex_state.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void goto_symex_statet::assignment(
180180

181181
#if 0
182182
PRECONDITION(l1_identifier != get_original_name(l1_identifier)
183-
|| l1_identifier=="goto_symex::\\guard"
183+
|| l1_identifier == guard_identifier()
184184
|| ns.lookup(l1_identifier).is_shared()
185185
|| has_prefix(id2string(l1_identifier), "symex::invalid_object")
186186
|| has_prefix(id2string(l1_identifier), "symex_dynamic::dynamic_object"));
@@ -372,9 +372,11 @@ bool goto_symex_statet::l2_thread_read_encoding(
372372
// is it a shared object?
373373
const irep_idt &obj_identifier=expr.get_object_name();
374374
if(
375-
obj_identifier == "goto_symex::\\guard" ||
375+
obj_identifier == guard_identifier() ||
376376
(!ns.lookup(obj_identifier).is_shared() && !(dirty)(obj_identifier)))
377+
{
377378
return false;
379+
}
378380

379381
ssa_exprt ssa_l1=expr;
380382
ssa_l1.remove_level_2();
@@ -508,9 +510,11 @@ bool goto_symex_statet::l2_thread_write_encoding(
508510
// is it a shared object?
509511
const irep_idt &obj_identifier=expr.get_object_name();
510512
if(
511-
obj_identifier == "goto_symex::\\guard" ||
513+
obj_identifier == guard_identifier() ||
512514
(!ns.lookup(obj_identifier).is_shared() && !(dirty)(obj_identifier)))
515+
{
513516
return false; // not shared
517+
}
514518

515519
// see whether we are within an atomic section
516520
if(atomic_section_id!=0)

src/goto-symex/goto_symex_state.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ class goto_symex_statet final
220220
typedef std::map<goto_programt::const_targett, goto_state_listt>
221221
goto_state_mapt;
222222

223+
// guards
224+
static irep_idt guard_identifier()
225+
{
226+
static irep_idt id = "goto_symex::\\guard";
227+
return id;
228+
}
229+
223230
// stack frames -- these are used for function calls and
224231
// for exceptions
225232
struct framet

src/goto-symex/renaming_level.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Author: Romain Brenguier, [email protected]
1515
#include <util/ssa_expr.h>
1616
#include <util/symbol.h>
1717

18+
#include "goto_symex_state.h"
19+
1820
void symex_level0t::
1921
operator()(ssa_exprt &ssa_expr, const namespacet &ns, unsigned thread_nr)
2022
{
@@ -25,7 +27,7 @@ operator()(ssa_exprt &ssa_expr, const namespacet &ns, unsigned thread_nr)
2527
const irep_idt &obj_identifier = ssa_expr.get_object_name();
2628

2729
// guards are not L0-renamed
28-
if(obj_identifier == "goto_symex::\\guard")
30+
if(obj_identifier == goto_symex_statet::guard_identifier())
2931
return;
3032

3133
const symbolt *s;

src/goto-symex/symex_goto.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ void goto_symext::symex_goto(statet &state)
243243
}
244244
else
245245
{
246-
symbol_exprt guard_symbol_expr=
247-
symbol_exprt(guard_identifier, bool_typet());
246+
symbol_exprt guard_symbol_expr =
247+
symbol_exprt(statet::guard_identifier(), bool_typet());
248248
exprt new_rhs = boolean_negate(new_guard);
249249

250250
ssa_exprt new_lhs(guard_symbol_expr);
@@ -394,7 +394,6 @@ static void for_each2(
394394
/// \param [in, out] dest_state: second state
395395
/// \param ns: namespace
396396
/// \param diff_guard: difference between the guards of the two states
397-
/// \param guard_identifier: prefix used for goto symex guards
398397
/// \param [out] log: logger for debug messages
399398
/// \param do_simplify: should the right-hand-side of the assignment that is
400399
/// added to the target be simplified
@@ -408,7 +407,6 @@ static void merge_names(
408407
goto_symext::statet &dest_state,
409408
const namespacet &ns,
410409
const guardt &diff_guard,
411-
const irep_idt &guard_identifier,
412410
messaget &log,
413411
const bool do_simplify,
414412
symex_target_equationt &target,
@@ -419,7 +417,7 @@ static void merge_names(
419417
const irep_idt l1_identifier = ssa.get_identifier();
420418
const irep_idt &obj_identifier = ssa.get_object_name();
421419

422-
if(obj_identifier == guard_identifier)
420+
if(obj_identifier == goto_symext::statet::guard_identifier())
423421
return; // just a guard, don't bother
424422

425423
if(goto_count == dest_count)
@@ -544,7 +542,6 @@ void goto_symext::phi_function(
544542
dest_state,
545543
ns,
546544
diff_guard,
547-
guard_identifier,
548545
log,
549546
symex_config.simplify_opt,
550547
target,

0 commit comments

Comments
 (0)