Skip to content

Commit e1bf936

Browse files
committed
Use global null_message_handlert instead of duplicates.
1 parent 0d22f72 commit e1bf936

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

jbmc/unit/java-testing-utils/load_java_class.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <testing-utils/free_form_cmdline.h>
1212
#include <testing-utils/catch.hpp>
13+
#include <testing-utils/message.h>
1314
#include <iostream>
1415

1516
#include <util/config.h>
@@ -94,13 +95,16 @@ symbol_tablet load_java_class(
9495
std::string filename=java_class_name + ".class";
9596

9697
// Construct a lazy_goto_modelt
97-
null_message_handlert message_handler;
9898
lazy_goto_modelt lazy_goto_model(
99-
[] (goto_model_functiont &function, const abstract_goto_modelt &model) { }, // NOLINT (*)
100-
[] (goto_modelt &goto_model) { return false; }, // NOLINT (*)
101-
[] (const irep_idt &name) { return false; },
102-
[] (const irep_idt &function_name, symbol_table_baset &symbol_table, goto_functiont &function, bool body_available) { return false; }, // NOLINT (*)
103-
message_handler);
99+
[](goto_model_functiont &function, const abstract_goto_modelt &model) {},
100+
[](goto_modelt &goto_model) { return false; },
101+
[](const irep_idt &name) { return false; },
102+
[](
103+
const irep_idt &function_name,
104+
symbol_table_baset &symbol_table,
105+
goto_functiont &function,
106+
bool body_available) { return false; },
107+
null_message_handler);
104108

