Skip to content

Commit 32ad5d3

Browse files
committed
Un-pointer current_names
1 parent 81320e1 commit 32ad5d3

File tree

5 files changed

+27
-33
lines changed

5 files changed

+27
-33
lines changed

src/goto-symex/auto_objects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void goto_symext::trigger_auto_object(
9595
if(has_prefix(id2string(symbol.base_name), "auto_object"))
9696
{
9797
// done already?
98-
if(state.level2.current_names->find(ssa_expr.get_identifier())==
99-
state.level2.current_names->end())
98+
if(state.level2.current_names.find(ssa_expr.get_identifier())==
99+
state.level2.current_names.end())
100100
{
101101
initialize_auto_object(expr, state);
102102
}

src/goto-symex/renaming_level.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void symex_level1t::operator()(ssa_exprt &ssa_expr) const
5050

5151
const irep_idt l0_name = ssa_expr.get_l1_object_identifier();
5252

53-
const auto it = current_names->find(l0_name);
54-
if(it == current_names->end())
53+
const auto it = current_names.find(l0_name);
54+
if(it == current_names.end())
5555
return;
5656

5757
// rename!
@@ -61,14 +61,14 @@ void symex_level1t::operator()(ssa_exprt &ssa_expr) const
6161
void symex_level1t::restore_from(
6262
const symex_renaming_levelt::current_namest &other)
6363
{
64-
auto it = current_names->begin();
64+
auto it = current_names.begin();
6565
for(const auto &pair : other)
6666
{
67-
while(it != current_names->end() && it->first < pair.first)
67+
while(it != current_names.end() && it->first < pair.first)
6868
++it;
69-
if(it == current_names->end() || pair.first < it->first)
70-
current_names->insert(it, pair);
71-
else if(it != current_names->end())
69+
if(it == current_names.end() || pair.first < it->first)
70+
current_names.insert(it, pair);
71+
else if(it != current_names.end())
7272
{
7373
PRECONDITION(it->first == pair.first);
7474
it->second = pair.second;

src/goto-symex/renaming_level.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ struct symex_renaming_levelt
2929

3030
/// Map identifier to ssa_exprt and counter
3131
typedef std::map<irep_idt, std::pair<ssa_exprt, unsigned>> current_namest;
32-
current_namest *current_names = new current_namest;
32+
current_namest current_names;
3333

3434
/// Counter corresponding to an identifier
35-
virtual unsigned current_count(const irep_idt &identifier) const
35+
unsigned current_count(const irep_idt &identifier) const
3636
{
37-
const auto it = current_names->find(identifier);
38-
return it == current_names->end() ? 0 : it->second.second;
37+
const auto it = current_names.find(identifier);
38+
return it == current_names.end() ? 0 : it->second.second;
3939
}
4040

4141
/// Increase the counter corresponding to an identifier
@@ -47,7 +47,7 @@ struct symex_renaming_levelt
4747
/// Add the \c ssa_exprt of current_names to vars
4848
void get_variables(std::unordered_set<ssa_exprt, irep_hash> &vars) const
4949
{
50-
for(const auto &pair : *current_names)
50+
for(const auto &pair : current_names)
5151
vars.insert(pair.second.first);
5252
}
5353
};
@@ -88,18 +88,12 @@ struct symex_level2t : public symex_renaming_levelt
8888

8989
optionalt<current_namest> global_names;
9090

91-
void erase(const irep_idt &identifier)
92-
{
93-
// We don't want to erase anything from the global scope if it exists.
94-
current_names->erase(identifier);
95-
}
96-
9791
/// Ages the generation of an ssa expression by one.
9892
void increase_generation(
9993
const irep_idt l1_identifier,
10094
const ssa_exprt &lhs)
10195
{
102-
current_names->emplace(l1_identifier, std::make_pair(lhs, 0));
96+
current_names.emplace(l1_identifier, std::make_pair(lhs, 0));
10397
if (global_names)
10498
global_names->emplace(l1_identifier, std::make_pair(lhs, 0));
10599

@@ -113,8 +107,8 @@ struct symex_level2t : public symex_renaming_levelt
113107
{
114108
// If we can't find the name in the local scope, don't increase the global
115109
// even if it exists there.
116-
auto current_names_iter = current_names->find(identifier);
117-
if (current_names_iter == current_names->end())
110+
auto current_names_iter = current_names.find(identifier);
111+
if (current_names_iter == current_names.end())
118112
return;
119113

120114
// If we have a global store, increment its generation count, then assign
@@ -142,7 +136,7 @@ struct symex_level2t : public symex_renaming_levelt
142136

143137
std::cout << "Printing differences between local and global generations." << '\n';
144138

145-
for(const auto &local : *current_names)
139+
for(const auto &local : current_names)
146140
{
147141
auto global_iter = global_names->find(local.first);
148142
if (global_iter == global_names->end())

src/goto-symex/symex_function_call.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ static void pop_frame(goto_symext::statet &state)
346346
state.level1.restore_from(frame.old_level1);
347347

348348
// clear function-locals from L2 renaming
349-
for(auto c_it = state.level2.current_names->begin();
350-
c_it != state.level2.current_names->end();) // no ++c_it
349+
for(auto c_it = state.level2.current_names.begin();
350+
c_it != state.level2.current_names.end();) // no ++c_it
351351
{
352352
const irep_idt l1_o_id=c_it->second.first.get_l1_object_identifier();
353353
// could use iteration over local_objects as l1_o_id is prefix
@@ -361,7 +361,7 @@ static void pop_frame(goto_symext::statet &state)
361361
}
362362
auto cur = c_it;
363363
++c_it;
364-
state.level2.erase(cur->first);
364+
state.level2.current_names.erase(cur);
365365
}
366366
}
367367

@@ -409,17 +409,17 @@ static void locality(
409409
const irep_idt l0_name=ssa.get_identifier();
410410

411411
// save old L1 name for popping the frame
412-
auto c_it = state.level1.current_names->find(l0_name);
412+
auto c_it = state.level1.current_names.find(l0_name);
413413

414-
if(c_it != state.level1.current_names->end())
414+
if(c_it != state.level1.current_names.end())
415415
{
416416
frame.old_level1.emplace(l0_name, c_it->second);
417417
c_it->second = std::make_pair(ssa, frame_nr);
418418
}
419419
else
420420
{
421421
c_it = state.level1.current_names
422-
->emplace(l0_name, std::make_pair(ssa, frame_nr))
422+
.emplace(l0_name, std::make_pair(ssa, frame_nr))
423423
.first;
424424
}
425425

src/goto-symex/symex_start_thread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void goto_symext::symex_start_thread(statet &state)
5252
// create a copy of the local variables for the new thread
5353
framet &frame = state.top();
5454

55-
for(auto c_it = state.level2.current_names->begin();
56-
c_it != state.level2.current_names->end();
55+
for(auto c_it = state.level2.current_names.begin();
56+
c_it != state.level2.current_names.end();
5757
++c_it)
5858
{
5959
const irep_idt l1_o_id=c_it->second.first.get_l1_object_identifier();
@@ -68,7 +68,7 @@ void goto_symext::symex_start_thread(statet &state)
6868
lhs.set_level_0(t);
6969

7070
// set up L1 name
71-
auto emplace_result = state.level1.current_names->emplace(
71+
auto emplace_result = state.level1.current_names.emplace(
7272
std::piecewise_construct,
7373
std::forward_as_tuple(lhs.get_l1_object_identifier()),
7474
std::forward_as_tuple(lhs, 0));

0 commit comments

Comments
 (0)