Skip to content

Commit 7671a1f

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Replace uses of deprecated integer2ulong
Use suitable numeric_cast<...>.
1 parent 009e7ae commit 7671a1f

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/ansi-c/expr2c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ std::string expr2ct::convert_constant(
18311831
else if(int_value>=' ' && int_value<126)
18321832
{
18331833
dest+='\'';
1834-
dest+=static_cast<char>(integer2ulong(int_value));
1834+
dest += numeric_cast_v<char>(int_value);
18351835
dest+='\'';
18361836
}
18371837
else

src/goto-programs/interpreter.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,14 @@ exprt interpretert::get_value(
511511
}
512512
return std::move(result);
513513
}
514-
if(use_non_det &&
515-
memory[integer2ulong(offset)].initialized!=
516-
memory_cellt::initializedt::WRITTEN_BEFORE_READ)
514+
if(
515+
use_non_det && memory[numeric_cast_v<std::size_t>(offset)].initialized !=
516+
memory_cellt::initializedt::WRITTEN_BEFORE_READ)
517+
{
517518
return side_effect_expr_nondett(type, source_locationt());
519+
}
518520
mp_vectort rhs;
519-
rhs.push_back(memory[integer2ulong(offset)].value);
521+
rhs.push_back(memory[numeric_cast_v<std::size_t>(offset)].value);
520522
return get_value(type, rhs);
521523
}
522524

@@ -647,7 +649,7 @@ exprt interpretert::get_value(
647649
}
648650

649651
// Retrieve value of basic data type
650-
return from_integer(rhs[integer2ulong(offset)], type);
652+
return from_integer(rhs[numeric_cast_v<std::size_t>(offset)], type);
651653
}
652654

653655
/// executes the assign statement at the current pc value
@@ -690,7 +692,7 @@ void interpretert::execute_assign()
690692

691693
for(mp_integer i=0; i<size; ++i)
692694
{
693-
memory[integer2ulong(address+i)].initialized=
695+
memory[numeric_cast_v<std::size_t>(address + i)].initialized =
694696
memory_cellt::initializedt::READ_BEFORE_WRITTEN;
695697
}
696698
}
@@ -707,7 +709,7 @@ void interpretert::assign(
707709
if((address+i)<memory.size())
708710
{
709711
mp_integer address_val=address+i;
710-
memory_cellt &cell=memory[integer2ulong(address_val)];
712+
memory_cellt &cell = memory[numeric_cast_v<std::size_t>(address_val)];
711713
if(show)
712714
{
713715
status() << total_steps << " ** assigning "
@@ -884,7 +886,7 @@ void interpretert::build_memory_map(const symbolt &symbol)
884886
if(size!=0)
885887
{
886888
mp_integer address=memory.size();
887-
memory.resize(integer2ulong(address+size));
889+
memory.resize(numeric_cast_v<std::size_t>(address + size));
888890
memory_map[symbol.name]=address;
889891
inverse_memory_map[address]=symbol.name;
890892
}
@@ -942,7 +944,7 @@ mp_integer interpretert::build_memory_map(
942944
size=1; // This is a hack to create existence
943945

944946
mp_integer address=memory.size();
945-
memory.resize(integer2ulong(address+size));
947+
memory.resize(numeric_cast_v<std::size_t>(address + size));
946948
memory_map[id]=address;
947949
inverse_memory_map[address]=id;
948950
dynamic_types.insert(std::pair<const irep_idt, typet>(id, alloc_type));

src/goto-programs/interpreter_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class interpretert:public messaget
145145

146146
mp_integer base_address_to_actual_size(const mp_integer &address) const
147147
{
148-
auto memory_iter=memory.find(integer2ulong(address));
148+
auto memory_iter = memory.find(numeric_cast_v<std::size_t>(address));
149149
if(memory_iter==memory.end())
150150
return 0;
151151
mp_integer ret=0;

src/goto-programs/interpreter_evaluate.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ void interpretert::read(
3333

3434
if((address+i)<memory.size())
3535
{
36-
const memory_cellt &cell=memory[integer2ulong(address+i)];
36+
const memory_cellt &cell =
37+
memory[numeric_cast_v<std::size_t>(address + i)];
3738
value=cell.value;
3839
if(cell.initialized==memory_cellt::initializedt::UNKNOWN)
3940
cell.initialized=memory_cellt::initializedt::READ_BEFORE_WRITTEN;
@@ -84,7 +85,7 @@ void interpretert::allocate(
8485
{
8586
if((address+i)<memory.size())
8687
{
87-
memory_cellt &cell=memory[integer2ulong(address+i)];
88+
memory_cellt &cell = memory[numeric_cast_v<std::size_t>(address + i)];
8889
cell.value=0;
8990
cell.initialized=memory_cellt::initializedt::UNKNOWN;
9091
}

0 commit comments

Comments
 (0)