Skip to content

Dirty locals analysis: consume goto_programt instead of goto_functiont #7244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/analyses/constant_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ class constant_propagator_ait:public ait<constant_propagator_domaint>

explicit constant_propagator_ait(
const goto_functiont &goto_function,
should_track_valuet should_track_value = track_all_values):
dirty(goto_function),
should_track_value(should_track_value)
should_track_valuet should_track_value = track_all_values)
: dirty(goto_function.body), should_track_value(should_track_value)
{
}

Expand All @@ -210,7 +209,7 @@ class constant_propagator_ait:public ait<constant_propagator_domaint>
goto_functionst::goto_functiont &goto_function,
const namespacet &ns,
should_track_valuet should_track_value = track_all_values)
: dirty(goto_function), should_track_value(should_track_value)
: dirty(goto_function.body), should_track_value(should_track_value)
{
operator()(function_identifier, goto_function, ns);
replace(goto_function, ns);
Expand Down
10 changes: 5 additions & 5 deletions src/analyses/dirty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Date: March 2013
#include <util/pointer_expr.h>
#include <util/std_expr.h>

void dirtyt::build(const goto_functiont &goto_function)
void dirtyt::build(const goto_programt &goto_program)
{
for(const auto &i : goto_function.body.instructions)
for(const auto &i : goto_program.instructions)
{
if(i.is_other())
{
Expand Down Expand Up @@ -108,12 +108,12 @@ void dirtyt::output(std::ostream &out) const

/// Analyse the given function with dirtyt if it hasn't been seen before
/// \param id: function id to analyse
/// \param function: function to analyse
/// \param goto_program: body of function to analyse
void incremental_dirtyt::populate_dirty_for_function(
const irep_idt &id,
const goto_functionst::goto_functiont &function)
const goto_programt &goto_program)
{
auto insert_result = dirty_processed_functions.insert(id);
if(insert_result.second)
dirty.add_function(function);
dirty.add_function(goto_program);
}
15 changes: 7 additions & 8 deletions src/analyses/dirty.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class dirtyt

public:
bool initialized;
typedef goto_functionst::goto_functiont goto_functiont;

/// \post dirtyt objects that are created through this constructor are not
/// safe to use. If you copied a dirtyt (for example, by adding an object
Expand All @@ -48,9 +47,9 @@ class dirtyt
{
}

explicit dirtyt(const goto_functiont &goto_function) : initialized(false)
explicit dirtyt(const goto_programt &goto_program) : initialized(false)
{
build(goto_function);
build(goto_program);
initialized = true;
}

Expand Down Expand Up @@ -81,9 +80,9 @@ class dirtyt
return dirty;
}

void add_function(const goto_functiont &goto_function)
void add_function(const goto_programt &goto_program)
{
build(goto_function);
build(goto_program);
initialized = true;
}

Expand All @@ -92,12 +91,12 @@ class dirtyt
// dirtyts should not be initialized twice
PRECONDITION(!initialized);
for(const auto &gf_entry : goto_functions.function_map)
build(gf_entry.second);
build(gf_entry.second.body);
initialized = true;
}

protected:
void build(const goto_functiont &goto_function);
void build(const goto_programt &);

// variables whose address is taken
std::unordered_set<irep_idt> dirty;
Expand All @@ -119,7 +118,7 @@ class incremental_dirtyt
public:
void populate_dirty_for_function(
const irep_idt &id,
const goto_functionst::goto_functiont &function);
const goto_programt &goto_program);

bool operator()(const irep_idt &id) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/local_bitvector_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class local_bitvector_analysist
local_bitvector_analysist(
const goto_functiont &_goto_function,
const namespacet &ns)
: dirty(_goto_function),
: dirty(_goto_function.body),
locals(_goto_function),
cfg(_goto_function.body),
ns(ns)
Expand Down
9 changes: 4 additions & 5 deletions src/analyses/local_may_alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ class local_may_aliast
public:
typedef goto_functionst::goto_functiont goto_functiont;

explicit local_may_aliast(
const goto_functiont &_goto_function):
dirty(_goto_function),
locals(_goto_function),
cfg(_goto_function.body)
explicit local_may_aliast(const goto_functiont &_goto_function)
: dirty(_goto_function.body),
locals(_goto_function),
cfg(_goto_function.body)
{
build(_goto_function);
}
Expand Down
9 changes: 3 additions & 6 deletions src/goto-instrument/contracts/cfg_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class function_cfg_infot : public cfg_infot
{
public:
explicit function_cfg_infot(const goto_functiont &_goto_function)
: is_dirty(_goto_function), locals(_goto_function)
: is_dirty(_goto_function.body), locals(_goto_function)
{
parameters.insert(
_goto_function.parameter_identifiers.begin(),
Expand Down Expand Up @@ -143,7 +143,7 @@ class loop_cfg_infot : public cfg_infot
{
public:
loop_cfg_infot(goto_functiont &_goto_function, const loopt &loop)
: is_dirty(_goto_function)
: is_dirty(_goto_function.body)
{
for(const auto &t : loop)
{
Expand Down Expand Up @@ -205,10 +205,7 @@ class goto_program_cfg_infot : public cfg_infot
goto_program.get_decl_identifiers(locals);

// collect dirty locals
goto_functiont goto_function;
goto_function.body.copy_from(goto_program);

dirtyt is_dirty(goto_function);
dirtyt is_dirty(goto_program);
const auto &dirty_ids = is_dirty.get_dirty_ids();
dirty.insert(dirty_ids.begin(), dirty_ids.end());
}
Expand Down
3 changes: 2 additions & 1 deletion src/goto-symex/symex_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ void goto_symext::symex_function_call_post_clean(
const goto_functionst::goto_functiont &goto_function =
get_goto_function(identifier);

path_storage.dirty.populate_dirty_for_function(identifier, goto_function);
path_storage.dirty.populate_dirty_for_function(
identifier, goto_function.body);

auto emplace_safe_pointers_result =
path_storage.safe_pointers.emplace(identifier, local_safe_pointerst{});
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/symex_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ std::unique_ptr<goto_symext::statet> goto_symext::initialize_entry_point_state(
emplace_safe_pointers_result.first->second(start_function->body);

path_storage.dirty.populate_dirty_for_function(
entry_point_id, *start_function);
entry_point_id, start_function->body);
state->dirty = &path_storage.dirty;

// Only enable loop analysis when complexity is enabled.
Expand Down
4 changes: 2 additions & 2 deletions unit/goto-symex/goto_symex_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ SCENARIO(

// Initialize dirty field of state
incremental_dirtyt dirty;
goto_functiont function;
dirty.populate_dirty_for_function("fun", function);
goto_programt function_body;
dirty.populate_dirty_for_function("fun", function_body);
state.dirty = &dirty;

GIVEN("An L1 lhs and an L2 rhs of type int")
Expand Down
4 changes: 2 additions & 2 deletions unit/goto-symex/symex_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ SCENARIO(

// Initialize dirty field of state
incremental_dirtyt dirty;
goto_functiont function;
dirty.populate_dirty_for_function("fun", function);
goto_programt function_body;
dirty.populate_dirty_for_function("fun", function_body);
state.dirty = &dirty;

// Initialize symbol table with an integer symbol `foo`, and a boolean g
Expand Down