File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 21
21
#include " java_bytecode_typecheck.h"
22
22
#include " java_pointer_casts.h"
23
23
#include " java_types.h"
24
+ #include " java_utils.h"
24
25
25
26
void java_bytecode_typecheckt::typecheck_expr (exprt &expr)
26
27
{
@@ -101,8 +102,7 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr)
101
102
const irep_idt value=expr.get (ID_value);
102
103
const symbol_typet string_type (" java::java.lang.String" );
103
104
104
- std::string escaped_symbol_name=
105
- " java::java.lang.String.Literal." ;
105
+ std::string escaped_symbol_name=JAVA_STRING_LITERAL_PREFIX " ." ;
106
106
escaped_symbol_name+=escape_non_alnum (id2string (value));
107
107
108
108
auto findit=symbol_table.symbols .find (escaped_symbol_name);
Original file line number Diff line number Diff line change 31
31
#include " java_entry_point.h"
32
32
#include " java_object_factory.h"
33
33
#include " java_types.h"
34
+ #include " java_utils.h"
34
35
35
36
#define INITIALIZE CPROVER_PREFIX " initialize"
36
37
@@ -71,7 +72,7 @@ static bool should_init_symbol(const symbolt &sym)
71
72
sym.mode ==ID_java)
72
73
return true ;
73
74
74
- return has_prefix ( id2string ( sym.name ), " java::java.lang.String.Literal " );
75
+ return is_java_string_literal_id ( sym.name );
75
76
}
76
77
77
78
void java_static_lifetime_init (
@@ -102,14 +103,13 @@ void java_static_lifetime_init(
102
103
bool allow_null=!assume_init_pointers_not_null;
103
104
if (allow_null)
104
105
{
105
- std::string namestr=id2string (sym.symbol_expr ().get_identifier ());
106
+ irep_idt nameid=sym.symbol_expr ().get_identifier ();
107
+ std::string namestr=id2string (nameid);
106
108
const std::string suffix=" @class_model" ;
107
109
// Static '.class' fields are always non-null.
108
110
if (has_suffix (namestr, suffix))
109
111
allow_null=false ;
110
- if (allow_null && has_prefix (
111
- namestr,
112
- " java::java.lang.String.Literal" ))
112
+ if (allow_null && is_java_string_literal_id (nameid))
113
113
allow_null=false ;
114
114
}
115
115
auto newsym=object_factory (
Original file line number Diff line number Diff line change @@ -107,3 +107,8 @@ void merge_source_location_rec(
107
107
for (exprt &op : expr.operands ())
108
108
merge_source_location_rec (op, source_location);
109
109
}
110
+
111
+ bool is_java_string_literal_id (const irep_idt &id)
112
+ {
113
+ return has_prefix (id2string (id), JAVA_STRING_LITERAL_PREFIX);
114
+ }
Original file line number Diff line number Diff line change 9
9
10
10
#include < util/type.h>
11
11
#include < util/symbol_table.h>
12
+ #include < util/message.h>
12
13
13
14
#include " java_bytecode_parse_tree.h"
14
15
@@ -45,4 +46,10 @@ void merge_source_location_rec(
45
46
exprt &expr,
46
47
const source_locationt &source_location);
47
48
49
+ #define JAVA_STRING_LITERAL_PREFIX " java::java.lang.String.Literal"
50
+
51
+ // / \param id: any string
52
+ // / \return Returns true if 'id' identifies a string literal symbol
53
+ bool is_java_string_literal_id (const irep_idt &id);
54
+
48
55
#endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
You can’t perform that action at this time.
0 commit comments