Skip to content

Commit 641a557

Browse files
authored
Merge pull request #3246 from danpoe/fixes/rename-max-nonnull-tree-depth
Fix misleading struct member name in Java object factory
2 parents 992bd3a + fac1ad8 commit 641a557

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

jbmc/src/java_bytecode/convert_java_nondet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static std::pair<goto_programt::targett, bool> insert_nondet_init_code(
100100
const auto &nondet_expr = to_side_effect_expr_nondet(op);
101101

102102
if(!nondet_expr.get_nullable())
103-
object_factory_parameters.max_nonnull_tree_depth = 1;
103+
object_factory_parameters.min_null_tree_depth = 1;
104104

105105
const source_locationt &source_loc = target->source_location;
106106

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static void java_static_lifetime_init(
219219

220220
object_factory_parameterst parameters = object_factory_parameters;
221221
if(not_allow_null && !is_class_model)
222-
parameters.max_nonnull_tree_depth = 1;
222+
parameters.min_null_tree_depth = 1;
223223

224224
gen_nondet_init(
225225
sym.symbol_expr(),
@@ -309,10 +309,10 @@ exprt::operandst java_build_arguments(
309309
object_factory_parameterst parameters = object_factory_parameters;
310310
// only pointer must be non-null
311311
if(assume_init_pointers_not_null || is_this)
312-
parameters.max_nonnull_tree_depth = 1;
312+
parameters.min_null_tree_depth = 1;
313313
// in main() also the array elements of the argument must be non-null
314314
if(is_main)
315-
parameters.max_nonnull_tree_depth = 2;
315+
parameters.min_null_tree_depth = 2;
316316

317317
parameters.function_id = goto_functionst::entry_point();
318318

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
860860

861861
auto set_null_inst=get_null_assignment(expr, pointer_type);
862862

863-
const bool allow_null =
864-
depth > object_factory_parameters.max_nonnull_tree_depth;
863+
const bool allow_null = depth > object_factory_parameters.min_null_tree_depth;
865864

866865
if(must_be_null)
867866
{

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,10 @@ static void clinit_wrapper_do_recursive_calls(
248248
const symbol_exprt new_global_symbol =
249249
symbol_table.lookup_ref(id).symbol_expr();
250250

251-
parameters.max_nonnull_tree_depth =
251+
parameters.min_null_tree_depth =
252252
is_non_null_library_global(id)
253-
? std::max(
254-
size_t(1), object_factory_parameters.max_nonnull_tree_depth)
255-
: object_factory_parameters.max_nonnull_tree_depth;
253+
? std::max(size_t(1), object_factory_parameters.min_null_tree_depth)
254+
: object_factory_parameters.min_null_tree_depth;
256255

257256
gen_nondet_init(
258257
new_global_symbol,
@@ -872,10 +871,10 @@ codet stub_global_initializer_factoryt::get_stub_initializer_body(
872871
const symbol_exprt new_global_symbol =
873872
symbol_table.lookup_ref(it->second).symbol_expr();
874873

875-
parameters.max_nonnull_tree_depth =
874+
parameters.min_null_tree_depth =
876875
is_non_null_library_global(it->second)
877-
? object_factory_parameters.max_nonnull_tree_depth + 1
878-
: object_factory_parameters.max_nonnull_tree_depth;
876+
? object_factory_parameters.min_null_tree_depth + 1
877+
: object_factory_parameters.min_null_tree_depth;
879878

880879
source_locationt location;
881880
location.set_function(function_id);

jbmc/src/java_bytecode/object_factory_parameters.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class optionst;
2121
#define MAX_NONDET_STRING_LENGTH \
2222
static_cast<std::size_t>(std::numeric_limits<std::int32_t>::max())
2323
#define MAX_NONDET_TREE_DEPTH 5
24-
#define MAX_NONNULL_TREE_DEPTH 0
24+
#define MIN_NULL_TREE_DEPTH 0
2525

2626
struct object_factory_parameterst final
2727
{
@@ -45,14 +45,14 @@ struct object_factory_parameterst final
4545
/// To force a certain depth of non-null objects.
4646
/// The default is that objects are 'maybe null' up to the nondet tree depth.
4747
/// Examples:
48-
/// * max_nondet_tree_depth=0, max_nonnull_tree_depth irrelevant
48+
/// * max_nondet_tree_depth=0, min_null_tree_depth irrelevant
4949
/// pointer initialized to null
50-
/// * max_nondet_tree_depth=n, max_nonnull_tree_depth=0
50+
/// * max_nondet_tree_depth=n, min_null_tree_depth=0
5151
/// pointer and children up to depth n maybe-null, beyond n null
52-
/// * max_nondet_tree_depth=n >=m, max_nonnull_tree_depth=m
52+
/// * max_nondet_tree_depth=n >=m, min_null_tree_depth=m
5353
/// pointer and children up to depth m initialized to non-null,
5454
/// children up to n maybe-null, beyond n null
55-
size_t max_nonnull_tree_depth = MAX_NONNULL_TREE_DEPTH;
55+
size_t min_null_tree_depth = MIN_NULL_TREE_DEPTH;
5656

5757
/// Force string content to be ASCII printable characters when set to true.
5858
bool string_printable = false;

jbmc/src/java_bytecode/simple_method_stubbing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void java_simple_method_stubst::create_method_stub_at(
110110

111111
object_factory_parameterst parameters = object_factory_parameters;
112112
if(assume_non_null)
113-
parameters.max_nonnull_tree_depth = 1;
113+
parameters.min_null_tree_depth = 1;
114114

115115
// Generate new instructions.
116116
code_blockt new_instructions;
@@ -198,7 +198,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
198198
{
199199
object_factory_parameterst parameters = object_factory_parameters;
200200
if(assume_non_null)
201-
parameters.max_nonnull_tree_depth = 1;
201+
parameters.min_null_tree_depth = 1;
202202

203203
gen_nondet_init(
204204
to_return,

0 commit comments

Comments
 (0)