Skip to content

Commit 44a788c

Browse files
author
Daniel Kroening
committed
preconditions that parameter identifiers must be set
This prevents the creation of symbol expressions that fail typechecking later.
1 parent 970cbc1 commit 44a788c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ code_blockt java_string_library_preprocesst::make_float_to_string_code(
954954
// Getting the argument
955955
java_method_typet::parameterst params = type.parameters();
956956
PRECONDITION(params.size()==1);
957+
PRECONDITION(!params[0].get_identifier().empty());
957958
const symbol_exprt arg(params[0].get_identifier(), params[0].type());
958959

959960
// Holder for output code
@@ -1097,6 +1098,7 @@ code_blockt java_string_library_preprocesst::make_init_function_from_call(
10971098

10981099
// The first parameter is the object to be initialized
10991100
PRECONDITION(!params.empty());
1101+
PRECONDITION(!params[0].get_identifier().empty());
11001102
const symbol_exprt arg_this(params[0].get_identifier(), params[0].type());
11011103
if(is_constructor)
11021104
params.erase(params.begin());
@@ -1137,6 +1139,7 @@ java_string_library_preprocesst::make_assign_and_return_function_from_call(
11371139
// This is similar to assign functions except we return a pointer to `this`
11381140
java_method_typet::parameterst params = type.parameters();
11391141
PRECONDITION(!params.empty());
1142+
PRECONDITION(!params[0].get_identifier().empty());
11401143
code_blockt code;
11411144
code.add(
11421145
make_assign_function_from_call(function_name, type, loc, symbol_table),
@@ -1507,6 +1510,8 @@ code_blockt java_string_library_preprocesst::make_object_get_class_code(
15071510
symbol_table_baset &symbol_table)
15081511
{
15091512
java_method_typet::parameterst params = type.parameters();
1513+
PRECONDITION(!params.empty());
1514+
PRECONDITION(!params[0].get_identifier().empty());
15101515
const symbol_exprt this_obj(params[0].get_identifier(), params[0].type());
15111516

15121517
// Code to be returned
@@ -1668,6 +1673,7 @@ code_blockt java_string_library_preprocesst::make_copy_string_code(
16681673

16691674
// Assign the argument to string_expr
16701675
java_method_typet::parametert op = type.parameters()[0];
1676+
PRECONDITION(!op.get_identifier().empty());
16711677
symbol_exprt arg0(op.get_identifier(), op.type());
16721678
code_assign_java_string_to_string_expr(
16731679
string_expr, arg0, loc, symbol_table, code);
@@ -1713,6 +1719,8 @@ code_blockt java_string_library_preprocesst::make_copy_constructor_code(
17131719

17141720
// Assign argument to a string_expr
17151721
java_method_typet::parameterst params = type.parameters();
1722+
PRECONDITION(!params[0].get_identifier().empty());
1723+
PRECONDITION(!params[1].get_identifier().empty());
17161724
symbol_exprt arg1(params[1].get_identifier(), params[1].type());
17171725
code_assign_java_string_to_string_expr(
17181726
string_expr, arg1, loc, symbol_table, code);
@@ -1747,6 +1755,7 @@ code_returnt java_string_library_preprocesst::make_string_length_code(
17471755
(void)function_id;
17481756

17491757
java_method_typet::parameterst params = type.parameters();
1758+
PRECONDITION(!params[0].get_identifier().empty());
17501759
symbol_exprt arg_this(params[0].get_identifier(), params[0].type());
17511760
dereference_exprt deref =
17521761
checked_dereference(arg_this, arg_this.type().subtype());

0 commit comments

Comments
 (0)