-
Notifications
You must be signed in to change notification settings - Fork 273
[SV-COMP'18 12/19] SV-COMP graphml fixes [blocks: #3486] #2001
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
Conversation
src/ansi-c/expr2c.cpp
Outdated
@@ -699,6 +699,7 @@ std::string expr2ct::convert_struct_type( | |||
if(tag!="") | |||
dest+=" "+id2string(tag); | |||
|
|||
#if 0 |
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 comment explaining why?
std::string result; | ||
|
||
if(assign.rhs().id()==ID_array) | ||
if(assign.rhs().id()=="array-list") |
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.
Use ID, or add one if not already present
exprt clean_lhs=assign.lhs(); | ||
remove_l0_l1(clean_lhs); | ||
std::string lhs=from_expr(ns, identifier, clean_lhs); | ||
if(lhs.find("#return_value")!=std::string::npos || |
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.
Use ID
return false; | ||
} | ||
|
||
static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix){ |
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.
Use depth_begin
et al instead of recursing?
{ | ||
nodes.push_back(graphml.add_node()); | ||
graphml[nodes.back()].node_name="N" + std::to_string(i); | ||
graphml[nodes.back()].is_violation=(i==max_thread_idx+1U) ? true : 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.
I think that ternary conditional is redundant
graphml[nodes.back()].has_invariant=false; | ||
} | ||
|
||
for(auto it=nodes.cbegin(); std::next(it)!=nodes.cend(); ++it) |
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.
INVARIANT(!nodes.empty())
?
} | ||
else if( | ||
id2string(it->lhs_object.get_identifier()) | ||
.find("#return_value")==std::string::npos && |
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.
Several well-known identifiers to ID-ify here
@@ -300,33 +428,13 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) | |||
else if(it->type==goto_trace_stept::typet::GOTO && | |||
it->pc->is_goto()) | |||
{ | |||
#if 0 | |||
// TODO: this requires knowledge about the phase of the |
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.
Provide an issue reference?
src/util/std_pair_hash.h
Outdated
inline void hash_combine(std::size_t & seed, const T & v) | ||
{ | ||
std::hash<T> hasher; | ||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); |
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.
Provide a reference for the particular source of magic numbers?
c472d62
to
daa0dd8
Compare
daa0dd8
to
917e11e
Compare
917e11e
to
dc199a9
Compare
This PR is now actually ready for review. We certainly have a lot of problems left to resolve, but that would at least get develop to have the GraphML witness code that we've been using in SV-COMP the last years. |
4fa3782
to
c958e2a
Compare
ace5f4f
to
808a00e
Compare
src/ansi-c/expr2c.cpp
Outdated
@@ -1866,6 +1869,27 @@ std::string expr2ct::convert_constant( | |||
else if(dest=="-NaN") | |||
dest="-NAN"; | |||
} | |||
else if(dest.size() == 4 && (dest[0] == '+' || dest[0] == '-')) |
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.
Combine this and the case above to remove the redundant expression dest.size() == 4 && (dest[0] == '+' || dest[0] == '-')
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.
I was trying to keep the diff smaller, but will now do as suggested.
namespace std // NOLINT(readability/namespace) | ||
{ | ||
template <typename S, typename T> | ||
struct hash<pair<S, T>> // NOLINT(readability/identifiers) |
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.
Surely this belongs in util somewhere
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.
Well, it has this single user...
std::string graphml_witnesst::convert_assign_rec( | ||
const irep_idt &identifier, | ||
const code_assignt &assign) | ||
{ | ||
static std:: |
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.
Quite surprised the lifetime of this cache isn't tied to that of some class, rather than living as long as the process
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.
I'll make it a class member.
graphml[*it].out[*std::next(it)].xml_node = edge; | ||
} | ||
|
||
// we do not provide any further details as CPAchecker does not seem to |
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.
Perhaps link to some appropriate issue or discussion thread?
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.
A link to furious discussions at the SV-COMP meeting in Thessaloniki? :-) Or maybe sosy-lab/sv-witnesses#12?
808a00e
to
ee2c68b
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: ee2c68b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105821202
See https://github.com/sosy-lab/sv-witnesses for the most up-to-date format specification.
https://github.com/sosy-lab/sv-witnesses documents a "control" node, and examples still include "sourcecode" nodes, but there neither is documented semantics for "control" nodes nor is it clear whether the "sourcecode" node is used by any tool.
The witness format documentation only states "Nodes where this flag is set must not have any leaving transitions" for sink nodes, but quite possibly validators expect the same for violation nodes.
NULL, NAN, INFINITY are not a keywords, just macros. Do not use them for output under the "clean" configuration.
Witness validators expect syntactically correct C code, not human-friendly pseudo-C.
Witness validators expect syntactically correct C code, and cannot cope with SSA suffixes.
The witness specification permits use of \result in assumptions (in violation witnesses), but then also requires setting assumption.resultfunction.
We must not filter out generated assertions for memory leaks.
Witness validators cannot handle array lists.
These symbols do not occur in the input program.
Witness validators cannot be expected to understand CBMC's "with" expressions. Fixes: diffblue#4486
It's actually not clear whether this is necessary or permitted, it's not contained in the official specification.
Expression-to-string conversion is costly.
This does likely need more work, but at least got us some points in the past.
We would previously use the name of the calling function. Instead, parameter assignments require a special case. Regression test kindly provided by @JanSvejda. Fixes: diffblue#4418
ee2c68b
to
16a59aa
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 16a59aa).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107154317
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
Do not merge as-is: this needs cleanup of patches and of the changes to
expr2ct
.