Skip to content

Commit 95e15fd

Browse files
authored
Merge pull request #4251 from tautschnig/parameter-identifiers-locals
Local bitvector analysis: use parameter_identifiers [blocks: #4167]
2 parents 17623d1 + 4193829 commit 95e15fd

File tree

6 files changed

+30
-31
lines changed

6 files changed

+30
-31
lines changed

src/analyses/goto_check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ void goto_checkt::goto_check(
16751675

16761676
if(enable_pointer_check)
16771677
local_bitvector_analysis =
1678-
util_make_unique<local_bitvector_analysist>(goto_function);
1678+
util_make_unique<local_bitvector_analysist>(goto_function, ns);
16791679

16801680
goto_programt &goto_program=goto_function.body;
16811681

src/analyses/local_bitvector_analysis.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ bool local_bitvector_analysist::merge(points_tot &a, points_tot &b)
6060
/// \return return 'true' iff we track the object with given identifier
6161
bool local_bitvector_analysist::is_tracked(const irep_idt &identifier)
6262
{
63-
localst::locals_mapt::const_iterator it=locals.locals_map.find(identifier);
64-
if(it==locals.locals_map.end() ||
65-
it->second.type().id()!=ID_pointer ||
66-
dirty(identifier))
67-
return false;
68-
69-
return true;
63+
localst::locals_sett::const_iterator it = locals.locals.find(identifier);
64+
return it != locals.locals.end() && ns.lookup(*it).type.id() == ID_pointer &&
65+
!dirty(identifier);
7066
}
7167

7268
void local_bitvector_analysist::assign_lhs(
@@ -254,9 +250,11 @@ void local_bitvector_analysist::build()
254250
// Gather the objects we track, and
255251
// feed in sufficiently bad defaults for their value
256252
// in the entry location.
257-
for(const auto &local : locals.locals_map)
258-
if(is_tracked(local.first))
259-
loc_infos[0][pointers.number(local.first)]=flagst::mk_unknown();
253+
for(const auto &local : locals.locals)
254+
{
255+
if(is_tracked(local))
256+
loc_infos[0][pointers.number(local)] = flagst::mk_unknown();
257+
}
260258

261259
while(!work_queue.empty())
262260
{

src/analyses/local_bitvector_analysis.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ class local_bitvector_analysist
2525
public:
2626
typedef goto_functionst::goto_functiont goto_functiont;
2727

28-
explicit local_bitvector_analysist(
29-
const goto_functiont &_goto_function):
30-
dirty(_goto_function),
31-
locals(_goto_function),
32-
cfg(_goto_function.body)
28+
local_bitvector_analysist(
29+
const goto_functiont &_goto_function,
30+
const namespacet &ns)
31+
: dirty(_goto_function),
32+
locals(_goto_function),
33+
cfg(_goto_function.body),
34+
ns(ns)
3335
{
3436
build();
3537
}
@@ -176,6 +178,7 @@ class local_bitvector_analysist
176178
const exprt &src);
177179

178180
protected:
181+
const namespacet &ns;
179182
void build();
180183

181184
typedef std::stack<unsigned> work_queuet;

src/analyses/locals.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,18 @@ Date: March 2013
1818
void localst::build(const goto_functiont &goto_function)
1919
{
2020
forall_goto_program_instructions(it, goto_function.body)
21+
{
2122
if(it->is_decl())
22-
{
23-
const code_declt &code_decl=to_code_decl(it->code);
24-
locals_map.emplace(code_decl.get_identifier(), code_decl.symbol());
25-
}
26-
27-
for(const auto &param : goto_function.type.parameters())
28-
locals_map.emplace(
29-
param.get_identifier(),
30-
symbol_exprt(param.get_identifier(), param.type()));
23+
locals.insert(it->get_decl().get_identifier());
24+
}
25+
26+
locals.insert(
27+
goto_function.parameter_identifiers.begin(),
28+
goto_function.parameter_identifiers.end());
3129
}
3230

3331
void localst::output(std::ostream &out) const
3432
{
35-
for(const auto &local : locals_map)
36-
out << local.first << "\n";
33+
for(const auto &local : locals)
34+
out << local << "\n";
3735
}

src/analyses/locals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class localst
3131
// but including the function parameters.
3232
bool is_local(const irep_idt &identifier) const
3333
{
34-
return locals_map.find(identifier)!=locals_map.end();
34+
return locals.find(identifier) != locals.end();
3535
}
3636

37-
typedef std::map<irep_idt, symbol_exprt> locals_mapt;
38-
locals_mapt locals_map;
37+
typedef std::unordered_set<irep_idt> locals_sett;
38+
locals_sett locals;
3939

4040
protected:
4141
void build(const goto_functiont &goto_function);

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ int goto_instrument_parse_optionst::doit()
299299

300300
forall_goto_functions(it, goto_model.goto_functions)
301301
{
302-
local_bitvector_analysist local_bitvector_analysis(it->second);
302+
local_bitvector_analysist local_bitvector_analysis(it->second, ns);
303303
std::cout << ">>>>\n";
304304
std::cout << ">>>> " << it->first << '\n';
305305
std::cout << ">>>>\n";

0 commit comments

Comments
 (0)