Skip to content

Commit 4bb7393

Browse files
authored
Merge pull request #3189 from romainbrenguier/clean-up/preprocessing-part2
Cleanup in string preprocessing
2 parents 42670a7 + e81e174 commit 4bb7393

13 files changed

+275
-339
lines changed

jbmc/src/java_bytecode/convert_java_nondet.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Author: Reuben Thomas, [email protected]
1515
#include <goto-programs/goto_model.h>
1616
#include <goto-programs/remove_skip.h>
1717

18-
#include <util/fresh_symbol.h>
1918
#include <util/irep_ids.h>
2019

2120
#include <memory>
2221

2322
#include "java_object_factory.h" // gen_nondet_init
23+
#include "java_utils.h"
2424

2525
/// Returns true if `expr` is a nondet pointer that isn't a function pointer or
2626
/// a void* pointer as these can be meaningfully non-det initialized.
@@ -116,13 +116,8 @@ static std::pair<goto_programt::targett, bool> insert_nondet_init_code(
116116
// target2: instruction containing op, with op replaced by aux_symbol
117117
// dead aux_symbol
118118

119-
symbolt &aux_symbol = get_fresh_aux_symbol(
120-
op.type(),
121-
id2string(function_identifier),
122-
"nondet_tmp",
123-
source_loc,
124-
ID_java,
125-
symbol_table);
119+
symbolt &aux_symbol = fresh_java_symbol(
120+
op.type(), "nondet_tmp", source_loc, function_identifier, symbol_table);
126121

127122
const symbol_exprt aux_symbol_expr = aux_symbol.symbol_expr();
128123
op = aux_symbol_expr;

jbmc/src/java_bytecode/java_bytecode_concurrency_instrumentation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Author: Kurt Degiogrio, [email protected]
99
#include "java_bytecode_concurrency_instrumentation.h"
1010
#include "expr2java.h"
1111
#include "java_types.h"
12+
#include "java_utils.h"
1213

1314
#include <util/expr_iterator.h>
1415
#include <util/namespace.h>
1516
#include <util/cprover_prefix.h>
1617
#include <util/std_types.h>
17-
#include <util/fresh_symbol.h>
1818
#include <util/arith_tools.h>
1919

2020
// Disable linter to allow an std::string constant.
@@ -229,12 +229,11 @@ static void instrument_synchronized_code(
229229
code_pop_catcht catch_pop;
230230

231231
// Create the finally block with the same label targeted in the catch-push
232-
const symbolt &tmp_symbol = get_fresh_aux_symbol(
232+
const symbolt &tmp_symbol = fresh_java_symbol(
233233
java_reference_type(struct_tag_typet("java::java.lang.Throwable")),
234-
id2string(symbol.name),
235234
"caught-synchronized-exception",
236235
code.source_location(),
237-
ID_java,
236+
id2string(symbol.name),
238237
symbol_table);
239238
symbol_exprt catch_var(tmp_symbol.name, tmp_symbol.type);
240239
catch_var.set(ID_C_base_name, tmp_symbol.base_name);

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Date: June 2017
1111
#include "java_bytecode_instrument.h"
1212

1313
#include <util/arith_tools.h>
14-
#include <util/fresh_symbol.h>
1514
#include <util/std_code.h>
1615
#include <util/std_expr.h>
1716
#include <util/c_types.h>
@@ -112,14 +111,8 @@ code_ifthenelset java_bytecode_instrumentt::throw_exception(
112111

113112
// Allocate and throw an instance of the exception class:
114113

115-
symbolt &new_symbol=
116-
get_fresh_aux_symbol(
117-
exc_ptr_type,
118-
"new_exception",
119-
"new_exception",
120-
original_loc,
121-
ID_java,
122-
symbol_table);
114+
symbolt &new_symbol = fresh_java_symbol(
115+
exc_ptr_type, "new_exception", original_loc, "new_exception", symbol_table);
123116

124117
side_effect_exprt new_instance(ID_java_new, exc_ptr_type, original_loc);
125118
code_assignt assign_new(new_symbol.symbol_expr(), new_instance);

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,11 @@ exprt::operandst java_build_arguments(
375375
// method(..., param, ...)
376376
//
377377

378-
const symbolt result_symbol = get_fresh_aux_symbol(
378+
const symbolt result_symbol = fresh_java_symbol(
379379
p.type(),
380-
id2string(function.name),
381380
"nondet_parameter_" + std::to_string(param_number),
382381
function.location,
383-
ID_java,
382+
function.name,
384383
symbol_table);
385384
main_arguments[param_number] = result_symbol.symbol_expr();
386385

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Author: Daniel Kroening, [email protected]
99
#include "java_object_factory.h"
1010

1111
#include <util/expr_initializer.h>
12-
#include <util/fresh_symbol.h>
1312
#include <util/nondet_bool.h>
1413
#include <util/nondet.h>
1514
#include <util/pointer_offset_size.h>
@@ -20,6 +19,7 @@ Author: Daniel Kroening, [email protected]
2019
#include "generic_parameter_specialization_map_keys.h"
2120
#include "java_root_class.h"
2221
#include "java_string_literals.h"
22+
#include "java_utils.h"
2323

2424
class java_object_factoryt
2525
{
@@ -442,13 +442,8 @@ void initialize_nondet_string_fields(
442442

443443
/// \todo Refactor with make_nondet_string_expr
444444
// length_expr = nondet(int);
445-
const symbolt length_sym = get_fresh_aux_symbol(
446-
java_int_type(),
447-
id2string(function_id),
448-
"tmp_object_factory",
449-
loc,
450-
ID_java,
451-
symbol_table);
445+
const symbolt length_sym = fresh_java_symbol(
446+
java_int_type(), "tmp_object_factory", loc, function_id, symbol_table);
452447
const symbol_exprt length_expr = length_sym.symbol_expr();
453448
const side_effect_expr_nondett nondet_length(length_expr.type(), loc);
454449
code.add(code_declt(length_expr));
@@ -476,18 +471,18 @@ void initialize_nondet_string_fields(
476471
index_exprt(data_expr, from_integer(0, java_int_type())));
477472

478473
add_pointer_to_array_association(
479-
array_pointer, data_expr, symbol_table, loc, code);
474+
array_pointer, data_expr, symbol_table, loc, function_id, code);
480475

481476
add_array_to_length_association(
482-
data_expr, length_expr, symbol_table, loc, code);
477+
data_expr, length_expr, symbol_table, loc, function_id, code);
483478

484479
struct_expr.operands()[struct_type.component_number("data")] = array_pointer;
485480

486481
// Printable ASCII characters are between ' ' and '~'.
487482
if(printable)
488483
{
489484
add_character_set_constraint(
490-
array_pointer, length_expr, " -~", symbol_table, loc, code);
485+
array_pointer, length_expr, " -~", symbol_table, loc, function_id, code);
491486
}
492487
}
493488

@@ -745,12 +740,11 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
745740
size_t depth,
746741
const source_locationt &location)
747742
{
748-
symbolt new_symbol = get_fresh_aux_symbol(
743+
symbolt new_symbol = fresh_java_symbol(
749744
replacement_pointer,
750-
id2string(object_factory_parameters.function_id),
751745
"tmp_object_factory",
752-
loc,
753-
ID_java,
746+
location,
747+
object_factory_parameters.function_id,
754748
symbol_table);
755749

756750
// Generate a new object into this new symbol

0 commit comments

Comments
 (0)