Skip to content

Commit df36774

Browse files
authored
Merge pull request #3942 from tautschnig/deprecation-nil_typet-acceleration
Replace use of deprecated nil_typet in acceleration [blocks: #3800]
2 parents 2ff58a9 + 01217e2 commit df36774

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,19 +653,19 @@ void disjunctive_polynomial_accelerationt::assert_for_values(
653653
exprt &target)
654654
{
655655
// First figure out what the appropriate type for this expression is.
656-
typet expr_type=nil_typet();
656+
optionalt<typet> expr_type;
657657

658658
for(std::map<exprt, exprt>::iterator it=values.begin();
659659
it!=values.end();
660660
++it)
661661
{
662-
if(expr_type==nil_typet())
662+
if(!expr_type.has_value())
663663
{
664664
expr_type=it->first.type();
665665
}
666666
else
667667
{
668-
expr_type=join_types(expr_type, it->first.type());
668+
expr_type = join_types(*expr_type, it->first.type());
669669
}
670670
}
671671

@@ -690,7 +690,7 @@ void disjunctive_polynomial_accelerationt::assert_for_values(
690690
it!=coefficients.end();
691691
++it)
692692
{
693-
exprt concrete_value=from_integer(1, expr_type);
693+
exprt concrete_value = from_integer(1, *expr_type);
694694

695695
for(expr_listt::const_iterator e_it=it->first.begin();
696696
e_it!=it->first.end();
@@ -701,7 +701,7 @@ void disjunctive_polynomial_accelerationt::assert_for_values(
701701
if(e==loop_counter)
702702
{
703703
mult_exprt mult(
704-
from_integer(num_unwindings, expr_type), concrete_value);
704+
from_integer(num_unwindings, *expr_type), concrete_value);
705705
mult.swap(concrete_value);
706706
}
707707
else
@@ -718,7 +718,7 @@ void disjunctive_polynomial_accelerationt::assert_for_values(
718718
// OK, concrete_value now contains the value of all the relevant variables
719719
// multiplied together. Create the term concrete_value*coefficient and add
720720
// it into the polynomial.
721-
typecast_exprt cast(it->second, expr_type);
721+
typecast_exprt cast(it->second, *expr_type);
722722
const mult_exprt term(concrete_value, cast);
723723

724724
if(rhs.is_nil())

src/goto-instrument/accelerate/polynomial.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Author: Matt Lewis
2323
exprt polynomialt::to_expr()
2424
{
2525
exprt ret=nil_exprt();
26-
typet itype=nil_typet();
26+
optionalt<typet> itype;
2727

2828
// Figure out the appropriate type to do all the intermediate calculations
2929
// in.
@@ -35,13 +35,13 @@ exprt polynomialt::to_expr()
3535
t_it!=m_it->terms.end();
3636
++t_it)
3737
{
38-
if(itype==nil_typet())
38+
if(itype.has_value())
3939
{
4040
itype=t_it->var.type();
4141
}
4242
else
4343
{
44-
itype=join_types(itype, t_it->var.type());
44+
itype = join_types(*itype, t_it->var.type());
4545
}
4646
}
4747
}
@@ -59,23 +59,23 @@ exprt polynomialt::to_expr()
5959
coeff=-coeff;
6060
}
6161

62-
exprt mon_expr=from_integer(coeff, itype);
62+
exprt mon_expr = from_integer(coeff, *itype);
6363

6464
for(std::vector<monomialt::termt>::iterator t_it=m_it->terms.begin();
6565
t_it!=m_it->terms.end();
6666
++t_it)
6767
{
6868
for(unsigned int i=0; i < t_it->exp; i++)
6969
{
70-
mon_expr=mult_exprt(mon_expr, typecast_exprt(t_it->var, itype));
70+
mon_expr = mult_exprt(mon_expr, typecast_exprt(t_it->var, *itype));
7171
}
7272
}
7373

7474
if(ret.id()==ID_nil)
7575
{
7676
if(neg)
7777
{
78-
ret=unary_minus_exprt(mon_expr, itype);
78+
ret = unary_minus_exprt(mon_expr, *itype);
7979
}
8080
else
8181
{

src/goto-instrument/accelerate/polynomial_accelerator.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void polynomial_acceleratort::assert_for_values(
508508
overflow_instrumentert &overflow)
509509
{
510510
// First figure out what the appropriate type for this expression is.
511-
typet expr_type=nil_typet();
511+
optionalt<typet> expr_type;
512512

513513
for(std::map<exprt, int>::iterator it=values.begin();
514514
it!=values.end();
@@ -523,25 +523,26 @@ void polynomial_acceleratort::assert_for_values(
523523
this_type=size_type();
524524
}
525525

526-
if(expr_type==nil_typet())
526+
if(!expr_type.has_value())
527527
{
528528
expr_type=this_type;
529529
}
530530
else
531531
{
532-
expr_type=join_types(expr_type, this_type);
532+
expr_type = join_types(*expr_type, this_type);
533533
}
534534
}
535535

536-
assert(to_bitvector_type(expr_type).get_width()>0);
537-
536+
INVARIANT(
537+
to_bitvector_type(*expr_type).get_width() > 0,
538+
"joined types must be non-empty bitvector types");
538539

539540
// Now set the initial values of the all the variables...
540541
for(std::map<exprt, int>::iterator it=values.begin();
541542
it!=values.end();
542543
++it)
543544
{
544-
program.assign(it->first, from_integer(it->second, expr_type));
545+
program.assign(it->first, from_integer(it->second, *expr_type));
545546
}
546547

547548
// Now unwind the loop as many times as we need to.
@@ -583,8 +584,8 @@ void polynomial_acceleratort::assert_for_values(
583584
// OK, concrete_value now contains the value of all the relevant variables
584585
// multiplied together. Create the term concrete_value*coefficient and add
585586
// it into the polynomial.
586-
typecast_exprt cast(it->second, expr_type);
587-
const mult_exprt term(from_integer(concrete_value, expr_type), cast);
587+
typecast_exprt cast(it->second, *expr_type);
588+
const mult_exprt term(from_integer(concrete_value, *expr_type), cast);
588589

589590
if(rhs.is_nil())
590591
{

0 commit comments

Comments
 (0)