Skip to content

Commit ac5af68

Browse files
committed
Address-taken locals analysis: support incremental analysis
This adds a constructor and incremental build function so that the set of address-taken locals can be populated one function at a time. This will be useful when goto-symex begins to use incremental loading, meaning it cannot populate the analysis in one operation.
1 parent fe775f3 commit ac5af68

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/analyses/dirty.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,14 @@ void dirtyt::output(std::ostream &out) const
7272
for(const auto &d : dirty)
7373
out << d << '\n';
7474
}
75+
76+
/// Analyse the given function with dirtyt if it hasn't been seen before
77+
/// \param id: function id to analyse
78+
/// \param function: function to analyse
79+
void incremental_dirtyt::populate_dirty_for_function(
80+
const irep_idt &id, const goto_functionst::goto_functiont &function)
81+
{
82+
auto insert_result = dirty_processed_functions.insert(id);
83+
if(insert_result.second)
84+
dirty.add_function(function);
85+
}

src/analyses/dirty.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class dirtyt
2525
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
2626
typedef goto_functionst::goto_functiont goto_functiont;
2727

28+
dirtyt()
29+
{
30+
}
31+
2832
explicit dirtyt(const goto_functiont &goto_function)
2933
{
3034
build(goto_function);
@@ -53,6 +57,11 @@ class dirtyt
5357
return dirty;
5458
}
5559

60+
void add_function(const goto_functiont &goto_function)
61+
{
62+
build(goto_function);
63+
}
64+
5665
protected:
5766
void build(const goto_functiont &goto_function);
5867

@@ -71,4 +80,27 @@ inline std::ostream &operator<<(
7180
return out;
7281
}
7382

83+
/// Wrapper for dirtyt that permits incremental population, ensuring each
84+
/// function is analysed exactly once.
85+
class incremental_dirtyt
86+
{
87+
public:
88+
void populate_dirty_for_function(
89+
const irep_idt &id, const goto_functionst::goto_functiont &function);
90+
91+
bool operator()(const irep_idt &id) const
92+
{
93+
return dirty(id);
94+
}
95+
96+
bool operator()(const symbol_exprt &expr) const
97+
{
98+
return dirty(expr);
99+
}
100+
101+
private:
102+
dirtyt dirty;
103+
std::unordered_set<irep_idt, irep_id_hash> dirty_processed_functions;
104+
};
105+
74106
#endif // CPROVER_ANALYSES_DIRTY_H

0 commit comments

Comments
 (0)