Skip to content

Commit 79cf777

Browse files
authored
Merge pull request #3150 from diffblue/exprt_is_one_cleanup
typing of constant_exprt in exprt::is_one
2 parents 88ca2d4 + 5eca8b6 commit 79cf777

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/util/expr.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,13 @@ bool exprt::is_one() const
227227
{
228228
if(is_constant())
229229
{
230-
const std::string &value=get_string(ID_value);
231-
const irep_idt &type_id=type().id_string();
230+
const auto &constant_expr = to_constant_expr(*this);
231+
const irep_idt &type_id = type().id();
232232

233233
if(type_id==ID_integer || type_id==ID_natural)
234234
{
235-
mp_integer int_value=string2integer(value);
235+
mp_integer int_value =
236+
string2integer(id2string(constant_expr.get_value()));
236237
if(int_value==1)
237238
return true;
238239
}
@@ -245,18 +246,19 @@ bool exprt::is_one() const
245246
}
246247
else if(type_id==ID_unsignedbv || type_id==ID_signedbv)
247248
{
248-
mp_integer int_value = bv2integer(value, false);
249+
mp_integer int_value =
250+
bv2integer(id2string(constant_expr.get_value()), false);
249251
if(int_value==1)
250252
return true;
251253
}
252254
else if(type_id==ID_fixedbv)
253255
{
254-
if(fixedbvt(to_constant_expr(*this))==1)
256+
if(fixedbvt(constant_expr) == 1)
255257
return true;
256258
}
257259
else if(type_id==ID_floatbv)
258260
{
259-
if(ieee_floatt(to_constant_expr(*this))==1)
261+
if(ieee_floatt(constant_expr) == 1)
260262
return true;
261263
}
262264
}

0 commit comments

Comments
 (0)