Skip to content

Commit 477511e

Browse files
committed
Create cpp file for array_element_from_pointer
This is so that the function can be used in more than just one place.
1 parent c1d61ac commit 477511e

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/util/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SRC = allocate_objects.cpp \
22
arith_tools.cpp \
3+
array_element_from_pointer.cpp \
34
array_name.cpp \
45
base_type.cpp \
56
bv_arithmetic.cpp \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*******************************************************************\
2+
3+
Module: Element access in a pointer array
4+
5+
Author: Diffblue Ltd.
6+
7+
\*******************************************************************/
8+
9+
#include "array_element_from_pointer.h"
10+
11+
dereference_exprt
12+
array_element_from_pointer(const exprt &pointer, const exprt &index)
13+
{
14+
PRECONDITION(can_cast_type<pointer_typet>(pointer.type()));
15+
PRECONDITION(
16+
index.type().id() == ID_signedbv || index.type().id() == ID_unsignedbv);
17+
return dereference_exprt{plus_exprt{pointer, index}};
18+
}

src/util/array_element_from_pointer.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ Author: Diffblue Ltd.
2222
/// \param index: index of the element to access
2323
/// \return expression representing the (\p index)'th element of the array
2424
dereference_exprt
25-
array_element_from_pointer(const exprt &pointer, const exprt &index)
26-
{
27-
PRECONDITION(can_cast_type<pointer_typet>(pointer.type()));
28-
PRECONDITION(
29-
index.type().id() == ID_signedbv || index.type().id() == ID_unsignedbv);
30-
return dereference_exprt{plus_exprt{pointer, index}};
31-
}
25+
array_element_from_pointer(const exprt &pointer, const exprt &index);
3226

3327
#endif // CPROVER_UTIL_ARRAY_ELEMENT_FROM_POINTER_H

0 commit comments

Comments
 (0)