@@ -16,9 +16,10 @@ Author: Daniel Kroening, kroening@kroening.com
1616#include < util/arith_tools.h>
1717#include < util/c_types.h>
1818#include < util/config.h>
19+ #include < util/invariant.h>
1920#include < util/message.h>
20- #include < util/std_expr.h>
2121#include < util/std_code.h>
22+ #include < util/std_expr.h>
2223#include < util/symbol_table.h>
2324
2425#include < goto-programs/format_strings.h>
@@ -279,9 +280,9 @@ void string_instrumentationt::do_sprintf(
279280
280281 if (arguments.size ()<2 )
281282 {
282- error (). source_location =target-> source_location ;
283- error () << " sprintf expected to have two or more arguments" << eom;
284- throw 0 ;
283+ throw incorrect_source_program_exceptiont (
284+ " sprintf expected to have two or more arguments" ,
285+ target-> source_location ) ;
285286 }
286287
287288 goto_programt tmp;
@@ -321,10 +322,9 @@ void string_instrumentationt::do_snprintf(
321322
322323 if (arguments.size ()<3 )
323324 {
324- error ().source_location =target->source_location ;
325- error () << " snprintf expected to have three or more arguments"
326- << eom;
327- throw 0 ;
325+ throw incorrect_source_program_exceptiont (
326+ " snprintf expected to have three or more arguments" ,
327+ target->source_location );
328328 }
329329
330330 goto_programt tmp;
@@ -364,9 +364,8 @@ void string_instrumentationt::do_fscanf(
364364
365365 if (arguments.size ()<2 )
366366 {
367- error ().source_location =target->source_location ;
368- error () << " fscanf expected to have two or more arguments" << eom;
369- throw 0 ;
367+ throw incorrect_source_program_exceptiont (
368+ " fscanf expected to have two or more arguments" , target->source_location );
370369 }
371370
372371 goto_programt tmp;
@@ -650,9 +649,8 @@ void string_instrumentationt::do_strchr(
650649
651650 if (arguments.size ()!=2 )
652651 {
653- error ().source_location =target->source_location ;
654- error () << " strchr expected to have two arguments" << eom;
655- throw 0 ;
652+ throw incorrect_source_program_exceptiont (
653+ " strchr expected to have two arguments" , target->source_location );
656654 }
657655
658656 goto_programt tmp;
@@ -677,9 +675,8 @@ void string_instrumentationt::do_strrchr(
677675
678676 if (arguments.size ()!=2 )
679677 {
680- error ().source_location =target->source_location ;
681- error () << " strrchr expected to have two arguments" << eom;
682- throw 0 ;
678+ throw incorrect_source_program_exceptiont (
679+ " strrchr expected to have two arguments" , target->source_location );
683680 }
684681
685682 goto_programt tmp;
@@ -704,9 +701,8 @@ void string_instrumentationt::do_strstr(
704701
705702 if (arguments.size ()!=2 )
706703 {
707- error ().source_location =target->source_location ;
708- error () << " strstr expected to have two arguments" << eom;
709- throw 0 ;
704+ throw incorrect_source_program_exceptiont (
705+ " strstr expected to have two arguments" , target->source_location );
710706 }
711707
712708 goto_programt tmp;
@@ -738,9 +734,8 @@ void string_instrumentationt::do_strtok(
738734
739735 if (arguments.size ()!=2 )
740736 {
741- error ().source_location =target->source_location ;
742- error () << " strtok expected to have two arguments" << eom;
743- throw 0 ;
737+ throw incorrect_source_program_exceptiont (
738+ " strtok expected to have two arguments" , target->source_location );
744739 }
745740
746741 goto_programt tmp;
0 commit comments