Skip to content

Commit 67d7505

Browse files
committed
Make is_initialization_allowed static and change init conditions.
1 parent 8bf62ad commit 67d7505

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/goto-harness/function_call_harness_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void function_call_harness_generatort::implt::generate_nondet_globals(
281281
for(const auto &symbol_table_entry : *symbol_table)
282282
{
283283
const auto &symbol = symbol_table_entry.second;
284-
if(recursive_initialization->is_initialization_allowed(symbol))
284+
if(recursive_initializationt::is_initialization_allowed(symbol))
285285
{
286286
globals.push_back(symbol.symbol_expr());
287287
}

src/goto-harness/memory_snapshot_harness_generator.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ code_blockt memory_snapshot_harness_generatort::add_assignments_to_globals(
248248
for(const auto &pair : goto_model.symbol_table)
249249
{
250250
const auto &global_symbol = pair.second;
251-
if(
252-
global_symbol.is_static_lifetime && global_symbol.is_lvalue &&
253-
global_symbol.type.id() != ID_code)
251+
if(recursive_initializationt::is_initialization_allowed(global_symbol))
254252
{
255253
auto symeexr = global_symbol.symbol_expr();
256254
if(symeexr.type() == global_symbol.value.type())
@@ -272,7 +270,8 @@ code_blockt memory_snapshot_harness_generatort::add_assignments_to_globals(
272270
? fresh_symbol_copy(snapshot_symbol, symbol_table)
273271
: snapshot_symbol;
274272

275-
if(!fresh_or_snapshot_symbol.is_static_lifetime)
273+
if(!recursive_initializationt::is_initialization_allowed(
274+
fresh_or_snapshot_symbol))
276275
continue;
277276

278277
if(variables_to_havoc.count(fresh_or_snapshot_symbol.base_name) == 0)

src/goto-harness/recursive_initialization.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ class recursive_initializationt
103103
/// \return the symbol expression for the `free` function
104104
symbol_exprt get_free_function();
105105

106-
bool is_initialization_allowed(const symbolt &symbol)
106+
static bool is_initialization_allowed(const symbolt &symbol)
107107
{
108+
auto const symbol_name = id2string(symbol.name);
108109
return (
109110
symbol.is_static_lifetime && symbol.is_lvalue &&
110-
symbol.type.id() != ID_code &&
111-
!has_prefix(id2string(symbol.name), CPROVER_PREFIX));
111+
!symbol.type.get_bool(ID_C_constant) && symbol.type.id() != ID_code &&
112+
!has_prefix(symbol_name, CPROVER_PREFIX) &&
113+
!has_prefix(symbol_name, GOTO_HARNESS_PREFIX));
112114
}
113115

114116
bool needs_freeing(const exprt &expr) const;

0 commit comments

Comments
 (0)