@@ -218,11 +218,7 @@ exprt smt2_parsert::let_expression()
218
218
exprt smt2_parsert::quantifier_expression (irep_idt id)
219
219
{
220
220
if (next_token ()!=OPEN)
221
- {
222
- std::ostringstream msg;
223
- msg << " expected bindings after " << id;
224
- throw error (msg.str ());
225
- }
221
+ throw error () << " expected bindings after " << id;
226
222
227
223
std::vector<symbol_exprt> bindings;
228
224
@@ -257,11 +253,7 @@ exprt smt2_parsert::quantifier_expression(irep_idt id)
257
253
exprt expr=expression ();
258
254
259
255
if (next_token ()!=CLOSE)
260
- {
261
- std::ostringstream msg;
262
- msg << " expected ')' after " << id;
263
- throw error (msg.str ());
264
- }
256
+ throw error () << " expected ')' after " << id;
265
257
266
258
exprt result=expr;
267
259
@@ -348,12 +340,10 @@ exprt smt2_parsert::multi_ary(irep_idt id, const exprt::operandst &op)
348
340
{
349
341
if (op[i].type () != op[0 ].type ())
350
342
{
351
- std::ostringstream msg;
352
- msg << " expression must have operands with matching types,"
353
- " but got `"
354
- << smt2_format (op[0 ].type ()) << " ' and `" << smt2_format (op[i].type ())
355
- << ' \' ' ;
356
- throw error (msg.str ());
343
+ throw error () << " expression must have operands with matching types,"
344
+ " but got `"
345
+ << smt2_format (op[0 ].type ()) << " ' and `"
346
+ << smt2_format (op[i].type ()) << ' \' ' ;
357
347
}
358
348
}
359
349
@@ -369,12 +359,10 @@ exprt smt2_parsert::binary_predicate(irep_idt id, const exprt::operandst &op)
369
359
370
360
if (op[0 ].type () != op[1 ].type ())
371
361
{
372
- std::ostringstream msg;
373
- msg << " expression must have operands with matching types,"
374
- " but got `"
375
- << smt2_format (op[0 ].type ()) << " ' and `" << smt2_format (op[1 ].type ())
376
- << ' \' ' ;
377
- throw error (msg.str ());
362
+ throw error () << " expression must have operands with matching types,"
363
+ " but got `"
364
+ << smt2_format (op[0 ].type ()) << " ' and `"
365
+ << smt2_format (op[1 ].type ()) << ' \' ' ;
378
366
}
379
367
380
368
return binary_predicate_exprt (op[0 ], id, op[1 ]);
@@ -404,26 +392,16 @@ exprt smt2_parsert::function_application_ieee_float_op(
404
392
const exprt::operandst &op)
405
393
{
406
394
if (op.size () != 3 )
407
- {
408
- std::ostringstream message;
409
- message << id << " takes three operands" ;
410
- throw error (message);
411
- }
395
+ throw error () << id << " takes three operands" ;
412
396
413
397
if (op[1 ].type ().id () != ID_floatbv || op[2 ].type ().id () != ID_floatbv)
414
- {
415
- std::ostringstream message;
416
- message << id << " takes FloatingPoint operands" ;
417
- throw error (message);
418
- }
398
+ throw error () << id << " takes FloatingPoint operands" ;
419
399
420
400
if (op[1 ].type () != op[2 ].type ())
421
401
{
422
- std::ostringstream message;
423
- message << id << " takes FloatingPoint operands with matching sort, "
424
- << " but got " << smt2_format (op[1 ].type ()) << " vs "
425
- << smt2_format (op[2 ].type ());
426
- throw error (message);
402
+ throw error () << id << " takes FloatingPoint operands with matching sort, "
403
+ << " but got " << smt2_format (op[1 ].type ()) << " vs "
404
+ << smt2_format (op[2 ].type ());
427
405
}
428
406
429
407
// clang-format off
@@ -494,9 +472,7 @@ exprt smt2_parsert::function_application()
494
472
}
495
473
else
496
474
{
497
- std::ostringstream msg;
498
- msg << " unknown indexed identifier " << buffer;
499
- throw error (msg.str ());
475
+ throw error () << " unknown indexed identifier " << buffer;
500
476
}
501
477
}
502
478
else if (buffer == " !" )
@@ -791,9 +767,7 @@ exprt smt2_parsert::function_application()
791
767
return symbol_exprt (final_id, id_it->second .type );
792
768
}
793
769
794
- std::ostringstream msg;
795
- msg << " unknown function symbol " << id;
796
- throw error (msg.str ());
770
+ throw error () << " unknown function symbol `" << id << ' \' ' ;
797
771
}
798
772
}
799
773
break ;
@@ -847,29 +821,17 @@ exprt smt2_parsert::function_application()
847
821
id==" zero_extend" )
848
822
{
849
823
if (next_token ()!=NUMERAL)
850
- {
851
- std::ostringstream msg;
852
- msg << " expected numeral after " << id;
853
- throw error (msg.str ());
854
- }
824
+ throw error () << " expected numeral after " << id;
855
825
856
826
auto index=std::stoll (buffer);
857
827
858
828
if (next_token ()!=CLOSE)
859
- {
860
- std::ostringstream msg;
861
- msg << " expected ')' after " << id << " index" ;
862
- throw error (msg.str ());
863
- }
829
+ throw error () << " expected ')' after " << id << " index" ;
864
830
865
831
auto op=operands ();
866
832
867
833
if (op.size ()!=1 )
868
- {
869
- std::ostringstream msg;
870
- msg << id << " takes one operand" ;
871
- throw error (msg.str ());
872
- }
834
+ throw error () << id << " takes one operand" ;
873
835
874
836
if (id==" rotate_left" )
875
837
{
@@ -911,9 +873,7 @@ exprt smt2_parsert::function_application()
911
873
}
912
874
else
913
875
{
914
- std::ostringstream msg;
915
- msg << " unknown indexed identifier " << buffer;
916
- throw error (msg.str ());
876
+ throw error () << " unknown indexed identifier `" << buffer << ' \' ' ;
917
877
}
918
878
}
919
879
else
@@ -1001,9 +961,7 @@ exprt smt2_parsert::expression()
1001
961
return std::move (symbol_expr);
1002
962
}
1003
963
1004
- std::ostringstream msg;
1005
- msg << " unknown expression " << identifier;
1006
- throw error (msg.str ());
964
+ throw error () << " unknown expression `" << identifier << ' \' ' ;
1007
965
}
1008
966
}
1009
967
@@ -1054,11 +1012,7 @@ typet smt2_parsert::sort()
1054
1012
else if (buffer==" Real" )
1055
1013
return real_typet ();
1056
1014
else
1057
- {
1058
- std::ostringstream msg;
1059
- msg << " unexpected sort: `" << buffer << ' \' ' ;
1060
- throw error (msg.str ());
1061
- }
1015
+ throw error () << " unexpected sort: `" << buffer << ' \' ' ;
1062
1016
1063
1017
case OPEN:
1064
1018
if (next_token ()!=SYMBOL)
@@ -1102,11 +1056,7 @@ typet smt2_parsert::sort()
1102
1056
return ieee_float_spect (width_f - 1 , width_e).to_type ();
1103
1057
}
1104
1058
else
1105
- {
1106
- std::ostringstream msg;
1107
- msg << " unexpected sort: `" << buffer << ' \' ' ;
1108
- throw error (msg.str ());
1109
- }
1059
+ throw error () << " unexpected sort: `" << buffer << ' \' ' ;
1110
1060
}
1111
1061
else if (buffer == " Array" )
1112
1062
{
@@ -1126,16 +1076,10 @@ typet smt2_parsert::sort()
1126
1076
throw error (" unsupported array sort" );
1127
1077
}
1128
1078
else
1129
- {
1130
- std::ostringstream msg;
1131
- msg << " unexpected sort: `" << buffer << ' \' ' ;
1132
- throw error (msg.str ());
1133
- }
1079
+ throw error () << " unexpected sort: `" << buffer << ' \' ' ;
1134
1080
1135
1081
default :
1136
- std::ostringstream msg;
1137
- msg << " unexpected token in a sort: `" << buffer << ' \' ' ;
1138
- throw error (msg.str ());
1082
+ throw error () << " unexpected token in a sort: `" << buffer << ' \' ' ;
1139
1083
}
1140
1084
}
1141
1085
@@ -1224,21 +1168,13 @@ void smt2_parsert::command(const std::string &c)
1224
1168
// declare-var appears to be a synonym for declare-const that is
1225
1169
// accepted by Z3 and CVC4
1226
1170
if (next_token ()!=SYMBOL)
1227
- {
1228
- std::ostringstream msg;
1229
- msg << " expected a symbol after `" << c << ' \' ' ;
1230
- throw error (msg.str ());
1231
- }
1171
+ throw error () << " expected a symbol after `" << c << ' \' ' ;
1232
1172
1233
1173
irep_idt id = buffer;
1234
1174
auto type = sort ();
1235
1175
1236
1176
if (id_map.find (id)!=id_map.end ())
1237
- {
1238
- std::ostringstream msg;
1239
- msg << " identifier `" << id << " ' defined twice" ;
1240
- throw error (msg.str ());
1241
- }
1177
+ throw error () << " identifier `" << id << " ' defined twice" ;
1242
1178
1243
1179
auto &entry = id_map[id];
1244
1180
entry.type = type;
@@ -1253,11 +1189,7 @@ void smt2_parsert::command(const std::string &c)
1253
1189
auto type = function_signature_declaration ();
1254
1190
1255
1191
if (id_map.find (id)!=id_map.end ())
1256
- {
1257
- std::ostringstream msg;
1258
- msg << " identifier `" << id << " ' defined twice" ;
1259
- throw error (msg.str ());
1260
- }
1192
+ throw error () << " identifier `" << id << " ' defined twice" ;
1261
1193
1262
1194
auto &entry = id_map[id];
1263
1195
entry.type = type;
@@ -1271,23 +1203,17 @@ void smt2_parsert::command(const std::string &c)
1271
1203
const irep_idt id = buffer;
1272
1204
1273
1205
if (id_map.find (id) != id_map.end ())
1274
- {
1275
- std::ostringstream msg;
1276
- msg << " identifier `" << id << " ' defined twice" ;
1277
- throw error (msg.str ());
1278
- }
1206
+ throw error () << " identifier `" << id << " ' defined twice" ;
1279
1207
1280
1208
const auto type = sort ();
1281
1209
const auto value = expression ();
1282
1210
1283
1211
// check type of value
1284
1212
if (value.type () != type)
1285
1213
{
1286
- std::ostringstream msg;
1287
- msg << " type mismatch in constant definition: expected `"
1288
- << smt2_format (type) << " ' but got `" << smt2_format (value.type ())
1289
- << ' \' ' ;
1290
- throw error (msg.str ());
1214
+ throw error () << " type mismatch in constant definition: expected `"
1215
+ << smt2_format (type) << " ' but got `"
1216
+ << smt2_format (value.type ()) << ' \' ' ;
1291
1217
}
1292
1218
1293
1219
// create the entry
@@ -1303,11 +1229,7 @@ void smt2_parsert::command(const std::string &c)
1303
1229
const irep_idt id=buffer;
1304
1230
1305
1231
if (id_map.find (id)!=id_map.end ())
1306
- {
1307
- std::ostringstream msg;
1308
- msg << " identifier `" << id << " ' defined twice" ;
1309
- throw error (msg.str ());
1310
- }
1232
+ throw error () << " identifier `" << id << " ' defined twice" ;
1311
1233
1312
1234
const auto signature = function_signature_definition ();
1313
1235
const auto body = expression ();
@@ -1318,20 +1240,16 @@ void smt2_parsert::command(const std::string &c)
1318
1240
const auto &f_signature = to_mathematical_function_type (signature.type );
1319
1241
if (body.type () != f_signature.codomain ())
1320
1242
{
1321
- std::ostringstream msg;
1322
- msg << " type mismatch in function definition: expected `"
1323
- << smt2_format (f_signature.codomain ()) << " ' but got `"
1324
- << smt2_format (body.type ()) << ' \' ' ;
1325
- throw error (msg.str ());
1243
+ throw error () << " type mismatch in function definition: expected `"
1244
+ << smt2_format (f_signature.codomain ()) << " ' but got `"
1245
+ << smt2_format (body.type ()) << ' \' ' ;
1326
1246
}
1327
1247
}
1328
1248
else if (body.type () != signature.type )
1329
1249
{
1330
- std::ostringstream msg;
1331
- msg << " type mismatch in function definition: expected `"
1332
- << smt2_format (signature.type ) << " ' but got `"
1333
- << smt2_format (body.type ()) << ' \' ' ;
1334
- throw error (msg.str ());
1250
+ throw error () << " type mismatch in function definition: expected `"
1251
+ << smt2_format (signature.type ) << " ' but got `"
1252
+ << smt2_format (body.type ()) << ' \' ' ;
1335
1253
}
1336
1254
1337
1255
// create the entry
0 commit comments