Skip to content

Commit a0e5510

Browse files
mgudemannDaniel Kroening
authored andcommitted
Peter's comments
1 parent f73048f commit a0e5510

8 files changed

+38
-27
lines changed

src/java_bytecode/expr2java.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ std::string expr2javat::convert_code_function_call(
5050
unsigned p;
5151
std::string lhs_str=convert(src.lhs(), p);
5252

53-
// TODO: ggf. Klammern je nach p
53+
// TODO: if necessery add parentheses, dependent on p
5454
dest+=lhs_str;
5555
dest+='=';
5656
}

src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ codet java_bytecode_convert_methodt::get_array_bounds_check(
425425
bounds_checks.operands().back().add_source_location()
426426
.set_comment("Array index < 0");
427427
bounds_checks.operands().back().add_source_location()
428-
.set_property_class("array-index-oob-low");
428+
.set_property_class("array-index-out-of-bounds-low");
429429
bounds_checks.add(code_assertt(ltlength));
430430

431431
bounds_checks.operands().back().add_source_location()=original_sloc;
432432
bounds_checks.operands().back().add_source_location()
433433
.set_comment("Array index >= length");
434434
bounds_checks.operands().back().add_source_location()
435-
.set_property_class("array-index-oob-high");
435+
.set_property_class("array-index-out-of-bounds-high");
436436

437437
// TODO make this throw ArrayIndexOutOfBoundsException instead of asserting.
438438
return bounds_checks;
@@ -795,9 +795,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
795795
if(i_it->statement=="jsr" ||
796796
i_it->statement=="jsr_w")
797797
{
798-
instructionst::const_iterator next=i_it;
798+
instructionst::const_iterator next=i_it+1;
799799
assert(
800-
++next!=instructions.end() &&
800+
next!=instructions.end() &&
801801
"jsr without valid return address?");
802802
targets.insert(next->address);
803803
jsr_ret_targets.push_back(next->address);
@@ -1750,7 +1750,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17501750
if(!disable_runtime_checks)
17511751
{
17521752
// TODO make this throw NegativeArrayIndexException instead.
1753-
constant_exprt intzero=as_number(0, java_int_type());
1753+
constant_exprt intzero=from_integer(0, java_int_type());
17541754
binary_relation_exprt gezero(op[0], ID_ge, intzero);
17551755
code_assertt check(gezero);
17561756
check.add_source_location().set_comment("Array size < 0");
@@ -1761,7 +1761,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17611761
if(max_array_length!=0)
17621762
{
17631763
constant_exprt size_limit=
1764-
as_number(max_array_length, java_int_type());
1764+
from_integer(max_array_length, java_int_type());
17651765
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
17661766
code_assumet assume_le_max_size(le_max_size);
17671767
checkandcreate.move_to_operands(assume_le_max_size);

src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class java_bytecode_convert_methodt:public messaget
5151
protected:
5252
symbol_tablet &symbol_table;
5353
const bool disable_runtime_checks;
54-
size_t max_array_length;
54+
const size_t max_array_length;
5555

5656
irep_idt method_id;
5757
irep_idt current_method;

src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,11 +1455,11 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
14551455
sourcefile_name=pool_entry(sourcefile_index).s;
14561456
else
14571457
{
1458-
std::string packageName=fqn.substr(0, last_index+1);
1459-
std::replace(packageName.begin(), packageName.end(), '.', '/');
1460-
const std::string
1461-
&fullFileName=(packageName+id2string(pool_entry(sourcefile_index).s));
1462-
sourcefile_name=fullFileName;
1458+
std::string package_name=fqn.substr(0, last_index+1);
1459+
std::replace(package_name.begin(), package_name.end(), '.', '/');
1460+
const std::string &full_file_name=
1461+
package_name+id2string(pool_entry(sourcefile_index).s);
1462+
sourcefile_name=full_file_name;
14631463
}
14641464

14651465
for(methodst::iterator m_it=parsed_class.methods.begin();

src/java_bytecode/java_entry_point.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ bool java_static_lifetime_init(
105105
symbolt &initialize_symbol=symbol_table.lookup(INITIALIZE);
106106
code_blockt &code_block=to_code_block(to_code(initialize_symbol.value));
107107

108-
// W need to zero out all static variables, or nondet-initialize if they're
108+
// We need to zero out all static variables, or nondet-initialize if they're
109109
// external. Iterate over a copy of the symtab, as its iterators are
110110
// invalidated by object_factory:
111111

112112
std::list<irep_idt> symnames;
113-
for(const auto& entry : symbol_table.symbols)
113+
for(const auto &entry : symbol_table.symbols)
114114
symnames.push_back(entry.first);
115115

116116
for(const auto& symname : symnames)

src/java_bytecode/java_object_factory.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,30 @@ class java_object_factoryt:public messaget
8181
const typet &override_type=empty_typet());
8282
};
8383

84-
// Returns false if we can't figure out the size of allocate_type.
85-
// allocate_type may differ from target_expr, e.g. for target_expr having
86-
// type int* and allocate_type being an int[10].
84+
85+
/*******************************************************************\
86+
87+
Function: gen_nondet_array_init
88+
89+
Inputs: the target expression, desired object type, source location
90+
and Boolean whether to create a dynamic object
91+
92+
Outputs: the allocated object
93+
94+
Purpose: Returns false if we can't figure out the size of allocate_type.
95+
allocate_type may differ from target_expr, e.g. for target_expr
96+
having type int* and allocate_type being an int[10].
97+
98+
\*******************************************************************/
99+
87100
exprt java_object_factoryt::allocate_object(
88-
const exprt& target_expr,
89-
const typet& allocate_type,
101+
const exprt &target_expr,
102+
const typet &allocate_type,
90103
const source_locationt &loc,
91104
bool create_dynamic_objects)
92105
{
93-
const typet& allocate_type_resolved=ns.follow(allocate_type);
94-
const typet& target_type=ns.follow(target_expr.type().subtype());
106+
const typet &allocate_type_resolved=ns.follow(allocate_type);
107+
const typet &target_type=ns.follow(target_expr.type().subtype());
95108
bool cast_needed=allocate_type_resolved!=target_type;
96109
if(!create_dynamic_objects)
97110
{
@@ -197,7 +210,7 @@ void java_object_factoryt::gen_nondet_init(
197210
if(!assume_non_null)
198211
{
199212
auto returns_null_sym=
200-
new_tmp_symbol(symbol_table, "opaque_returns_null");
213+
new_tmp_symbol(symbol_table, "opaque_returns_null");
201214
returns_null_sym.type=c_bool_typet(1);
202215
auto returns_null=returns_null_sym.symbol_expr();
203216
auto assign_returns_null=
@@ -449,7 +462,6 @@ void java_object_factoryt::gen_nondet_array_init(
449462
init_code.move_to_operands(init_done_label);
450463
}
451464

452-
453465
/*******************************************************************\
454466
455467
Function: gen_nondet_init
@@ -502,7 +514,7 @@ Function: new_tmp_symbol
502514

503515
symbolt &new_tmp_symbol(symbol_tablet &symbol_table, const std::string& prefix)
504516
{
505-
static size_t temporary_counter=0;
517+
static size_t temporary_counter=0; // TODO change this
506518

507519
auxiliary_symbolt new_symbol;
508520
symbolt *symbol_ptr;

src/java_bytecode/java_pointer_casts.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Function: find_superclass_with_type
4444
4545
\*******************************************************************/
4646

47-
4847
bool find_superclass_with_type(
4948
exprt &ptr,
5049
const typet &target_type,

src/util/json_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ json_objectt json(
265265
if(expr.get(ID_value)==ID_NULL)
266266
result["data"]=json_stringt("NULL");
267267
}
268-
else if(type.id()==ID_bool || type.id()==ID_c_bool)
268+
else if(type.id()==ID_bool)
269269
{
270270
result["name"]=json_stringt("boolean");
271271
result["binary"]=json_stringt(expr.is_true()?"1":"0");

0 commit comments

Comments
 (0)