@@ -221,20 +221,14 @@ void smv_typecheckt::instantiate(
221
221
222
222
if (s_it==symbol_table.symbols .end ())
223
223
{
224
- error ().source_location =location;
225
- error () << " submodule `"
226
- << identifier
227
- << " ' not found" << eom;
228
- throw 0 ;
224
+ throw errort ().with_location (location)
225
+ << " submodule `" << identifier << " ' not found" ;
229
226
}
230
227
231
228
if (s_it->second .type .id ()!=ID_module)
232
229
{
233
- error ().source_location =location;
234
- error () << " submodule `"
235
- << identifier
236
- << " ' not a module" << eom;
237
- throw 0 ;
230
+ throw errort ().with_location (location)
231
+ << " submodule `" << identifier << " ' not a module" ;
238
232
}
239
233
240
234
const irept::subt &ports=s_it->second .type .find (ID_ports).get_sub ();
@@ -243,10 +237,8 @@ void smv_typecheckt::instantiate(
243
237
244
238
if (ports.size ()!=operands.size ())
245
239
{
246
- error ().source_location =location;
247
- error () << " submodule `" << identifier
248
- << " ' has wrong number of arguments" << eom;
249
- throw 0 ;
240
+ throw errort ().with_location (location)
241
+ << " submodule `" << identifier << " ' has wrong number of arguments" ;
250
242
}
251
243
252
244
std::set<irep_idt> port_identifiers;
@@ -275,12 +267,14 @@ void smv_typecheckt::instantiate(
275
267
276
268
if (s_it2==symbol_table.symbols .end ())
277
269
{
278
- error () << " symbol `" << v_it->second << " ' not found" << eom;
279
- throw 0 ;
270
+ throw errort () << " symbol `" << v_it->second << " ' not found" ;
280
271
}
281
272
282
- if (port_identifiers.find (s_it2->first ) != port_identifiers.end ()) {
283
- } else if (s_it2->second .type .id () == ID_module) {
273
+ if (port_identifiers.find (s_it2->first ) != port_identifiers.end ())
274
+ {
275
+ }
276
+ else if (s_it2->second .type .id () == ID_module)
277
+ {
284
278
}
285
279
else
286
280
{
@@ -316,8 +310,7 @@ void smv_typecheckt::instantiate(
316
310
317
311
if (s_it2==nullptr )
318
312
{
319
- error () << " symbol `" << v_id << " ' not found" << eom;
320
- throw 0 ;
313
+ throw errort () << " symbol `" << v_id << " ' not found" ;
321
314
}
322
315
323
316
symbolt &symbol=*s_it2;
@@ -400,10 +393,9 @@ void smv_typecheckt::instantiate_rename(
400
393
}
401
394
else
402
395
{
403
- error ().source_location =expr.find_source_location ();
404
- error () << " expected symbol expression here, but got "
405
- << to_string (it->second ) << eom;
406
- throw 0 ;
396
+ throw errort ().with_location (expr.find_source_location ())
397
+ << " expected symbol expression here, but got "
398
+ << to_string (it->second );
407
399
}
408
400
}
409
401
else
@@ -431,10 +423,8 @@ void smv_typecheckt::typecheck_op(
431
423
{
432
424
if (expr.operands ().size ()==0 )
433
425
{
434
- error ().source_location =expr.find_source_location ();
435
- error () << " Expected operands for " << expr.id ()
436
- << " operator" << eom;
437
- throw 0 ;
426
+ throw errort ().with_location (expr.find_source_location ())
427
+ << " Expected operands for " << expr.id () << " operator" ;
438
428
}
439
429
440
430
for (auto &op : expr.operands ())
@@ -497,9 +487,8 @@ smv_ranget smv_typecheckt::convert_type(const typet &src)
497
487
}
498
488
else
499
489
{
500
- error ().source_location =src.source_location ();
501
- error () << " Unexpected type: `" << to_string (src) << " '" << eom;
502
- throw 0 ;
490
+ throw errort ().with_location (src.source_location ())
491
+ << " Unexpected type: `" << to_string (src) << " '" ;
503
492
}
504
493
505
494
return dest;
@@ -589,9 +578,8 @@ void smv_typecheckt::typecheck(
589
578
590
579
if (s_it==nullptr )
591
580
{
592
- error ().source_location =expr.find_source_location ();
593
- error () << " variable `" << identifier << " ' not found" << eom;
594
- throw 0 ;
581
+ throw errort ().with_location (expr.find_source_location ())
582
+ << " variable `" << identifier << " ' not found" ;
595
583
}
596
584
597
585
symbolt &symbol=*s_it;
@@ -647,9 +635,8 @@ void smv_typecheckt::typecheck(
647
635
{
648
636
if (expr.operands ().size ()!=2 )
649
637
{
650
- error ().source_location =expr.find_source_location ();
651
- error () << " Expected two operands for -> operator" << eom;
652
- throw 0 ;
638
+ throw errort ().with_location (expr.find_source_location ())
639
+ << " Expected two operands for -> operator" ;
653
640
}
654
641
655
642
typecheck_op (expr, bool_typet (), mode);
@@ -663,9 +650,8 @@ void smv_typecheckt::typecheck(
663
650
664
651
if (expr.operands ().size ()!=2 )
665
652
{
666
- error ().source_location =expr.find_source_location ();
667
- error () << " Expected two operands for " << expr.id () << eom;
668
- throw 0 ;
653
+ throw errort ().with_location (expr.find_source_location ())
654
+ << " Expected two operands for " << expr.id ();
669
655
}
670
656
671
657
expr.type ()=bool_typet ();
@@ -684,9 +670,8 @@ void smv_typecheckt::typecheck(
684
670
{
685
671
if (op0.type ().id ()!=ID_range)
686
672
{
687
- error ().source_location =expr.find_source_location ();
688
- error () << " Expected number type for " << to_string (expr) << eom;
689
- throw 0 ;
673
+ throw errort ().with_location (expr.find_source_location ())
674
+ << " Expected number type for " << to_string (expr);
690
675
}
691
676
}
692
677
}
@@ -708,9 +693,8 @@ void smv_typecheckt::typecheck(
708
693
709
694
if (expr.operands ().size ()!=2 )
710
695
{
711
- error ().source_location =expr.find_source_location ();
712
- error () << " Expected two operands for " << expr.id () << eom;
713
- throw 0 ;
696
+ throw errort ().with_location (expr.find_source_location ())
697
+ << " Expected two operands for " << expr.id ();
714
698
}
715
699
716
700
if (type.is_nil ())
@@ -742,9 +726,8 @@ void smv_typecheckt::typecheck(
742
726
}
743
727
else if (type.id ()!=ID_range)
744
728
{
745
- error ().source_location =expr.find_source_location ();
746
- error () << " Expected number type for " << to_string (expr) << eom;
747
- throw 0 ;
729
+ throw errort ().with_location (expr.find_source_location ())
730
+ << " Expected number type for " << to_string (expr);
748
731
}
749
732
}
750
733
else if (expr.id ()==ID_constant)
@@ -772,9 +755,8 @@ void smv_typecheckt::typecheck(
772
755
expr=true_exprt ();
773
756
else
774
757
{
775
- error ().source_location =expr.find_source_location ();
776
- error () << " expected 0 or 1 here, but got " << value << eom;
777
- throw 0 ;
758
+ throw errort ().with_location (expr.find_source_location ())
759
+ << " expected 0 or 1 here, but got " << value;
778
760
}
779
761
}
780
762
else if (type.id ()==ID_range)
@@ -783,17 +765,15 @@ void smv_typecheckt::typecheck(
783
765
784
766
if (int_value<smv_range.from || int_value>smv_range.to )
785
767
{
786
- error ().source_location =expr.find_source_location ();
787
- error () << " expected " << smv_range.from << " .." << smv_range.to
788
- << " here, but got " << value << eom;
789
- throw 0 ;
768
+ throw errort ().with_location (expr.find_source_location ())
769
+ << " expected " << smv_range.from << " .." << smv_range.to
770
+ << " here, but got " << value;
790
771
}
791
772
}
792
773
else
793
774
{
794
- error ().source_location =expr.find_source_location ();
795
- error () << " Unexpected constant: " << value << eom;
796
- throw 0 ;
775
+ throw errort ().with_location (expr.find_source_location ())
776
+ << " Unexpected constant: " << value;
797
777
}
798
778
}
799
779
}
@@ -936,9 +916,8 @@ void smv_typecheckt::typecheck(
936
916
}
937
917
else
938
918
{
939
- error ().source_location =expr.find_source_location ();
940
- error () << " No type checking for " << expr.id () << eom;
941
- throw 0 ;
919
+ throw errort ().with_location (expr.find_source_location ())
920
+ << " No type checking for " << expr.id ();
942
921
}
943
922
944
923
if (!type.is_nil () && expr.type ()!=type)
@@ -969,12 +948,10 @@ void smv_typecheckt::typecheck(
969
948
return ;
970
949
}
971
950
972
- error ().source_location =expr.find_source_location ();
973
- error () << " Expected expression of type `" << to_string (type)
974
- << " ', but got expression `" << to_string (expr)
975
- << " ', which is of type `" << to_string (expr.type ())
976
- << " '" << eom;
977
- throw 0 ;
951
+ throw errort ().with_location (expr.find_source_location ())
952
+ << " Expected expression of type `" << to_string (type)
953
+ << " ', but got expression `" << to_string (expr) << " ', which is of type `"
954
+ << to_string (expr.type ()) << " '" ;
978
955
}
979
956
}
980
957
@@ -996,9 +973,8 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
996
973
{
997
974
if (expr_mode!=NORMAL)
998
975
{
999
- error ().source_location =expr.find_source_location ();
1000
- error () << " next(next(...)) encountered" << eom;
1001
- throw 0 ;
976
+ throw errort ().with_location (expr.find_source_location ())
977
+ << " next(next(...)) encountered" ;
1002
978
}
1003
979
1004
980
assert (expr.operands ().size ()==1 );
@@ -1044,9 +1020,8 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
1044
1020
{
1045
1021
if (expr.operands ().size ()==0 )
1046
1022
{
1047
- error ().source_location =expr.find_source_location ();
1048
- error () << " expected operand here" << eom;
1049
- throw 0 ;
1023
+ throw errort ().with_location (expr.find_source_location ())
1024
+ << " expected operand here" ;
1050
1025
}
1051
1026
1052
1027
std::string identifier=
@@ -1061,10 +1036,8 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
1061
1036
{
1062
1037
if (expr.operands ().size ()<1 )
1063
1038
{
1064
- error ().source_location =expr.find_source_location ();
1065
- error () << " Expected at least one operand for " << expr.id ()
1066
- << " expression" << eom;
1067
- throw 0 ;
1039
+ throw errort ().with_location (expr.find_source_location ())
1040
+ << " Expected at least one operand for " << expr.id () << " expression" ;
1068
1041
}
1069
1042
1070
1043
exprt tmp;
@@ -1075,8 +1048,8 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
1075
1048
{
1076
1049
if (op.operands ().size () != 2 )
1077
1050
{
1078
- error ().source_location = op.find_source_location ();
1079
- throw " case expected to have two operands" ;
1051
+ throw errort ().with_location ( op.find_source_location ())
1052
+ << " case expected to have two operands" ;
1080
1053
}
1081
1054
1082
1055
exprt &condition = to_binary_expr (op).op0 ();
@@ -1254,23 +1227,22 @@ Function: smv_typecheckt::collect_define
1254
1227
void smv_typecheckt::collect_define (const exprt &expr)
1255
1228
{
1256
1229
if (expr.id ()!=ID_equal || expr.operands ().size ()!=2 )
1257
- throw " collect_define expects equality" ;
1230
+ throw errort () << " collect_define expects equality" ;
1258
1231
1259
1232
const exprt &op0 = to_equal_expr (expr).op0 ();
1260
1233
const exprt &op1 = to_equal_expr (expr).op1 ();
1261
1234
1262
1235
if (op0.id ()!=ID_symbol)
1263
- throw " collect_define expects symbol on left hand side" ;
1236
+ throw errort () << " collect_define expects symbol on left hand side" ;
1264
1237
1265
- const irep_idt &identifier= op0. get (ID_identifier );
1238
+ const irep_idt &identifier = to_symbol_expr ( op0). get_identifier ( );
1266
1239
1267
1240
auto it=symbol_table.get_writeable (identifier);
1268
1241
1269
1242
if (it==nullptr )
1270
1243
{
1271
- error () << " collect_define failed to find symbol `"
1272
- << identifier << " '" << eom;
1273
- throw 0 ;
1244
+ throw errort () << " collect_define failed to find symbol `" << identifier
1245
+ << " '" ;
1274
1246
}
1275
1247
1276
1248
symbolt &symbol=*it;
@@ -1285,9 +1257,8 @@ void smv_typecheckt::collect_define(const exprt &expr)
1285
1257
1286
1258
if (!result.second )
1287
1259
{
1288
- error ().source_location =expr.find_source_location ();
1289
- error () << " symbol `" << identifier << " ' defined twice" << eom;
1290
- throw 0 ;
1260
+ throw errort ().with_location (expr.find_source_location ())
1261
+ << " symbol `" << identifier << " ' defined twice" ;
1291
1262
}
1292
1263
}
1293
1264
@@ -1311,17 +1282,15 @@ void smv_typecheckt::convert_define(const irep_idt &identifier)
1311
1282
1312
1283
if (d.in_progress )
1313
1284
{
1314
- error () << " definition of `" << identifier << " ' is cyclic" << eom;
1315
- throw 0 ;
1285
+ throw errort () << " definition of `" << identifier << " ' is cyclic" ;
1316
1286
}
1317
1287
1318
1288
auto it=symbol_table.get_writeable (identifier);
1319
1289
1320
1290
if (it==nullptr )
1321
1291
{
1322
- error () << " convert_define failed to find symbol `"
1323
- << identifier << " '" << eom;
1324
- throw 0 ;
1292
+ throw errort () << " convert_define failed to find symbol `" << identifier
1293
+ << " '" ;
1325
1294
}
1326
1295
1327
1296
symbolt &symbol=*it;
@@ -1493,8 +1462,7 @@ void smv_typecheckt::typecheck()
1493
1462
1494
1463
if (it==smv_parse_tree.modules .end ())
1495
1464
{
1496
- error () << " failed to find module " << module << eom;
1497
- throw 0 ;
1465
+ throw errort () << " failed to find module " << module ;
1498
1466
}
1499
1467
1500
1468
convert (it->second );
0 commit comments