Skip to content

Commit 7943595

Browse files
codebyzebromainbrenguier
authored andcommitted
Stop preprocessing String.equals
String.equals currently handled by CBMC, this removes support within CBMC so that String.equals will be handled by a model instead. CProverString.equals is provided by JBMC instead of String.equals.
1 parent 130f6f0 commit 7943595

File tree

2 files changed

+0
-81
lines changed

2 files changed

+0
-81
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -942,72 +942,6 @@ java_string_library_preprocesst::string_literal_to_string_expr(
942942
ID_cprover_string_literal_func, {expr}, loc, symbol_table, code);
943943
}
944944

945-
/// Used to provide code for the Java String.equals(Object) function.
946-
/// \param type: type of the function call
947-
/// \param loc: location in the program_invocation_name
948-
/// \param symbol_table: symbol table
949-
/// \param function_id: unused
950-
/// \return Code corresponding to:
951-
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
952-
/// IF arg->@class_identifier == "java.lang.String"
953-
/// THEN
954-
/// string_expr1 = {this->length; *this->data}
955-
/// string_expr2 = {arg->length; *arg->data}
956-
/// bool string_equals_tmp = cprover_string_equal(string_expr1, string_expr2)
957-
/// return string_equals_tmp
958-
/// ELSE
959-
/// return false
960-
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
961-
codet java_string_library_preprocesst::make_equals_function_code(
962-
const java_method_typet &type,
963-
const source_locationt &loc,
964-
const irep_idt &function_id,
965-
symbol_table_baset &symbol_table)
966-
{
967-
const typet &return_type = type.return_type();
968-
exprt::operandst ops;
969-
for(const auto &p : type.parameters())
970-
{
971-
symbol_exprt sym(p.get_identifier(), p.type());
972-
ops.push_back(sym);
973-
}
974-
975-
code_ifthenelset code;
976-
code.cond() = [&] {
977-
const member_exprt class_identifier(
978-
checked_dereference(ops[1], ops[1].type().subtype()),
979-
"@class_identifier",
980-
string_typet());
981-
return equal_exprt(
982-
class_identifier,
983-
constant_exprt("java::java.lang.String", string_typet()));
984-
}();
985-
986-
code.then_case() = [&] {
987-
code_blockt instance_case;
988-
// Check content equality
989-
const symbolt string_equals_sym = get_fresh_aux_symbol(
990-
return_type,
991-
id2string(function_id),
992-
"str_eq",
993-
loc,
994-
ID_java,
995-
symbol_table);
996-
const symbol_exprt string_equals = string_equals_sym.symbol_expr();
997-
instance_case.add(code_declt(string_equals), loc);
998-
const exprt::operandst args =
999-
process_equals_function_operands(ops, loc, symbol_table, instance_case);
1000-
const auto fun_app = make_function_application(
1001-
ID_cprover_string_equal_func, args, return_type, symbol_table);
1002-
instance_case.add(code_assignt(string_equals, fun_app), loc);
1003-
instance_case.add(code_returnt(string_equals), loc);
1004-
return instance_case;
1005-
}();
1006-
1007-
code.else_case() = code_returnt(from_integer(false, return_type));
1008-
return code;
1009-
}
1010-
1011945
/// Provide code for the String.valueOf(F) function.
1012946
/// \param type: type of the function call
1013947
/// \param loc: location in the program_invocation_name
@@ -2031,15 +1965,6 @@ void java_string_library_preprocesst::initialize_conversion_table()
20311965
cprover_equivalent_to_java_function
20321966
["java::java.lang.String.endsWith:(Ljava/lang/String;)Z"]=
20331967
ID_cprover_string_endswith_func;
2034-
2035-
conversion_table["java::java.lang.String.equals:(Ljava/lang/Object;)Z"] =
2036-
std::bind(
2037-
&java_string_library_preprocesst::make_equals_function_code,
2038-
this,
2039-
std::placeholders::_1,
2040-
std::placeholders::_2,
2041-
std::placeholders::_3,
2042-
std::placeholders::_4);
20431968
cprover_equivalent_to_java_function
20441969
["java::java.lang.String.equalsIgnoreCase:(Ljava/lang/String;)Z"]=
20451970
ID_cprover_string_equals_ignore_case_func;

jbmc/src/java_bytecode/java_string_library_preprocess.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ class java_string_library_preprocesst:public messaget
145145
// A set tells us what java types should be considered as string objects
146146
std::unordered_set<irep_idt> string_types;
147147

148-
codet make_equals_function_code(
149-
const java_method_typet &type,
150-
const source_locationt &loc,
151-
const irep_idt &function_id,
152-
symbol_table_baset &symbol_table);
153-
154148
codet make_float_to_string_code(
155149
const java_method_typet &type,
156150
const source_locationt &loc,

0 commit comments

Comments
 (0)