-
Notifications
You must be signed in to change notification settings - Fork 273
[SV-COMP'18 7/19] Ensure that local declarations do not introduce spurious dead warnings #1996
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
int main() | ||
{ | ||
int *p = 0; | ||
|
||
for(int i = 0; i < 3; ++i) | ||
{ | ||
{ | ||
int x = 42; | ||
p = &x; | ||
*p = 1; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--pointer-check | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1666,6 +1666,34 @@ void goto_checkt::goto_check( | |
} | ||
} | ||
} | ||
else if(i.is_decl()) | ||
{ | ||
if(enable_pointer_check) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am unfamiliar with this code so non-blocking (I don't understand why dead statements need this instrumentation), but some documentation of why a deceleration statement needs to be instrumented when |
||
{ | ||
assert(i.code.operands().size()==1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const symbol_exprt &variable=to_symbol_expr(i.code.op0()); | ||
|
||
// is it dirty? | ||
if(local_bitvector_analysis->dirty(variable)) | ||
{ | ||
// reset the dead marker | ||
goto_programt::targett t=new_code.add_instruction(ASSIGN); | ||
exprt address_of_expr=address_of_exprt(variable); | ||
exprt lhs=ns.lookup(CPROVER_PREFIX "dead_object").symbol_expr(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignorant of this code, is this somehow the point where the variable that's declared goes out of scope? If you do pull out the "dead_object" string, it'd be great to document there what this variable is. |
||
if(!base_type_eq(lhs.type(), address_of_expr.type(), ns)) | ||
address_of_expr.make_typecast(lhs.type()); | ||
exprt rhs= | ||
if_exprt( | ||
equal_exprt(lhs, address_of_expr), | ||
null_pointer_exprt(to_pointer_type(address_of_expr.type())), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be clearer to use |
||
lhs, | ||
lhs.type()); | ||
t->source_location=i.source_location; | ||
t->code=code_assignt(lhs, rhs); | ||
t->code.add_source_location()=i.source_location; | ||
} | ||
} | ||
} | ||
else if(i.is_end_function()) | ||
{ | ||
if(i.function==goto_functionst::entry_point() && | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,11 +72,8 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr) | |
state.propagation.remove(l1_identifier); | ||
|
||
// L2 renaming | ||
// inlining may yield multiple declarations of the same identifier | ||
// within the same L1 context | ||
if(state.level2.current_names.find(l1_identifier)== | ||
state.level2.current_names.end()) | ||
state.level2.current_names[l1_identifier]=std::make_pair(ssa, 0); | ||
state.level2.current_names.insert( | ||
std::make_pair(l1_identifier, std::make_pair(ssa, 0))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: might as well emplace, rather than make pair then insert |
||
state.level2.increase_counter(l1_identifier); | ||
const bool record_events=state.record_events; | ||
state.record_events=false; | ||
|
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.
Add an extra no-match line for the particular warning you were seeing?