Skip to content

Commit 2c9196d

Browse files
committed
Store "is hidden" attribute of goto functions in the symbol table
There should only be a single place to hold type information, including attributes, to ensure consistency. Future changes will remove the "type" member of goto_functiont, making the type information stored in the symbol table the single, authoritative source of information. With this commit the information will remain available in both places, but all read accesses only use the information in the symbol table.
1 parent f82244a commit 2c9196d

File tree

8 files changed

+32
-5
lines changed

8 files changed

+32
-5
lines changed

src/goto-instrument/cover_filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool internal_functions_filtert::operator()(
2929
if(function.name == INITIALIZE_FUNCTION)
3030
return false;
3131

32-
if(goto_function.is_hidden())
32+
if(function.is_hidden())
3333
return false;
3434

3535
// ignore Java built-ins (synthetic functions)

src/goto-programs/goto_convert_functions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ void goto_convert_functionst::convert_function(
215215
f.body.update();
216216

217217
if(hide(f.body))
218+
{
218219
f.make_hidden();
220+
symbol_table.get_writeable_ref(identifier).set_hidden();
221+
}
219222

220223
lifetime = parent_lifetime;
221224
}

src/goto-programs/goto_inline_class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void goto_inlinet::insert_function_body(
253253
end.type=LOCATION;
254254

255255
// make sure the inlined function does not introduce hiding
256-
if(goto_function.is_hidden())
256+
if(ns.lookup(identifier).is_hidden())
257257
{
258258
for(auto &instruction : body.instructions)
259259
instruction.labels.remove(CPROVER_PREFIX "HIDE");

src/goto-programs/read_bin_goto_object.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ static bool read_bin_goto_object(
160160
f.body.update();
161161

162162
if(hidden)
163+
{
163164
f.make_hidden();
165+
// can be removed with the next goto-binary version update as the
166+
// information is guaranteed to be stored in the symbol table
167+
#if GOTO_BINARY_VERSION > 5
168+
#error This code should be removed
169+
#endif
170+
symbol_table.get_writeable_ref(fname).set_hidden();
171+
}
164172
}
165173

166174
functions.compute_location_numbers();

src/goto-symex/symex_function_call.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,9 @@ void goto_symext::symex_function_call_code(
274274
a = state.rename(std::move(a), ns);
275275

276276
// we hide the call if the caller and callee are both hidden
277+
const bool callee_is_hidden = ns.lookup(identifier).is_hidden();
277278
const bool hidden =
278-
state.call_stack().top().hidden_function && goto_function.is_hidden();
279+
state.call_stack().top().hidden_function && callee_is_hidden;
279280

280281
// record the call
281282
target.function_call(
@@ -314,7 +315,7 @@ void goto_symext::symex_function_call_code(
314315
frame.end_of_function=--goto_function.body.instructions.end();
315316
frame.return_value=call.lhs();
316317
frame.function_identifier=identifier;
317-
frame.hidden_function=goto_function.is_hidden();
318+
frame.hidden_function = callee_is_hidden;
318319

319320
const framet &p_frame = state.call_stack().previous_frame();
320321
for(const auto &pair : p_frame.loop_iterations)

src/goto-symex/symex_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
326326
state->call_stack().top().end_of_function = limit;
327327
state->call_stack().top().calling_location.pc =
328328
state->call_stack().top().end_of_function;
329-
state->call_stack().top().hidden_function = start_function->is_hidden();
329+
state->call_stack().top().hidden_function =
330+
ns.lookup(entry_point_id).is_hidden();
330331

331332
state->symex_target = &target;
332333

src/util/symbol.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ class symbolt
117117
value = exprt(ID_compiled);
118118
}
119119

120+
/// Returns true iff the symbol is marked for internal use.
121+
bool is_hidden() const
122+
{
123+
return is_auxiliary;
124+
}
125+
126+
/// Mark a symbol for internal use. This is advisory and may be utilized,
127+
/// e.g., to filter output.
128+
void set_hidden()
129+
{
130+
is_auxiliary = true;
131+
}
132+
120133
/// Check that a symbol is well formed.
121134
bool is_well_formed() const;
122135

unit/goto-instrument/cover/cover_only.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ symbolt create_new_symbol(const irep_idt &name, const irep_idt &file_name)
2222
source_locationt location;
2323
location.set_file(file_name);
2424
symbol.location = location;
25+
symbol.type = code_typet{{}, empty_typet{}};
2526

2627
return symbol;
2728
}

0 commit comments

Comments
 (0)