@@ -331,7 +331,7 @@ int gcc_modet::doit()
331331
332332 auto default_verbosity = (cmdline.isset (" Wall" ) || cmdline.isset (" Wextra" )) ?
333333 messaget::M_WARNING : messaget::M_ERROR;
334- eval_verbosity (
334+ messaget:: eval_verbosity (
335335 cmdline.get_value (" verbosity" ), default_verbosity, gcc_message_handler);
336336
337337 bool act_as_bcc=
@@ -407,19 +407,21 @@ int gcc_modet::doit()
407407 return EX_OK;
408408 }
409409
410+ messaget log{gcc_message_handler};
411+
410412 if (act_as_bcc)
411413 {
412414 if (produce_hybrid_binary)
413- debug () << " BCC mode (hybrid)" << eom;
415+ log. debug () << " BCC mode (hybrid)" << messaget:: eom;
414416 else
415- debug () << " BCC mode" << eom;
417+ log. debug () << " BCC mode" << messaget:: eom;
416418 }
417419 else
418420 {
419421 if (produce_hybrid_binary)
420- debug () << " GCC mode (hybrid)" << eom;
422+ log. debug () << " GCC mode (hybrid)" << messaget:: eom;
421423 else
422- debug () << " GCC mode" << eom;
424+ log. debug () << " GCC mode" << messaget:: eom;
423425 }
424426
425427 // model validation
@@ -540,25 +542,31 @@ int gcc_modet::doit()
540542 switch (compiler.mode )
541543 {
542544 case compilet::LINK_LIBRARY:
543- debug () << " Linking a library only" << eom; break ;
545+ log.debug () << " Linking a library only" << messaget::eom;
546+ break ;
544547 case compilet::COMPILE_ONLY:
545- debug () << " Compiling only" << eom; break ;
548+ log.debug () << " Compiling only" << messaget::eom;
549+ break ;
546550 case compilet::ASSEMBLE_ONLY:
547- debug () << " Assembling only" << eom; break ;
551+ log.debug () << " Assembling only" << messaget::eom;
552+ break ;
548553 case compilet::PREPROCESS_ONLY:
549- debug () << " Preprocessing only" << eom; break ;
554+ log.debug () << " Preprocessing only" << messaget::eom;
555+ break ;
550556 case compilet::COMPILE_LINK:
551- debug () << " Compiling and linking a library" << eom; break ;
557+ log.debug () << " Compiling and linking a library" << messaget::eom;
558+ break ;
552559 case compilet::COMPILE_LINK_EXECUTABLE:
553- debug () << " Compiling and linking an executable" << eom; break ;
560+ log.debug () << " Compiling and linking an executable" << messaget::eom;
561+ break ;
554562 }
555563
556564 if (cmdline.isset (" i386-win32" ) ||
557565 cmdline.isset (" winx64" ))
558566 {
559567 // We may wish to reconsider the below.
560568 config.ansi_c .mode =configt::ansi_ct::flavourt::VISUAL_STUDIO;
561- debug () << " Enabling Visual Studio syntax" << eom;
569+ log. debug () << " Enabling Visual Studio syntax" << messaget:: eom;
562570 }
563571 else
564572 {
@@ -697,7 +705,7 @@ int gcc_modet::doit()
697705
698706 if (exit_code!=0 )
699707 {
700- error () << " preprocessing has failed" << eom;
708+ log. error () << " preprocessing has failed" << messaget:: eom;
701709 return exit_code;
702710 }
703711
@@ -729,7 +737,8 @@ int gcc_modet::doit()
729737 cmdline.isset (' o' ) && cmdline.isset (' c' ) &&
730738 compiler.source_files .size () >= 2 )
731739 {
732- error () << " cannot specify -o with -c with multiple files" << eom;
740+ log.error () << " cannot specify -o with -c with multiple files"
741+ << messaget::eom;
733742 return 1 ; // to match gcc's behaviour
734743 }
735744
@@ -826,10 +835,11 @@ int gcc_modet::preprocess(
826835 INVARIANT (new_argv.size ()>=1 , " No program name in argv" );
827836 new_argv[0 ]=native_tool_name.c_str ();
828837
829- debug () << " RUN:" ;
838+ messaget log{gcc_message_handler};
839+ log.debug () << " RUN:" ;
830840 for (std::size_t i=0 ; i<new_argv.size (); i++)
831- debug () << " " << new_argv[i];
832- debug () << eom;
841+ log. debug () << " " << new_argv[i];
842+ log. debug () << messaget:: eom;
833843
834844 return run (new_argv[0 ], new_argv, cmdline.stdin_file , stdout_file, " " );
835845}
@@ -869,10 +879,11 @@ int gcc_modet::run_gcc(const compilet &compiler)
869879 // overwrite argv[0]
870880 new_argv[0 ]=native_tool_name;
871881
872- debug () << " RUN:" ;
882+ messaget log{gcc_message_handler};
883+ log.debug () << " RUN:" ;
873884 for (std::size_t i=0 ; i<new_argv.size (); i++)
874- debug () << " " << new_argv[i];
875- debug () << eom;
885+ log. debug () << " " << new_argv[i];
886+ log. debug () << messaget:: eom;
876887
877888 return run (new_argv[0 ], new_argv, cmdline.stdin_file , " " , " " );
878889}
@@ -927,8 +938,9 @@ int gcc_modet::gcc_hybrid_binary(compilet &compiler)
927938 output_files.front ()==" /dev/null" ))
928939 return run_gcc (compiler);
929940
930- debug () << " Running " << native_tool_name
931- << " to generate hybrid binary" << eom;
941+ messaget log{gcc_message_handler};
942+ log.debug () << " Running " << native_tool_name << " to generate hybrid binary"
943+ << messaget::eom;
932944
933945 // save the goto-cc output files
934946 std::list<std::string> goto_binaries;
@@ -945,7 +957,7 @@ int gcc_modet::gcc_hybrid_binary(compilet &compiler)
945957 }
946958 catch (const cprover_exception_baset &e)
947959 {
948- error () << " Rename failed: " << e.what () << eom;
960+ log. error () << " Rename failed: " << e.what () << messaget:: eom;
949961 return 1 ;
950962 }
951963
@@ -987,7 +999,7 @@ int gcc_modet::gcc_hybrid_binary(compilet &compiler)
987999 goto_binary,
9881000 *it,
9891001 compiler.mode == compilet::COMPILE_LINK_EXECUTABLE,
990- get_message_handler () );
1002+ gcc_message_handler );
9911003 }
9921004
9931005 return result;
@@ -1012,10 +1024,12 @@ int gcc_modet::asm_output(
10121024 return EX_OK;
10131025 }
10141026
1027+ messaget log{gcc_message_handler};
1028+
10151029 if (produce_hybrid_binary)
10161030 {
1017- debug () << " Running " << native_tool_name
1018- << " to generate native asm output" << eom;
1031+ log. debug () << " Running " << native_tool_name
1032+ << " to generate native asm output" << messaget:: eom;
10191033
10201034 int result=run_gcc (compiler);
10211035 if (result!=0 )
@@ -1043,23 +1057,24 @@ int gcc_modet::asm_output(
10431057 output_files.begin ()->second ==" /dev/null" ))
10441058 return EX_OK;
10451059
1046- debug ()
1047- << " Appending preprocessed sources to generate hybrid asm output"
1048- << eom;
1060+ log.debug () << " Appending preprocessed sources to generate hybrid asm output"
1061+ << messaget::eom;
10491062
10501063 for (const auto &so : output_files)
10511064 {
10521065 std::ifstream is (so.first );
10531066 if (!is.is_open ())
10541067 {
1055- error () << " Failed to open input source " << so.first << eom;
1068+ log.error () << " Failed to open input source " << so.first
1069+ << messaget::eom;
10561070 return 1 ;
10571071 }
10581072
10591073 std::ofstream os (so.second , std::ios::app);
10601074 if (!os.is_open ())
10611075 {
1062- error () << " Failed to open output file " << so.second << eom;
1076+ log.error () << " Failed to open output file " << so.second
1077+ << messaget::eom;
10631078 return 1 ;
10641079 }
10651080
0 commit comments