Skip to content

Allow function pointer arguments to be equal #5171

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
merged 3 commits into from
Jan 27, 2020

Conversation

xbauch
Copy link
Contributor

@xbauch xbauch commented Nov 4, 2019

for the function-call goto-harness.

We add a new command-line option treat-pointers-equal that takes a list of
formal parameter names and results in a harness that only generates constructor
for one of the pointers. The other pointers are simply assigned with the
constructed one.

  • 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.

for the function-call goto-harness.

We add a new command-line option `treat-pointers-equal` that takes a list of
formal parameter names and results in a harness that only generates constructor
for one of the pointers. The other pointers are simply assigned with the
constructed one.
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: 9db8bd4).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/134853929

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

This is currently only capable of expressing that a single set of function params should be treated equal, I'd like this to be able to specify multiple (non-overlapping I'd hope?) sets of possibly equal pointers.

Also, these should be maybe equal, but as currently specified they'll definitely be equal, which is a bit unfortunate (as now we won't be covering the case where they're not equal, we'd have to generate a different harness for these again).


bool recursive_initializationt::needs_freeing(const exprt &expr) const
{
if(expr.type().id() != ID_pointer)

Choose a reason for hiding this comment

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

Function pointers also shouldn't be freed but we're already fixing this in a follow up PR

Specified by a semi-colon separated list of comma separated names.
@codecov-io
Copy link

codecov-io commented Nov 13, 2019

Codecov Report

Merging #5171 into develop will increase coverage by 0.01%.
The diff coverage is 89.7%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5171      +/-   ##
===========================================
+ Coverage    67.32%   67.33%   +0.01%     
===========================================
  Files         1155     1155              
  Lines        94643    94708      +65     
===========================================
+ Hits         63715    63773      +58     
- Misses       30928    30935       +7
Flag Coverage Δ
#cproversmt2 42.64% <ø> (ø) ⬆️
#regression 63.82% <89.7%> (+0.01%) ⬆️
#unit 31.96% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/goto-harness/recursive_initialization.h 100% <ø> (ø) ⬆️
src/goto-harness/recursive_initialization.cpp 85.31% <100%> (+1.42%) ⬆️
...c/goto-harness/function_call_harness_generator.cpp 86.95% <80.55%> (-2.57%) ⬇️

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 cb20917...f95df53. Read the comment docs.

@xbauch
Copy link
Contributor Author

xbauch commented Nov 14, 2019

@hannes-steffenhagen-diffblue both sets of equal pointers and conditional equality should be implemented now.

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: dcf0ea3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/136572662

{
for(auto const &value : values)
{
for(auto const &param_cluster : split_string(value, ';'))

Choose a reason for hiding this comment

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

Super minor nitpick that ; might not necessarily be the best separator to use here because on most shells it’s also a terminator, but tbh I don’t think it’s big enough of a problem to worry about here.


bool recursive_initializationt::needs_freeing(const exprt &expr) const
{
if(expr.type().id() != ID_pointer || expr.type().id() == ID_code)

Choose a reason for hiding this comment

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

This could just be return expr.type().id() = ID_pointer && expr.type().id() != ID_code;

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.

@@ -280,6 +321,19 @@ bool recursive_initializationt::should_be_treated_as_array(
initialization_config.pointers_to_treat_as_arrays.end();
}

optionalt<std::size_t>

Choose a reason for hiding this comment

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

Small preference to have a (strong?) typedef for this size_t so we know that it refers to an “equal cluster”

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.

initialization_config.arguments_may_be_equal)
{
// in equality cluster but not common origin -> free if equal to origin
const auto condition =

Choose a reason for hiding this comment

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

I don’t quite understand the logic, shouldn’t it be the other way round (i.e. don’t free if not common origin, unless your value is different than origin)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Off by negation: good catch. Fixed.

@xbauch xbauch force-pushed the feature/function-harness-param-equal branch from 019194f to f95df53 Compare January 24, 2020 13:54
between pointer arguments. Whether or not they will be equal is now a
non-deterministic choice. Freeing pointer had to be extended.
@xbauch xbauch force-pushed the feature/function-harness-param-equal branch from f95df53 to 49b86dc Compare January 24, 2020 15:52
@xbauch xbauch merged commit 2400d10 into diffblue:develop Jan 27, 2020
NlightNFotis added a commit that referenced this pull request Jan 28, 2020
…ondet-harness

Function pointer non-det initialisation in goto-harness [depends-on: #5171]
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.

6 participants