2828#include < util/cprover_prefix.h>
2929#include < util/options.h>
3030
31- #include < langapi/language_util.h>
31+ #include < langapi/language.h>
32+ #include < langapi/mode.h>
3233
3334#include " local_bitvector_analysis.h"
3435
@@ -80,9 +81,8 @@ class goto_checkt
8081 void check_rec (
8182 const exprt &expr,
8283 guardt &guard,
83- bool address,
84- const irep_idt &mode);
85- void check (const exprt &expr, const irep_idt &mode);
84+ bool address);
85+ void check (const exprt &expr);
8686
8787 void bounds_check (const index_exprt &expr, const guardt &guard);
8888 void div_by_zero_check (const div_exprt &expr, const guardt &guard);
@@ -94,8 +94,7 @@ class goto_checkt
9494 const dereference_exprt &expr,
9595 const guardt &guard,
9696 const exprt &access_lb,
97- const exprt &access_ub,
98- const irep_idt &mode);
97+ const exprt &access_ub);
9998 void integer_overflow_check (const exprt &expr, const guardt &guard);
10099 void conversion_check (const exprt &expr, const guardt &guard);
101100 void float_overflow_check (const exprt &expr, const guardt &guard);
@@ -141,6 +140,8 @@ class goto_checkt
141140 typedef std::pair<exprt, exprt> allocationt;
142141 typedef std::list<allocationt> allocationst;
143142 allocationst allocations;
143+
144+ irep_idt mode;
144145};
145146
146147void goto_checkt::collect_allocations (
@@ -917,8 +918,7 @@ void goto_checkt::pointer_validity_check(
917918 const dereference_exprt &expr,
918919 const guardt &guard,
919920 const exprt &access_lb,
920- const exprt &access_ub,
921- const irep_idt &mode)
921+ const exprt &access_ub)
922922{
923923 if (!enable_pointer_check)
924924 return ;
@@ -1274,7 +1274,8 @@ void goto_checkt::add_guarded_claim(
12741274
12751275 goto_programt::targett t=new_code.add_instruction (type);
12761276
1277- std::string source_expr_string=from_expr (ns, " " , src_expr);
1277+ std::string source_expr_string;
1278+ get_language_from_mode (mode)->from_expr (src_expr, source_expr_string, ns);
12781279
12791280 t->guard .swap (new_expr);
12801281 t->source_location =source_location;
@@ -1283,11 +1284,7 @@ void goto_checkt::add_guarded_claim(
12831284 }
12841285}
12851286
1286- void goto_checkt::check_rec (
1287- const exprt &expr,
1288- guardt &guard,
1289- bool address,
1290- const irep_idt &mode)
1287+ void goto_checkt::check_rec (const exprt &expr, guardt &guard, bool address)
12911288{
12921289 // we don't look into quantifiers
12931290 if (expr.id ()==ID_exists || expr.id ()==ID_forall)
@@ -1298,26 +1295,26 @@ void goto_checkt::check_rec(
12981295 if (expr.id ()==ID_dereference)
12991296 {
13001297 assert (expr.operands ().size ()==1 );
1301- check_rec (expr.op0 (), guard, false , mode );
1298+ check_rec (expr.op0 (), guard, false );
13021299 }
13031300 else if (expr.id ()==ID_index)
13041301 {
13051302 assert (expr.operands ().size ()==2 );
1306- check_rec (expr.op0 (), guard, true , mode );
1307- check_rec (expr.op1 (), guard, false , mode );
1303+ check_rec (expr.op0 (), guard, true );
1304+ check_rec (expr.op1 (), guard, false );
13081305 }
13091306 else
13101307 {
13111308 forall_operands (it, expr)
1312- check_rec (*it, guard, true , mode );
1309+ check_rec (*it, guard, true );
13131310 }
13141311 return ;
13151312 }
13161313
13171314 if (expr.id ()==ID_address_of)
13181315 {
13191316 assert (expr.operands ().size ()==1 );
1320- check_rec (expr.op0 (), guard, true , mode );
1317+ check_rec (expr.op0 (), guard, true );
13211318 return ;
13221319 }
13231320 else if (expr.id ()==ID_and || expr.id ()==ID_or)
@@ -1334,7 +1331,7 @@ void goto_checkt::check_rec(
13341331 throw " `" +expr.id_string ()+" ' takes Boolean operands only, but got " +
13351332 op.pretty ();
13361333
1337- check_rec (op, guard, false , mode );
1334+ check_rec (op, guard, false );
13381335
13391336 if (expr.id ()==ID_or)
13401337 guard.add (not_exprt (op));
@@ -1359,19 +1356,19 @@ void goto_checkt::check_rec(
13591356 throw msg;
13601357 }
13611358
1362- check_rec (expr.op0 (), guard, false , mode );
1359+ check_rec (expr.op0 (), guard, false );
13631360
13641361 {
13651362 guardt old_guard=guard;
13661363 guard.add (expr.op0 ());
1367- check_rec (expr.op1 (), guard, false , mode );
1364+ check_rec (expr.op1 (), guard, false );
13681365 guard.swap (old_guard);
13691366 }
13701367
13711368 {
13721369 guardt old_guard=guard;
13731370 guard.add (not_exprt (expr.op0 ()));
1374- check_rec (expr.op2 (), guard, false , mode );
1371+ check_rec (expr.op2 (), guard, false );
13751372 guard.swap (old_guard);
13761373 }
13771374
@@ -1384,7 +1381,7 @@ void goto_checkt::check_rec(
13841381 const dereference_exprt &deref=
13851382 to_dereference_expr (member.struct_op ());
13861383
1387- check_rec (deref.op0 (), guard, false , mode );
1384+ check_rec (deref.op0 (), guard, false );
13881385
13891386 exprt access_ub=nil_exprt ();
13901387
@@ -1394,13 +1391,13 @@ void goto_checkt::check_rec(
13941391 if (member_offset.is_not_nil () && size.is_not_nil ())
13951392 access_ub=plus_exprt (member_offset, size);
13961393
1397- pointer_validity_check (deref, guard, member_offset, access_ub, mode );
1394+ pointer_validity_check (deref, guard, member_offset, access_ub);
13981395
13991396 return ;
14001397 }
14011398
14021399 forall_operands (it, expr)
1403- check_rec (*it, guard, false , mode );
1400+ check_rec (*it, guard, false );
14041401
14051402 if (expr.id ()==ID_index)
14061403 {
@@ -1462,21 +1459,21 @@ void goto_checkt::check_rec(
14621459 to_dereference_expr (expr),
14631460 guard,
14641461 nil_exprt (),
1465- size_of_expr (expr.type (), ns),
1466- mode);
1462+ size_of_expr (expr.type (), ns));
14671463}
14681464
1469- void goto_checkt::check (const exprt &expr, const irep_idt &mode )
1465+ void goto_checkt::check (const exprt &expr)
14701466{
14711467 guardt guard;
1472- check_rec (expr, guard, false , mode );
1468+ check_rec (expr, guard, false );
14731469}
14741470
14751471void goto_checkt::goto_check (
14761472 goto_functiont &goto_function,
1477- const irep_idt &mode )
1473+ const irep_idt &_mode )
14781474{
14791475 assertions.clear ();
1476+ mode = _mode;
14801477
14811478 local_bitvector_analysist local_bitvector_analysis_obj (goto_function);
14821479 local_bitvector_analysis=&local_bitvector_analysis_obj;
@@ -1497,7 +1494,7 @@ void goto_checkt::goto_check(
14971494 i.is_target ())
14981495 assertions.clear ();
14991496
1500- check (i.guard , mode );
1497+ check (i.guard );
15011498
15021499 // magic ERROR label?
15031500 for (const auto &label : error_labels)
@@ -1523,20 +1520,20 @@ void goto_checkt::goto_check(
15231520
15241521 if (statement==ID_expression)
15251522 {
1526- check (i.code , mode );
1523+ check (i.code );
15271524 }
15281525 else if (statement==ID_printf)
15291526 {
15301527 forall_operands (it, i.code )
1531- check (*it, mode );
1528+ check (*it);
15321529 }
15331530 }
15341531 else if (i.is_assign ())
15351532 {
15361533 const code_assignt &code_assign=to_code_assign (i.code );
15371534
1538- check (code_assign.lhs (), mode );
1539- check (code_assign.rhs (), mode );
1535+ check (code_assign.lhs ());
1536+ check (code_assign.rhs ());
15401537
15411538 // the LHS might invalidate any assertion
15421539 invalidate (code_assign.lhs ());
@@ -1576,7 +1573,7 @@ void goto_checkt::goto_check(
15761573 }
15771574
15781575 forall_operands (it, code_function_call)
1579- check (*it, mode );
1576+ check (*it);
15801577
15811578 // the call might invalidate any assertion
15821579 assertions.clear ();
@@ -1585,7 +1582,7 @@ void goto_checkt::goto_check(
15851582 {
15861583 if (i.code .operands ().size ()==1 )
15871584 {
1588- check (i.code .op0 (), mode );
1585+ check (i.code .op0 ());
15891586 // the return value invalidate any assertion
15901587 invalidate (i.code .op0 ());
15911588 }
0 commit comments