Skip to content

Commit 247380f

Browse files
authored
Merge pull request #6089 from tautschnig/version-output-refactor
De-duplicate version output code
2 parents 1ab5de1 + 3776bf2 commit 247380f

File tree

9 files changed

+21
-49
lines changed

9 files changed

+21
-49
lines changed

jbmc/src/janalyzer/janalyzer_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "janalyzer_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <fstream>
1716
#include <iostream>
@@ -346,13 +345,7 @@ int janalyzer_parse_optionst::doit()
346345
messaget::eval_verbosity(
347346
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
348347

349-
//
350-
// Print a banner
351-
//
352-
log.status() << "JANALYZER version " << CBMC_VERSION << " "
353-
<< sizeof(void *) * CHAR_BIT << "-bit "
354-
<< config.this_architecture() << " "
355-
<< config.this_operating_system() << messaget::eom;
348+
log_version_and_architecture("JANALYZER");
356349

357350
register_languages();
358351

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "jbmc_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <iostream>
1716
#include <memory>
@@ -478,13 +477,7 @@ int jbmc_parse_optionst::doit()
478477
optionst options;
479478
get_command_line_options(options);
480479

481-
//
482-
// Print a banner
483-
//
484-
log.status() << "JBMC version " << CBMC_VERSION << " "
485-
<< sizeof(void *) * CHAR_BIT << "-bit "
486-
<< config.this_architecture() << " "
487-
<< config.this_operating_system() << messaget::eom;
480+
log_version_and_architecture("JBMC");
488481

489482
// output the options
490483
switch(ui_message_handler.get_ui())

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Peter Schrammel
1111

1212
#include "jdiff_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <iostream>
1716

@@ -175,13 +174,7 @@ int jdiff_parse_optionst::doit()
175174
messaget::eval_verbosity(
176175
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
177176

178-
//
179-
// Print a banner
180-
//
181-
log.status() << "JDIFF version " << CBMC_VERSION << " "
182-
<< sizeof(void *) * CHAR_BIT << "-bit "
183-
<< config.this_architecture() << " "
184-
<< config.this_operating_system() << messaget::eom;
177+
log_version_and_architecture("JDIFF");
185178

186179
if(cmdline.args.size() != 2)
187180
{

scripts/expected_doxygen_warnings.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ warning: Include graph for 'goto_instrument_parse_options.cpp' not generated, to
22
warning: Included by graph for 'goto_model.h' not generated, too many nodes (95), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
33
warning: Included by graph for 'arith_tools.h' not generated, too many nodes (167), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
44
warning: Included by graph for 'c_types.h' not generated, too many nodes (128), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
5-
warning: Included by graph for 'config.h' not generated, too many nodes (77), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
5+
warning: Included by graph for 'config.h' not generated, too many nodes (78), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
66
warning: Included by graph for 'invariant.h' not generated, too many nodes (172), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
77
warning: Included by graph for 'irep.h' not generated, too many nodes (80), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
88
warning: Included by graph for 'message.h' not generated, too many nodes (97), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.

src/cbmc/cbmc_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "cbmc_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <fstream>
1716
#include <iostream>
@@ -517,13 +516,7 @@ int cbmc_parse_optionst::doit()
517516
messaget::eval_verbosity(
518517
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
519518

520-
//
521-
// Print a banner
522-
//
523-
log.status() << "CBMC version " << CBMC_VERSION << " "
524-
<< sizeof(void *) * CHAR_BIT << "-bit "
525-
<< config.this_architecture() << " "
526-
<< config.this_operating_system() << messaget::eom;
519+
log_version_and_architecture("CBMC");
527520

528521
//
529522
// Unwinding of transition systems is done by hw-cbmc.

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "goto_analyzer_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <fstream>
1716
#include <iostream>
@@ -394,13 +393,7 @@ int goto_analyzer_parse_optionst::doit()
394393
messaget::eval_verbosity(
395394
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
396395

397-
//
398-
// Print a banner
399-
//
400-
log.status() << "GOTO-ANALYSER version " << CBMC_VERSION << " "
401-
<< sizeof(void *) * CHAR_BIT << "-bit "
402-
<< config.this_architecture() << " "
403-
<< config.this_operating_system() << messaget::eom;
396+
log_version_and_architecture("GOTO-ANALYZER");
404397

405398
register_languages();
406399

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Peter Schrammel
1111

1212
#include "goto_diff_parse_options.h"
1313

14-
#include <climits>
1514
#include <cstdlib> // exit()
1615
#include <fstream>
1716
#include <iostream>
@@ -135,13 +134,7 @@ int goto_diff_parse_optionst::doit()
135134
messaget::eval_verbosity(
136135
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
137136

138-
//
139-
// Print a banner
140-
//
141-
log.status() << "GOTO-DIFF version " << CBMC_VERSION << " "
142-
<< sizeof(void *) * CHAR_BIT << "-bit "
143-
<< config.this_architecture() << " "
144-
<< config.this_operating_system() << messaget::eom;
137+
log_version_and_architecture("GOTO-DIFF");
145138

146139
if(cmdline.args.size()!=2)
147140
{

src/util/parse_options.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ Author: Daniel Kroening, [email protected]
2121
#endif
2222

2323
#include "cmdline.h"
24+
#include "config.h"
2425
#include "exception_utils.h"
2526
#include "exit_codes.h"
2627
#include "signal_catcher.h"
2728
#include "string_utils.h"
29+
#include "version.h"
2830

2931
parse_options_baset::parse_options_baset(
3032
const std::string &_optstring,
@@ -147,6 +149,15 @@ int parse_options_baset::main()
147149
}
148150
}
149151

152+
void parse_options_baset::log_version_and_architecture(
153+
const std::string &front_end)
154+
{
155+
log.status() << front_end << " version " << CBMC_VERSION << " "
156+
<< sizeof(void *) * CHAR_BIT << "-bit "
157+
<< config.this_architecture() << " "
158+
<< config.this_operating_system() << messaget::eom;
159+
}
160+
150161
std::string align_center_with_border(const std::string &text)
151162
{
152163
auto const total_length = std::size_t{63};

src/util/parse_options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class parse_options_baset
3535
virtual int main();
3636
virtual ~parse_options_baset() { }
3737

38+
/// Write version and system architecture to log.status().
39+
void log_version_and_architecture(const std::string &front_end);
40+
3841
private:
3942
bool parse_result;
4043

0 commit comments

Comments
 (0)