Skip to content

Commit 3653c9b

Browse files
committed
bv_pointerst: move encoding methods into the .cpp file
This commit moves three methods that have (relatively) large bodies from the header file into the .cpp file.
1 parent 2110147 commit 3653c9b

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

src/solvers/flattening/bv_pointers.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,36 @@ std::size_t bv_pointerst::bv_pointers_widtht::get_address_width(
115115
return type.get_width();
116116
}
117117

118+
bvt bv_pointerst::object_literals(const bvt &bv, const pointer_typet &type)
119+
const
120+
{
121+
const std::size_t offset_width = bv_pointers_width.get_offset_width(type);
122+
const std::size_t object_width = bv_pointers_width.get_object_width(type);
123+
PRECONDITION(bv.size() >= offset_width + object_width);
124+
125+
return bvt(
126+
bv.begin() + offset_width, bv.begin() + offset_width + object_width);
127+
}
128+
129+
bvt bv_pointerst::offset_literals(const bvt &bv, const pointer_typet &type)
130+
const
131+
{
132+
const std::size_t offset_width = bv_pointers_width.get_offset_width(type);
133+
PRECONDITION(bv.size() >= offset_width);
134+
135+
return bvt(bv.begin(), bv.begin() + offset_width);
136+
}
137+
138+
bvt bv_pointerst::object_offset_encoding(const bvt &object, const bvt &offset)
139+
{
140+
bvt result;
141+
result.reserve(offset.size() + object.size());
142+
result.insert(result.end(), offset.begin(), offset.end());
143+
result.insert(result.end(), object.begin(), object.end());
144+
145+
return result;
146+
}
147+
118148
literalt bv_pointerst::convert_rest(const exprt &expr)
119149
{
120150
PRECONDITION(expr.type().id() == ID_bool);

src/solvers/flattening/bv_pointers.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,43 +115,21 @@ class bv_pointerst:public boolbvt
115115
/// \param bv: Encoded pointer
116116
/// \param type: Type of the encoded pointer
117117
/// \return Vector of literals identifying the object part of \p bv
118-
bvt object_literals(const bvt &bv, const pointer_typet &type) const
119-
{
120-
const std::size_t offset_width = bv_pointers_width.get_offset_width(type);
121-
const std::size_t object_width = bv_pointers_width.get_object_width(type);
122-
PRECONDITION(bv.size() >= offset_width + object_width);
123-
124-
return bvt(
125-
bv.begin() + offset_width, bv.begin() + offset_width + object_width);
126-
}
118+
bvt object_literals(const bvt &bv, const pointer_typet &type) const;
127119

128120
/// Given a pointer encoded in \p bv, extract the literals representing the
129121
/// offset into an object that the pointer points to.
130122
/// \param bv: Encoded pointer
131123
/// \param type: Type of the encoded pointer
132124
/// \return Vector of literals identifying the offset part of \p bv
133-
bvt offset_literals(const bvt &bv, const pointer_typet &type) const
134-
{
135-
const std::size_t offset_width = bv_pointers_width.get_offset_width(type);
136-
PRECONDITION(bv.size() >= offset_width);
137-
138-
return bvt(bv.begin(), bv.begin() + offset_width);
139-
}
125+
bvt offset_literals(const bvt &bv, const pointer_typet &type) const;
140126

141127
/// Construct a pointer encoding from given encodings of \p object and \p
142128
/// offset.
143129
/// \param object: Encoded object
144130
/// \param offset: Encoded offset
145131
/// \return Pointer encoding
146-
static bvt object_offset_encoding(const bvt &object, const bvt &offset)
147-
{
148-
bvt result;
149-
result.reserve(offset.size() + object.size());
150-
result.insert(result.end(), offset.begin(), offset.end());
151-
result.insert(result.end(), object.begin(), object.end());
152-
153-
return result;
154-
}
132+
static bvt object_offset_encoding(const bvt &object, const bvt &offset);
155133
};
156134

157135
#endif // CPROVER_SOLVERS_FLATTENING_BV_POINTERS_H

0 commit comments

Comments
 (0)