Skip to content

Commit 7562b09

Browse files
committed
Store goto_symex::\guard in a single place
The static member of a static function will ensure both proper initialisation and making it available to all users.
1 parent 0bf061b commit 7562b09

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
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 != symex_targett::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: 3 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 == symex_targett::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,7 +372,7 @@ 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 == symex_targett::guard_identifier() ||
376376
(!ns.lookup(obj_identifier).is_shared() && !(dirty)(obj_identifier)))
377377
return false;
378378

@@ -508,7 +508,7 @@ bool goto_symex_statet::l2_thread_write_encoding(
508508
// is it a shared object?
509509
const irep_idt &obj_identifier=expr.get_object_name();
510510
if(
511-
obj_identifier == "goto_symex::\\guard" ||
511+
obj_identifier == symex_targett::guard_identifier() ||
512512
(!ns.lookup(obj_identifier).is_shared() && !(dirty)(obj_identifier)))
513513
return false; // not shared
514514

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 "symex_target.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 == symex_targett::guard_identifier())
2931
return;
3032

3133
const symbolt *s;

src/goto-symex/symex_goto.cpp

Lines changed: 3 additions & 3 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(symex_targett::guard_identifier(), bool_typet());
248248
exprt new_rhs = boolean_negate(new_guard);
249249

250250
ssa_exprt new_lhs(guard_symbol_expr);
@@ -544,7 +544,7 @@ void goto_symext::phi_function(
544544
dest_state,
545545
ns,
546546
diff_guard,
547-
guard_identifier,
547+
symex_targett::guard_identifier(),
548548
log,
549549
symex_config.simplify_opt,
550550
target,

src/goto-symex/symex_target.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ class symex_targett
7171
GUARD,
7272
};
7373

74+
// guards
75+
static irep_idt guard_identifier()
76+
{
77+
static irep_idt id = "goto_symex::\\guard";
78+
return id;
79+
}
80+
7481
/// Read from a shared variable \p ssa_object (which is both the left- and the
7582
/// right--hand side of assignment): we effectively assign the value stored in
7683
/// \p ssa_object by another thread to \p ssa_object in the memory scope of

0 commit comments

Comments
 (0)