Skip to content

Conversation

thomasspriggs
Copy link
Contributor

@thomasspriggs thomasspriggs commented Jun 30, 2019

Whilst working on entry point code, I noticed the construction of codets based on ID_input and ID_output using direct manipulation of the .operands(). I also found an absence of documentation as to what these were. This PR adds a higher level interface and documentation for these.

  • 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/ N/A - No feature or user visible behaviour changes.
  • 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.

Copy link
Contributor

@allredj allredj left a 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: d7ee16b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/117569411

@codecov-io
Copy link

Codecov Report

Merging #4855 into develop will decrease coverage by <.01%.
The diff coverage is 87.75%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4855      +/-   ##
===========================================
- Coverage    69.06%   69.06%   -0.01%     
===========================================
  Files         1297     1294       -3     
  Lines       106819   106698     -121     
===========================================
- Hits         73779    73688      -91     
+ Misses       33040    33010      -30
Impacted Files Coverage Δ
jbmc/src/java_bytecode/java_entry_point.h 100% <ø> (ø) ⬆️
src/goto-programs/interpreter.cpp 0% <0%> (ø) ⬆️
src/pointer-analysis/value_set_fi.cpp 58.42% <100%> (ø) ⬆️
src/pointer-analysis/value_set.cpp 74.74% <100%> (ø) ⬆️
src/util/allocate_objects.cpp 90.19% <100%> (-0.55%) ⬇️
src/ansi-c/expr2c.cpp 67.13% <100%> (ø) ⬆️
src/util/std_code.h 91.11% <100%> (+0.09%) ⬆️
jbmc/src/java_bytecode/java_entry_point.cpp 87.68% <100%> (-0.96%) ⬇️
src/goto-symex/symex_other.cpp 81.63% <100%> (ø) ⬆️
src/ansi-c/ansi_c_entry_point.cpp 87.41% <100%> (-0.75%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1f0dc7...a61789d. Read the comment docs.

Copy link
Contributor

@allredj allredj left a 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: a61789d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/117807593


code_inputt::code_inputt(
const irep_idt &identifier,
exprt expression,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identifier usually is an index into the symbol table for us -- how about making that "description"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, I will update this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

std::move(location)}
{
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd that you have to choose between multiple inputs in a vector with no description and one input with a description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor which takes one input with a description is a convenient interface for use in the construction of cprover_start inside cbmc/jbmc. Its existence means that we can reduce the amount of duplication in the code which produces the various different versions of cprover_start.

The constructor which takes multiple inputs in a vector is required in order to support arbitrary calls to __CPROVER_input in user code. The definition in cprover.h is void __CPROVER_input(const char *description, ...);. This would allow the first parameter to be any pointer to char, rather than a string literal only. The ... would allow any number of expressions to be associated with the description, rather than a single expression only. The existing invariants only constrain the ... to correspond to at least one expression. Therefore this additional constructor cannot be removed without further constraining what user code is considered valid. My intention was to create a higher level internal interface, rather than make externally facing changes to existing functionality.

Is my explanation of this aspect sufficient, or do you want me to make further changes to the code in the PR - such documenting the purposes of the two constructors?

void __CPROVER_input(const char *id, ...);
void __CPROVER_output(const char *id, ...);
void __CPROVER_input(const char *description, ...);
void __CPROVER_output(const char *description, ...);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a nuisance, but you'll need to add // NOLINTNEXTLINE(build/deprecated) before each of the above lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// can be added to the input code in order add instructions of this type to the
/// goto program.
/// The first argument is expected to be a C string denoting the input
/// identifier. The second argument is the expression for the input value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line with the discussion with @kroening above: I think you will need to provide this kind of documentation for each of the constructors. It's really no clear how the above maps to the two, very different constructors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. It wasn't clear to me what change @kroening wanted. I will add doxygen for each of the constructors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added doxygen for each of the constructors.

This commit adds a higher level interface for `ID_input` based ireps.
This gives us a central place to document instances of these and a
central place to put the code for constructing and checking them. This
makes it possible to find documentation about them and avoids
duplicating the code for constructing and checking them.
This commit adds a higher level interface for `ID_output` based ireps.
This gives us a central place to document instances of these and a
central place to put the code for constructing and checking them. This
makes it possible to find documentation about them and avoids
duplicating the code for constructing and checking them.
@thomasspriggs thomasspriggs merged commit 7051df5 into diffblue:develop Jul 8, 2019
@thomasspriggs thomasspriggs deleted the tas/iot branch July 8, 2019 14:11
Copy link
Contributor

@allredj allredj left a 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: 0617618).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/118285644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants