Skip to content

Commit d18a463

Browse files
authored
Merge pull request #5575 from tautschnig/goto_functiont-is_hidden
Move "is hidden" attribute of goto functions out of type
2 parents f00b222 + 4e5bf6e commit d18a463

File tree

10 files changed

+19
-41
lines changed

10 files changed

+19
-41
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(function.is_hidden())
32+
if(goto_function.is_hidden())
3333
return false;
3434

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

src/goto-programs/goto_convert_functions.cpp

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

228228
if(hide(f.body))
229-
{
230229
f.make_hidden();
231-
symbol_table.get_writeable_ref(identifier).set_hidden();
232-
}
233230

234231
lifetime = parent_lifetime;
235232
}

src/goto-programs/goto_function.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,17 @@ class goto_functiont
6060
return type.get_bool(ID_C_inlined);
6161
}
6262

63-
DEPRECATED(SINCE(2019, 2, 16, "Get the type from the symbol table instead"))
6463
bool is_hidden() const
6564
{
66-
return type.get_bool(ID_C_hide);
65+
return function_is_hidden;
6766
}
6867

69-
DEPRECATED(SINCE(2019, 2, 16, "Get the type from the symbol table instead"))
7068
void make_hidden()
7169
{
72-
type.set(ID_C_hide, true);
70+
function_is_hidden = true;
7371
}
7472

75-
goto_functiont() : body(), type({}, empty_typet())
73+
goto_functiont() : body(), type({}, empty_typet()), function_is_hidden(false)
7674
{
7775
}
7876

@@ -81,20 +79,23 @@ class goto_functiont
8179
body.clear();
8280
type.clear();
8381
parameter_identifiers.clear();
82+
function_is_hidden = false;
8483
}
8584

8685
void swap(goto_functiont &other)
8786
{
8887
body.swap(other.body);
8988
type.swap(other.type);
9089
parameter_identifiers.swap(other.parameter_identifiers);
90+
std::swap(function_is_hidden, other.function_is_hidden);
9191
}
9292

9393
void copy_from(const goto_functiont &other)
9494
{
9595
body.copy_from(other.body);
9696
type = other.type;
9797
parameter_identifiers = other.parameter_identifiers;
98+
function_is_hidden = other.function_is_hidden;
9899
}
99100

100101
goto_functiont(const goto_functiont &) = delete;
@@ -103,7 +104,8 @@ class goto_functiont
103104
goto_functiont(goto_functiont &&other)
104105
: body(std::move(other.body)),
105106
type(std::move(other.type)),
106-
parameter_identifiers(std::move(other.parameter_identifiers))
107+
parameter_identifiers(std::move(other.parameter_identifiers)),
108+
function_is_hidden(other.function_is_hidden)
107109
{
108110
}
109111

@@ -112,6 +114,7 @@ class goto_functiont
112114
body = std::move(other.body);
113115
type = std::move(other.type);
114116
parameter_identifiers = std::move(other.parameter_identifiers);
117+
function_is_hidden = other.function_is_hidden;
115118
return *this;
116119
}
117120

@@ -120,6 +123,9 @@ class goto_functiont
120123
/// The validation mode indicates whether well-formedness check failures are
121124
/// reported via DATA_INVARIANT violations or exceptions.
122125
void validate(const namespacet &ns, const validation_modet vm) const;
126+
127+
protected:
128+
bool function_is_hidden;
123129
};
124130

125131
void get_local_identifiers(const goto_functiont &, std::set<irep_idt> &dest);

src/goto-programs/goto_inline_class.cpp

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

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

src/goto-programs/read_bin_goto_object.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ static bool read_bin_goto_object(
131131
instruction.labels.push_back(label);
132132
if(label == CPROVER_PREFIX "HIDE")
133133
hidden=true;
134-
// The above info is normally in the type of the goto_functiont object,
135-
// which should likely be stored in the binary.
134+
// The above info is also held in the goto_functiont object, and could
135+
// be stored in the binary.
136136
}
137137
}
138138

@@ -160,15 +160,7 @@ static bool read_bin_goto_object(
160160
f.body.update();
161161

162162
if(hidden)
163-
{
164163
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-
}
172164
}
173165

174166
functions.compute_location_numbers();

src/goto-symex/symex_function_call.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,8 @@ void goto_symext::symex_function_call_code(
270270
[&](const exprt &a) { return state.rename(a, ns); });
271271

272272
// we hide the call if the caller and callee are both hidden
273-
const bool callee_is_hidden = ns.lookup(identifier).is_hidden();
274273
const bool hidden =
275-
state.call_stack().top().hidden_function && callee_is_hidden;
274+
state.call_stack().top().hidden_function && goto_function.is_hidden();
276275

277276
// record the call
278277
target.function_call(
@@ -338,7 +337,7 @@ void goto_symext::symex_function_call_code(
338337
frame.end_of_function=--goto_function.body.instructions.end();
339338
frame.return_value=call.lhs();
340339
frame.function_identifier=identifier;
341-
frame.hidden_function = callee_is_hidden;
340+
frame.hidden_function = goto_function.is_hidden();
342341

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

src/goto-symex/symex_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
434434
state->call_stack().top().end_of_function = limit;
435435
state->call_stack().top().calling_location.pc =
436436
state->call_stack().top().end_of_function;
437-
state->call_stack().top().hidden_function =
438-
ns.lookup(entry_point_id).is_hidden();
437+
state->call_stack().top().hidden_function = start_function->is_hidden();
439438

440439
state->symex_target = &target;
441440

src/util/irep_ids.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ IREP_ID_ONE(signed_int128)
285285
IREP_ID_ONE(unsigned_int128)
286286
IREP_ID_ONE(case)
287287
IREP_ID_TWO(C_inlined, #inlined)
288-
IREP_ID_TWO(C_hide, #hide)
289288
IREP_ID_ONE(hide)
290289
IREP_ID_ONE(abs)
291290
IREP_ID_ONE(sign)

src/util/symbol.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,6 @@ 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-
133120
/// Check that a symbol is well formed.
134121
bool is_well_formed() const;
135122

unit/goto-instrument/cover/cover_only.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ 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{}};
2625

2726
return symbol;
2827
}

0 commit comments

Comments
 (0)