File tree 5 files changed +38
-0
lines changed
java_bytecode/java_static_initializers
5 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,14 @@ bool is_clinit_wrapper_function(const irep_idt &function_id)
80
80
return has_suffix (id2string (function_id), clinit_wrapper_suffix);
81
81
}
82
82
83
+ // / Check if function_id is a clinit
84
+ // / \param function_id: some function identifier
85
+ // / \return true if the passed identifier is a clinit
86
+ bool is_clinit_function (const irep_idt &function_id)
87
+ {
88
+ return has_suffix (id2string (function_id), clinit_function_suffix);
89
+ }
90
+
83
91
// / Add a new symbol to the symbol table.
84
92
// / Note: assumes that a symbol with this name does not exist.
85
93
// / /param name: name of the symbol to be generated
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ irep_idt clinit_wrapper_name(const irep_idt &class_name);
25
25
irep_idt user_specified_clinit_name (const irep_idt &class_name);
26
26
27
27
bool is_clinit_wrapper_function (const irep_idt &function_id);
28
+ bool is_clinit_function (const irep_idt &function_id);
28
29
29
30
void create_static_initializer_symbols (
30
31
symbol_tablet &symbol_table,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ SRC += java_bytecode/ci_lazy_methods/lazy_load_lambdas.cpp \
47
47
java_bytecode/java_object_factory/gen_nondet_string_init.cpp \
48
48
java_bytecode/java_object_factory/struct_tag_types.cpp \
49
49
java_bytecode/java_replace_nondet/replace_nondet.cpp \
50
+ java_bytecode/java_static_initializers/java_static_initializers.cpp \
50
51
java_bytecode/java_string_library_preprocess/convert_exprt_to_string_exprt.cpp \
51
52
java_bytecode/java_types/erase_type_arguments.cpp \
52
53
java_bytecode/java_types/generic_type_index.cpp \
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: Unit tests for java_types
4
+
5
+ Author: Diffblue Ltd.
6
+
7
+ \*******************************************************************/
8
+
9
+ #include < java_bytecode/java_static_initializers.h>
10
+ #include < testing-utils/use_catch.h>
11
+
12
+ SCENARIO (" is_clinit_function" , " [core][java_static_initializers]" )
13
+ {
14
+ GIVEN (" A function id that represents a clinit" )
15
+ THEN (" is_clinit_function should return true." )
16
+ {
17
+ const std::string input = " com.something.package.TestClass.<clinit>:()V" ;
18
+ REQUIRE (is_clinit_function (input));
19
+ }
20
+ GIVEN (" A function id that does not represent a clinit" )
21
+ THEN (" is_clinit_function should return false." )
22
+ {
23
+ const std::string input = " com.something.package.TestClass.<notclinit>:()V" ;
24
+ REQUIRE_FALSE (is_clinit_function (input));
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ java_bytecode
2
+ testing-utils
You can’t perform that action at this time.
0 commit comments