-
Notifications
You must be signed in to change notification settings - Fork 277
Output C code from harness generation tool. #5343
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
Output C code from harness generation tool. #5343
Conversation
NlightNFotis
commented
May 14, 2020
- Each commit message has a non-empty body, explaining why the change was made.
- Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
- The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
- Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
- My commit message includes data points confirming performance improvements (if claimed).
- My PR is restricted to a single feature or bugfix.
- White-space or formatting changes outside the feature-related changed lines are in commits of their own.
@@ -3,7 +3,7 @@ | |||
unsigned int x; | |||
unsigned int y; | |||
|
|||
unsigned int nondet_int() | |||
unsigned int some_random_unsigned_integer() |
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 was changed because of a dump_c()
bug; It assumes that nondet_*
names are available with specific meanings.
@@ -1,4 +1,4 @@ | |||
CORE | |||
KNOWNBUG |
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.
We can work around this for now by re-enabling the old behaviour for these, but we've marked them KNOWNBUG for now because we're first trying to get the call-function harness to behave like we want it to.
65b63fe
to
aa7d1d9
Compare
../ansi-c/ansi-c$(LIBEXT) \ | ||
../cpp/cpp$(LIBEXT) \ | ||
../goto-instrument/dump_c$(OBJEXT) \ | ||
../goto-instrument/goto_program2code$(OBJEXT) \ |
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.
these are all needed for dump_c
205327f
to
46f8a54
Compare
Previously the `dump-c` output of recursive initialisation wouldn't work with types that have nested const things in them, such as pointer-to-const or array with constant elements.
46f8a54
to
881125f
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5343 +/- ##
===========================================
- Coverage 68.16% 68.07% -0.10%
===========================================
Files 1170 1170
Lines 96441 96477 +36
===========================================
- Hits 65735 65672 -63
- Misses 30706 30805 +99
Continue to review full report at Codecov.
|
43e4a83
to
e5114db
Compare
The C output doesn't quite work with the snapshot harness at the moment (specifically, it doesn't work with the feature to restart analysis from a specific point in the program) so these test are marked as KNOWNBUG for now. Going forward we may re-enable these after fixing the feature, or possibly do without the restarting entirely.
Modify goto-harness to output C code that corresponds to the added harness functions and some global values. This has been a feature request.
e5114db
to
d404ae1
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.
LGTM
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.
Mostly looks OK, but a couple of queries I'd like answered if possible?
@@ -22,6 +22,7 @@ Author: Diffblue Ltd. | |||
#include "function_harness_generator_options.h" | |||
#include "goto_harness_generator.h" | |||
|
|||
#define GOTO_HARNESS_PREFIX "GOTO_HARNESS" |
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 would have thought that as this is an "implementation" prefix, it should be __GOTO_HARNESS
? (i.e. double underscore at the front) ?
@@ -28,3 +28,9 @@ void type_with_subtypest::move_to_subtypes(typet &type) | |||
sub.push_back(static_cast<const typet &>(get_nil_irep())); | |||
sub.back().swap(type); | |||
} | |||
|
|||
typet remove_const(typet type) |
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.
const argument? Or if this is modifying the argument, then why return ?
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.
It's returning a copy with the modification. If the argument was const we'd have to make two copies, if it was const reference we'd still have to make a copy so we don't gain anything in either case.
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.
OK, I like the const just to make it explicit - and of course depending on how much this is called, an extra copy probably isn't the end of the world... But its a nitpick really on my part.
@@ -224,4 +224,8 @@ inline type_with_subtypest &to_type_with_subtypes(typet &type) | |||
for(type_with_subtypest::subtypest::iterator it=to_type_with_subtypes(type).subtypes().begin(); \ | |||
it!=to_type_with_subtypes(type).subtypes().end(); ++it) | |||
|
|||
/// Remove const qualifier from type (if any). | |||
/// Returns type as is if there is no const qualifier. | |||
typet remove_const(typet type); |
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.
Yeah, I'm not sure why this is a member function rather than a static?
Before this change, we were using CPROVER_PREFIX, which was causing some symbols to be dropped before the C code output because of the prefix symbolising CProver internal values.
d404ae1
to
d8a9207
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.
LGTM
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.
Seems ok except the hundred or so tests that get marked KNOWNBUG here -- what was the memory-snapshot thingy that got trashed?
if(component.type().get_bool(ID_C_constant)) | ||
{ | ||
return dereference_exprt{ | ||
typecast_exprt{address_of_exprt{std::move(member_expr)}, |
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.
Comment that this pile of stuff amounts to *(X*)&field
, where field
has type const X*
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.
Also I take it you've tried using braced initialiser style for such things?
goto-instrument \ | ||
goto-harness \ |
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.
Sort order was correct before