Skip to content

Commit a9a44af

Browse files
author
Daniel Kroening
committed
introduce protected_exprt
This will serve as the interface that we aspire exprt to offer; in particular, access to opX is protected.
1 parent 8ddf489 commit a9a44af

File tree

4 files changed

+119
-86
lines changed

4 files changed

+119
-86
lines changed

src/util/expr.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,40 @@ class exprt:public irept
319319
const_unique_depth_iteratort unique_depth_cend() const;
320320
};
321321

322+
/// Protected class for all expressions.
323+
/// This API will eventually replace exprt.
324+
class protected_exprt : public exprt
325+
{
326+
protected:
327+
// constructors
328+
DEPRECATED("use protected_exprt(id, type) instead")
329+
protected_exprt() : exprt()
330+
{
331+
}
332+
333+
DEPRECATED("use protected_exprt(id, type) instead")
334+
explicit protected_exprt(const irep_idt &_id) : exprt(_id)
335+
{
336+
}
337+
338+
protected_exprt(const irep_idt &_id, const typet &_type) : exprt(_id, _type)
339+
{
340+
}
341+
342+
// protect these low-level methods
343+
using exprt::make_bool;
344+
using exprt::make_typecast;
345+
using exprt::op0;
346+
using exprt::op1;
347+
using exprt::op2;
348+
using exprt::op3;
349+
// using exprt::find;
350+
// using exprt::get;
351+
// using exprt::set;
352+
using exprt::add;
353+
using exprt::remove;
354+
};
355+
322356
class expr_visitort
323357
{
324358
public:

src/util/pointer_offset_size.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,11 @@ exprt build_sizeof_expr(
593593
const constant_exprt &expr,
594594
const namespacet &ns)
595595
{
596-
const typet &type=
597-
static_cast<const typet &>(expr.find(ID_C_c_sizeof_type));
596+
// need to cast down to access 'find'
597+
const auto &expr_as_irep = static_cast<const irept &>(expr);
598+
599+
const typet &type =
600+
static_cast<const typet &>(expr_as_irep.find(ID_C_c_sizeof_type));
598601

599602
if(type.is_nil())
600603
return nil_exprt();

src/util/std_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ extractbits_exprt::extractbits_exprt(
150150
const exprt &_src,
151151
const std::size_t _upper,
152152
const std::size_t _lower,
153-
const typet &_type):
154-
exprt(ID_extractbits, _type)
153+
const typet &_type)
154+
: protected_exprt(ID_extractbits, _type)
155155
{
156156
PRECONDITION(_upper >= _lower);
157157
operands().resize(3);

0 commit comments

Comments
 (0)