Skip to content

Commit 5e22d89

Browse files
Make index in renamings be of std::size_t type
This avoids some conversions, in particular when assigning from the return value of fresh_l2_name_provider.
1 parent 75028b9 commit 5e22d89

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

src/goto-symex/goto_state.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ std::size_t goto_statet::increase_generation(
3535

3636
if(const auto r_opt = level2.current_names.find(l1_identifier))
3737
{
38-
std::pair<ssa_exprt, unsigned> copy = r_opt->get();
39-
copy.second = narrow<unsigned>(n);
38+
std::pair<ssa_exprt, std::size_t> copy = r_opt->get();
39+
copy.second = n;
4040
level2.current_names.replace(l1_identifier, std::move(copy));
4141
}
4242
else

src/goto-symex/renamed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class renamedt : private underlyingt
5050
};
5151

5252
friend renamedt<ssa_exprt, L0>
53-
symex_level0(ssa_exprt, const namespacet &, unsigned);
53+
symex_level0(ssa_exprt, const namespacet &, std::size_t);
5454
friend struct symex_level1t;
5555
friend struct symex_level2t;
5656
friend class goto_symex_statet;

src/goto-symex/renaming_level.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void get_variables(
3131
}
3232

3333
renamedt<ssa_exprt, L0>
34-
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, unsigned thread_nr)
34+
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, std::size_t thread_nr)
3535
{
3636
// already renamed?
3737
if(!ssa_expr.get_level_0().empty())
@@ -56,21 +56,21 @@ symex_level0(ssa_exprt ssa_expr, const namespacet &ns, unsigned thread_nr)
5656
return renamedt<ssa_exprt, L0>{ssa_expr};
5757
}
5858

59-
void symex_level1t::insert(const renamedt<ssa_exprt, L0> &ssa, unsigned index)
59+
void symex_level1t::insert(const renamedt<ssa_exprt, L0> &ssa, std::size_t index)
6060
{
6161
current_names.insert(
6262
ssa.get().get_identifier(), std::make_pair(ssa.get(), index));
6363
}
6464

65-
optionalt<std::pair<ssa_exprt, unsigned>> symex_level1t::insert_or_replace(
65+
optionalt<std::pair<ssa_exprt, std::size_t>> symex_level1t::insert_or_replace(
6666
const renamedt<ssa_exprt, L0> &ssa,
67-
unsigned index)
67+
std::size_t index)
6868
{
6969
const irep_idt &identifier = ssa.get().get_identifier();
7070
const auto old_value = current_names.find(identifier);
7171
if(old_value)
7272
{
73-
std::pair<ssa_exprt, unsigned> result = *old_value;
73+
std::pair<ssa_exprt, std::size_t> result = *old_value;
7474
current_names.replace(identifier, std::make_pair(ssa.get(), index));
7575
return result;
7676
}

src/goto-symex/renaming_level.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Author: Romain Brenguier, [email protected]
2929
/// This is extended by the different symex_level structures which are used
3030
/// during symex to ensure static single assignment (SSA) form.
3131
using symex_renaming_levelt =
32-
sharing_mapt<irep_idt, std::pair<ssa_exprt, unsigned>>;
32+
sharing_mapt<irep_idt, std::pair<ssa_exprt, std::size_t>>;
3333

3434
/// Add the \c ssa_exprt of current_names to vars
3535
DEPRECATED(SINCE(2019, 6, 5, "Unused"))
@@ -44,21 +44,21 @@ void get_variables(
4444
/// a guard, a shared variable or a function. \p ns is queried to decide
4545
/// whether we are in one of these cases.
4646
renamedt<ssa_exprt, L0>
47-
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, unsigned thread_nr);
47+
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, std::size_t thread_nr);
4848

4949
/// Functor to set the level 1 renaming of SSA expressions.
5050
/// Level 1 corresponds to function frames.
5151
/// This is to preserve locality in case of recursion
5252
struct symex_level1t
5353
{
5454
/// Assume \p ssa is not already known
55-
void insert(const renamedt<ssa_exprt, L0> &ssa, unsigned index);
55+
void insert(const renamedt<ssa_exprt, L0> &ssa, std::size_t index);
5656

5757
/// Set the index for \p ssa to index.
5858
/// \return if an index for \p ssa was already know, returns it's previous
5959
/// value.
60-
optionalt<std::pair<ssa_exprt, unsigned>>
61-
insert_or_replace(const renamedt<ssa_exprt, L0> &ssa, unsigned index);
60+
optionalt<std::pair<ssa_exprt, std::size_t>>
61+
insert_or_replace(const renamedt<ssa_exprt, L0> &ssa, std::size_t index);
6262

6363
/// \return true if \p ssa has an associated index
6464
bool has(const renamedt<ssa_exprt, L0> &ssa) const;

src/util/ssa_expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,19 @@ const irep_idt ssa_exprt::get_l1_object_identifier() const
178178
#endif
179179
}
180180

181-
void ssa_exprt::set_level_0(unsigned i)
181+
void ssa_exprt::set_level_0(std::size_t i)
182182
{
183183
set(ID_L0, i);
184184
::update_identifier(*this);
185185
}
186186

187-
void ssa_exprt::set_level_1(unsigned i)
187+
void ssa_exprt::set_level_1(std::size_t i)
188188
{
189189
set(ID_L1, i);
190190
::update_identifier(*this);
191191
}
192192

193-
void ssa_exprt::set_level_2(unsigned i)
193+
void ssa_exprt::set_level_2(std::size_t i)
194194
{
195195
set(ID_L2, i);
196196
::update_identifier(*this);

src/util/ssa_expr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ class ssa_exprt:public symbol_exprt
5252
return o.get_identifier();
5353
}
5454

55-
void set_level_0(unsigned i);
55+
void set_level_0(std::size_t i);
5656

57-
void set_level_1(unsigned i);
57+
void set_level_1(std::size_t i);
5858

59-
void set_level_2(unsigned i);
59+
void set_level_2(std::size_t i);
6060

6161
void remove_level_2();
6262

0 commit comments

Comments
 (0)