105109
// Configure the path loading
106110
config.java.classpath.clear();
@@ -115,7 +119,7 @@ symbol_tablet load_java_class(
115119
std::istringstream java_code_stream("ignored");
116120

117121
// Configure the language, load the class files
118-
language.set_message_handler(message_handler);
122+
language.set_message_handler(null_message_handler);
119123
language.get_language_options(command_line);
120124
language.parse(java_code_stream, filename);
121125
language.typecheck(lazy_goto_model.symbol_table, "");

jbmc/unit/java_bytecode/java_bytecode_parse_lambdas/java_bytecode_parse_lambda_method_table.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
#include <algorithm>
1010
#include <functional>
11-
#include <util/message.h>
1211
#include <util/config.h>
1312

1413
#include <java-testing-utils/require_parse_tree.h>
1514

1615
#include <testing-utils/catch.hpp>
16+
#include <testing-utils/message.h>
1717
#include <java_bytecode/java_bytecode_parser.h>
1818

1919
#include <java_bytecode/java_bytecode_parse_tree.h>
@@ -29,7 +29,6 @@ SCENARIO(
2929
{
3030
// NOLINTNEXTLINE(whitespace/braces)
3131
run_test_with_compilers([](const std::string &compiler) {
32-
null_message_handlert message_handler;
3332
GIVEN(
3433
"A class with a static lambda variables from " + compiler + " compiler.")
3534
{
@@ -38,7 +37,7 @@ SCENARIO(
3837
"./java_bytecode/java_bytecode_parse_lambdas/lambda_examples/" +
3938
compiler + "_classes/StaticLambdas.class",
4039
parse_tree,
41-
message_handler);
40+
null_message_handler);
4241
WHEN("Parsing that class")
4342
{
4443
REQUIRE(parse_tree.loading_successful);
@@ -342,15 +341,14 @@ SCENARIO(
342341
{
343342
run_test_with_compilers(
344343
[](const std::string &compiler) { // NOLINT(whitespace/braces)
345-
null_message_handlert message_handler;
346344
GIVEN("A method with local lambdas from " + compiler + " compiler.")
347345
{
348346
java_bytecode_parse_treet parse_tree;
349347
java_bytecode_parse(
350348
"./java_bytecode/java_bytecode_parse_lambdas/lambda_examples/" +
351349
compiler + "_classes/LocalLambdas.class",
352350
parse_tree,
353-
message_handler);
351+
null_message_handler);
354352
WHEN("Parsing that class")
355353
{
356354
REQUIRE(parse_tree.loading_successful);
@@ -650,7 +648,6 @@ SCENARIO(
650648
{
651649
run_test_with_compilers(
652650
[](const std::string &compiler) { // NOLINT(whitespace/braces)
653-
null_message_handlert message_handler;
654651
GIVEN(
655652
"A class that has lambdas as member variables from " + compiler +
656653
" compiler.")
@@ -660,7 +657,7 @@ SCENARIO(
660657
"./java_bytecode/java_bytecode_parse_lambdas/lambda_examples/" +
661658
compiler + "_classes/MemberLambdas.class",
662659
parse_tree,
663-
message_handler);
660+
null_message_handler);
664661
WHEN("Parsing that class")
665662
{
666663
REQUIRE(parse_tree.loading_successful);
@@ -985,7 +982,6 @@ SCENARIO(
985982
{
986983
run_test_with_compilers(
987984
[](const std::string &compiler) { // NOLINT(whitespace/braces)
988-
null_message_handlert message_handler;
989985
GIVEN(
990986
"An inner class with member variables as lambdas that capture outer "
991987
"variables from " +
@@ -996,7 +992,7 @@ SCENARIO(
996992
"./java_bytecode/java_bytecode_parse_lambdas/lambda_examples/" +
997993
compiler + "_classes/OuterMemberLambdas$Inner.class",
998994
parse_tree,
999-
message_handler);
995+
null_message_handler);
1000996
WHEN("Parsing that class")
1001997
{
1002998
REQUIRE(parse_tree.loading_successful);

jbmc/unit/java_bytecode/java_replace_nondet/replace_nondet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
\*******************************************************************/
99

1010
#include <testing-utils/catch.hpp>
11+
#include <testing-utils/message.h>
1112
#include <java-testing-utils/load_java_class.h>
1213

1314
#include <goto-programs/goto_convert_functions.h>
@@ -84,9 +85,8 @@ TEST_CASE(
8485
journalling_symbol_tablet symbol_table =
8586
journalling_symbol_tablet::wrap(raw_symbol_table);
8687

87-
null_message_handlert null_output;
8888
goto_functionst functions;
89-
goto_convert(symbol_table, functions, null_output);
89+
goto_convert(symbol_table, functions, null_message_handler);
9090

9191
const std::string function_name = "java::Main.replaceNondet:()V";
9292
goto_functionst::goto_functiont &goto_function =

jbmc/unit/java_bytecode/java_virtual_functions/virtual_functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
\*******************************************************************/
88

99
#include <testing-utils/catch.hpp>
10+
#include <testing-utils/message.h>
1011
#include <java-testing-utils/load_java_class.h>
1112

1213
#include <goto-programs/goto_convert_functions.h>
@@ -53,9 +54,8 @@ SCENARIO(
5354
WHEN("The entry point function is generated")
5455
{
5556
symbol_tablet new_table(symbol_table);
56-
null_message_handlert null_output;
5757
goto_functionst new_goto_functions;
58-
goto_convert(new_table, new_goto_functions, null_output);
58+
goto_convert(new_table, new_goto_functions, null_message_handler);
5959
remove_virtual_functions(new_table, new_goto_functions);
6060

6161
bool found_function = false;
@@ -129,7 +129,7 @@ SCENARIO(
129129
options.set_option("cover", "location");
130130
REQUIRE_FALSE(
131131
instrument_cover_goals(
132-
options, new_table, new_goto_functions, null_output));
132+
options, new_table, new_goto_functions, null_message_handler));
133133

134134
auto function = new_goto_functions.function_map.find(function_name);
135135
REQUIRE(function != new_goto_functions.function_map.end());

jbmc/unit/pointer-analysis/custom_value_set_analysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Author: Chris Smowton, [email protected]
77
\*******************************************************************/
88

99
#include <testing-utils/catch.hpp>
10+
#include <testing-utils/message.h>
1011

1112
#include <goto-programs/goto_inline.h>
1213
#include <goto-programs/initialize_goto_model.h>
@@ -170,7 +171,6 @@ SCENARIO("test_value_set_analysis",
170171
{
171172
config.set_arch("none");
172173
config.main = "";
173-
null_message_handlert null_output;
174174
cmdlinet command_line;
175175

176176
// This classpath is the default, but the config object
@@ -181,8 +181,8 @@ SCENARIO("test_value_set_analysis",
181181

182182
register_language(new_java_bytecode_language);
183183

184-
goto_modelt goto_model=
185-
initialize_goto_model(command_line, null_output);
184+
goto_modelt goto_model =
185+
initialize_goto_model(command_line, null_message_handler);
186186

187187
null_message_handlert message_handler;
188188
remove_java_new(goto_model, message_handler);
@@ -191,7 +191,7 @@ SCENARIO("test_value_set_analysis",
191191

192192
// Fully inline the test program, to avoid VSA conflating
193193
// constructor callsites confusing the results we're trying to check:
194-
goto_function_inline(goto_model, TEST_FUNCTION_NAME, null_output);
194+
goto_function_inline(goto_model, TEST_FUNCTION_NAME, null_message_handler);
195195

196196
const goto_programt &test_function=
197197
goto_model.goto_functions.function_map.at(TEST_PREFIX "test:()V").body;

unit/json/json_parser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
#include <json/json_parser.h>
1010
#include <testing-utils/catch.hpp>
11+
#include <testing-utils/message.h>
1112

1213
SCENARIO("Loading JSON files")
1314
{
14-
null_message_handlert message_handler;
1515
GIVEN("A invalid JSON file and a valid JSON file")
1616
{
1717
const std::string valid_json_path = "./json/valid.json";
@@ -21,7 +21,7 @@ SCENARIO("Loading JSON files")
2121
{
2222
jsont invalid_json;
2323
const auto invalid_parse_error =
24-
parse_json(invalid_json_path, message_handler, invalid_json);
24+
parse_json(invalid_json_path, null_message_handler, invalid_json);
2525
THEN("An error state should be returned")
2626
{
2727
REQUIRE(invalid_parse_error);
@@ -30,7 +30,7 @@ SCENARIO("Loading JSON files")
3030
{
3131
jsont valid_json;
3232
const auto valid_parse_error =
33-
parse_json(valid_json_path, message_handler, valid_json);
33+
parse_json(valid_json_path, null_message_handler, valid_json);
3434
THEN("The JSON file should be parsed correctly")
3535
{
3636
REQUIRE_FALSE(valid_parse_error);
@@ -45,7 +45,7 @@ SCENARIO("Loading JSON files")
4545
{
4646
jsont valid_json;
4747
const auto valid_parse_error =
48-
parse_json(valid_json_path, message_handler, valid_json);
48+
parse_json(valid_json_path, null_message_handler, valid_json);
4949
THEN("The JSON file should be parsed correctly")
5050
{
5151
REQUIRE_FALSE(valid_parse_error);
@@ -56,7 +56,7 @@ SCENARIO("Loading JSON files")
5656
{
5757
jsont invalid_json;
5858
const auto invalid_parse_error =
59-
parse_json(invalid_json_path, message_handler, invalid_json);
59+
parse_json(invalid_json_path, null_message_handler, invalid_json);
6060
THEN("An error state should be returned")
6161
{
6262
REQUIRE(invalid_parse_error);

0 commit comments

Comments
 (0)