File tree 4 files changed +111
-89
lines changed
4 files changed +111
-89
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,29 @@ class exprt:public irept
319
319
const_unique_depth_iteratort unique_depth_cend () const ;
320
320
};
321
321
322
+ // / Class for expressions that offers a restriction of the API
323
+ // / offered by exprt. Notably, access to non-type-safe methods such
324
+ // / as opX() is protected.
325
+ // / This API will eventually replace exprt.
326
+ class expr_protectedt : public exprt
327
+ {
328
+ protected:
329
+ // constructor
330
+ expr_protectedt (const irep_idt &_id, const typet &_type) : exprt(_id, _type)
331
+ {
332
+ }
333
+
334
+ // protect these low-level methods
335
+ using exprt::make_bool;
336
+ using exprt::make_typecast;
337
+ using exprt::op0;
338
+ using exprt::op1;
339
+ using exprt::op2;
340
+ using exprt::op3;
341
+ using exprt::add;
342
+ using exprt::remove;
343
+ };
344
+
322
345
class expr_visitort
323
346
{
324
347
public:
Original file line number Diff line number Diff line change @@ -593,8 +593,11 @@ exprt build_sizeof_expr(
593
593
const constant_exprt &expr,
594
594
const namespacet &ns)
595
595
{
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));
598
601
599
602
if (type.is_nil ())
600
603
return nil_exprt ();
Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ extractbits_exprt::extractbits_exprt(
150
150
const exprt &_src,
151
151
const std::size_t _upper,
152
152
const std::size_t _lower,
153
- const typet &_type):
154
- exprt (ID_extractbits, _type)
153
+ const typet &_type)
154
+ : protected_exprt (ID_extractbits, _type)
155
155
{
156
156
PRECONDITION (_upper >= _lower);
157
157
operands ().resize (3 );
You can’t perform that action at this time.
0 commit comments