@@ -7,6 +7,7 @@ Author: Daniel Kroening, kroening@kroening.com
77\*******************************************************************/
88
99#include < util/message.h>
10+ #include < util/suffix.h>
1011#include < util/string2int.h>
1112
1213#include " remove_static_init_loops.h"
@@ -56,6 +57,10 @@ void remove_static_init_loopst::unwind_enum_static(
5657 const std::string java_clinit=" <clinit>:()V" ;
5758 const std::string &fname=id2string (ins.function );
5859 size_t class_prefix_length=fname.find_last_of (' .' );
60+ // is Java function and static init?
61+ const symbolt &function_name=symbol_table.lookup (ins.function );
62+ if (!(function_name.mode ==ID_java && has_suffix (fname, java_clinit)))
63+ continue ;
5964 assert (
6065 class_prefix_length!=std::string::npos &&
6166 " could not identify class name" );
@@ -65,23 +70,16 @@ void remove_static_init_loopst::unwind_enum_static(
6570 size_t unwinds=class_type.get_size_t (ID_java_enum_static_unwind);
6671
6772 unwind_max=std::max (unwind_max, unwinds);
68- if (fname. length ()>java_clinit. length () )
73+ if (unwinds> 0 )
6974 {
70- // extend unwindset with unwinds for <clinit> of enum
71- if (fname.compare (
72- fname.length ()-java_clinit.length (),
73- java_clinit.length (),
74- java_clinit)==0 && unwinds>0 )
75- {
76- const std::string &set=options.get_option (" unwindset" );
77- std::string newset;
78- if (set!=" " )
79- newset=" ," ;
80- newset+=
81- id2string (ins.function )+" ." +std::to_string (loop_id)+" :" +
82- std::to_string (unwinds);
83- options.set_option (" unwindset" , set+newset);
84- }
75+ const std::string &set=options.get_option (" unwindset" );
76+ std::string newset;
77+ if (set!=" " )
78+ newset=" ," ;
79+ newset+=
80+ id2string (ins.function )+" ." +std::to_string (loop_id)+" :" +
81+ std::to_string (unwinds);
82+ options.set_option (" unwindset" , set+newset);
8583 }
8684 }
8785 }
0 commit comments