-
Notifications
You must be signed in to change notification settings - Fork 273
ignore non-Java files in enum static init unwind #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kroening
merged 1 commit into
diffblue:master
from
mgudemann:fix_remove_static_init_non_java_functions
Feb 9, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
public enum enum1 | ||
{ | ||
VAL1, VAL2, VAL3, VAL4, VAL5; | ||
static | ||
{ | ||
for(enum1 e : enum1.values()) | ||
{ | ||
System.out.println(e); | ||
} | ||
} | ||
public static void main(String[] args) | ||
{ | ||
enum1 e=VAL5; | ||
assert(e==VAL5); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
enum1.class | ||
--java-unwind-enum-static --unwind 3 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^Unwinding loop java::enum1.<clinit>:()V.0 iteration 5 (6 max) file enum1.java line 6 function java::enum1.<clinit>:()V bytecode_index 78 thread 0$ | ||
-- | ||
^warning: ignoring |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ Author: Daniel Kroening, [email protected] | |
\*******************************************************************/ | ||
|
||
#include <util/message.h> | ||
#include <util/suffix.h> | ||
#include <util/string2int.h> | ||
|
||
#include "remove_static_init_loops.h" | ||
|
@@ -56,6 +57,10 @@ void remove_static_init_loopst::unwind_enum_static( | |
const std::string java_clinit="<clinit>:()V"; | ||
const std::string &fname=id2string(ins.function); | ||
size_t class_prefix_length=fname.find_last_of('.'); | ||
// is Java function and static init? | ||
const symbolt &function_name=symbol_table.lookup(ins.function); | ||
if(!(function_name.mode==ID_java && has_suffix(fname, java_clinit))) | ||
continue; | ||
assert( | ||
class_prefix_length!=std::string::npos && | ||
"could not identify class name"); | ||
|
@@ -65,23 +70,16 @@ void remove_static_init_loopst::unwind_enum_static( | |
size_t unwinds=class_type.get_size_t(ID_java_enum_static_unwind); | ||
|
||
unwind_max=std::max(unwind_max, unwinds); | ||
if(fname.length()>java_clinit.length()) | ||
if(unwinds>0) | ||
{ | ||
// extend unwindset with unwinds for <clinit> of enum | ||
if(fname.compare( | ||
fname.length()-java_clinit.length(), | ||
java_clinit.length(), | ||
java_clinit)==0 && unwinds>0) | ||
{ | ||
const std::string &set=options.get_option("unwindset"); | ||
std::string newset; | ||
if(set!="") | ||
newset=","; | ||
newset+= | ||
id2string(ins.function)+"."+std::to_string(loop_id)+":"+ | ||
std::to_string(unwinds); | ||
options.set_option("unwindset", set+newset); | ||
} | ||
const std::string &set=options.get_option("unwindset"); | ||
std::string newset; | ||
if(set!="") | ||
newset=","; | ||
newset+= | ||
id2string(ins.function)+"."+std::to_string(loop_id)+":"+ | ||
std::to_string(unwinds); | ||
options.set_option("unwindset", set+newset); | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment in https://github.com/diffblue/cbmc/blob/master/src/cbmc/cbmc_parse_options.cpp#L553 to make this side-effect more visible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a comment