Skip to content

Commit 6f78426

Browse files
authored
Merge pull request #5618 from tautschnig/messaget-goto_cc_mode
goto_cc_modet isn't a messaget
2 parents 7f41999 + d40c7e2 commit 6f78426

File tree

9 files changed

+122
-83
lines changed

9 files changed

+122
-83
lines changed

src/goto-cc/armcc_mode.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ int armcc_modet::doit()
4646
has_prefix(base_name, "goto-link");
4747
#endif
4848

49-
const auto verbosity = eval_verbosity(
49+
const auto verbosity = messaget::eval_verbosity(
5050
cmdline.get_value("verbosity"), messaget::M_ERROR, message_handler);
5151

52-
debug() << "ARM mode" << eom;
52+
messaget log{message_handler};
53+
log.debug() << "ARM mode" << messaget::eom;
5354

5455
// model validation
5556
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

src/goto-cc/as_mode.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ int as_modet::doit()
7575
return EX_OK;
7676
}
7777

78+
messaget log{message_handler};
79+
7880
bool act_as_as86=
7981
base_name=="as86" ||
8082
base_name.find("goto-as86")!=std::string::npos;
@@ -83,40 +85,44 @@ int as_modet::doit()
8385
cmdline.isset("version"))
8486
{
8587
if(act_as_as86)
86-
status() << "as86 version: 0.16.17 (goto-cc " << CBMC_VERSION << ")"
87-
<< eom;
88+
{
89+
log.status() << "as86 version: 0.16.17 (goto-cc " << CBMC_VERSION << ")"
90+
<< messaget::eom;
91+
}
8892
else
89-
status() << "GNU assembler version 2.20.51.0.7 20100318"
90-
<< " (goto-cc " << CBMC_VERSION << ")" << eom;
93+
{
94+
log.status() << "GNU assembler version 2.20.51.0.7 20100318"
95+
<< " (goto-cc " << CBMC_VERSION << ")" << messaget::eom;
96+
}
9197

92-
status()
98+
log.status()
9399
<< '\n'
94100
<< "Copyright (C) 2006-2014 Daniel Kroening, Christoph Wintersteiger\n"
95101
<< "CBMC version: " << CBMC_VERSION << '\n'
96102
<< "Architecture: " << config.this_architecture() << '\n'
97-
<< "OS: " << config.this_operating_system() << eom;
103+
<< "OS: " << config.this_operating_system() << messaget::eom;
98104

99105
return EX_OK; // Exit!
100106
}
101107

102108
auto default_verbosity = (cmdline.isset("w-") || cmdline.isset("warn")) ?
103109
messaget::M_WARNING : messaget::M_ERROR;
104-
eval_verbosity(
110+
messaget::eval_verbosity(
105111
cmdline.get_value("verbosity"), default_verbosity, message_handler);
106112

107113
if(act_as_as86)
108114
{
109115
if(produce_hybrid_binary)
110-
debug() << "AS86 mode (hybrid)" << eom;
116+
log.debug() << "AS86 mode (hybrid)" << messaget::eom;
111117
else
112-
debug() << "AS86 mode" << eom;
118+
log.debug() << "AS86 mode" << messaget::eom;
113119
}
114120
else
115121
{
116122
if(produce_hybrid_binary)
117-
debug() << "AS mode (hybrid)" << eom;
123+
log.debug() << "AS mode (hybrid)" << messaget::eom;
118124
else
119-
debug() << "AS mode" << eom;
125+
log.debug() << "AS mode" << messaget::eom;
120126
}
121127

122128
// get configuration
@@ -128,12 +134,12 @@ int as_modet::doit()
128134
if(cmdline.isset('b')) // as86 only
129135
{
130136
compiler.mode=compilet::COMPILE_LINK_EXECUTABLE;
131-
debug() << "Compiling and linking an executable" << eom;
137+
log.debug() << "Compiling and linking an executable" << messaget::eom;
132138
}
133139
else
134140
{
135141
compiler.mode=compilet::COMPILE_LINK;
136-
debug() << "Compiling and linking a library" << eom;
142+
log.debug() << "Compiling and linking a library" << messaget::eom;
137143
}
138144

139145
config.ansi_c.mode=configt::ansi_ct::flavourt::GCC;
@@ -173,7 +179,7 @@ int as_modet::doit()
173179
std::ifstream is(infile);
174180
if(!is.is_open())
175181
{
176-
error() << "Failed to open input source " << infile << eom;
182+
log.error() << "Failed to open input source " << infile << messaget::eom;
177183
return 1;
178184
}
179185

@@ -208,7 +214,7 @@ int as_modet::doit()
208214
os.open(dest);
209215
if(!os.is_open())
210216
{
211-
error() << "Failed to tmp output file " << dest << eom;
217+
log.error() << "Failed to tmp output file " << dest << messaget::eom;
212218
return 1;
213219
}
214220

@@ -227,7 +233,10 @@ int as_modet::doit()
227233
compiler.add_input_file(dest);
228234
}
229235
else
230-
warning() << "No GOTO-CC section found in " << arg_it->arg << eom;
236+
{
237+
log.warning() << "No GOTO-CC section found in " << arg_it->arg
238+
<< messaget::eom;
239+
}
231240
}
232241

233242
// Revert to as in case there is no source to compile
@@ -285,8 +294,9 @@ int as_modet::as_hybrid_binary(const compilet &compiler)
285294
if(output_file=="/dev/null")
286295
return EX_OK;
287296

288-
debug() << "Running " << native_tool_name
289-
<< " to generate hybrid binary" << eom;
297+
messaget log{message_handler};
298+
log.debug() << "Running " << native_tool_name << " to generate hybrid binary"
299+
<< messaget::eom;
290300

291301
// save the goto-cc output file
292302
std::string saved = output_file + ".goto-cc-saved";
@@ -296,7 +306,7 @@ int as_modet::as_hybrid_binary(const compilet &compiler)
296306
}
297307
catch(const cprover_exception_baset &e)
298308
{
299-
error() << "Rename failed: " << e.what() << eom;
309+
log.error() << "Rename failed: " << e.what() << messaget::eom;
300310
return 1;
301311
}
302312

@@ -309,7 +319,7 @@ int as_modet::as_hybrid_binary(const compilet &compiler)
309319
saved,
310320
output_file,
311321
compiler.mode == compilet::COMPILE_LINK_EXECUTABLE,
312-
get_message_handler());
322+
message_handler);
313323
}
314324

315325
return result;

src/goto-cc/cw_mode.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ int cw_modet::doit()
4646
has_prefix(base_name, "goto-link");
4747
#endif
4848

49-
const auto verbosity = eval_verbosity(
49+
const auto verbosity = messaget::eval_verbosity(
5050
cmdline.get_value("verbosity"), messaget::M_ERROR, message_handler);
5151

52-
debug() << "CodeWarrior mode" << eom;
52+
messaget log{message_handler};
53+
log.debug() << "CodeWarrior mode" << messaget::eom;
5354

5455
// model validation
5556
compiler.validate_goto_model = cmdline.isset("validate-goto-model");

src/goto-cc/gcc_mode.cpp

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)