Skip to content

Support non-heap allocated flexible arrays #6661

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

Conversation

tautschnig
Copy link
Collaborator

This addresses an existing todo in the code base: we need to come up
with a new type based on the actual initializer.

Fixes: #3653

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig tautschnig self-assigned this Feb 11, 2022
@tautschnig tautschnig force-pushed the bugfixes/flexible-array-static branch from a31b08c to da76ab4 Compare February 14, 2022 11:10
@tautschnig tautschnig mentioned this pull request Feb 14, 2022
3 tasks
@codecov
Copy link

codecov bot commented Feb 14, 2022

Codecov Report

Merging #6661 (4965d64) into develop (1154f13) will increase coverage by 0.17%.
The diff coverage is 98.80%.

❗ Current head 4965d64 differs from pull request most recent head b16c7d7. Consider uploading reports for the commit b16c7d7 to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6661      +/-   ##
===========================================
+ Coverage    76.92%   77.10%   +0.17%     
===========================================
  Files         1583     1582       -1     
  Lines       183314   182663     -651     
===========================================
- Hits        141018   140834     -184     
+ Misses       42296    41829     -467     
Impacted Files Coverage Δ
src/util/pointer_predicates.cpp 93.10% <ø> (-0.45%) ⬇️
src/util/pointer_predicates.h 66.66% <ø> (ø)
src/ansi-c/c_typecheck_initializer.cpp 76.35% <97.29%> (+1.35%) ⬆️
jbmc/src/janalyzer/janalyzer_parse_options.cpp 48.75% <100.00%> (ø)
jbmc/src/jbmc/jbmc_parse_options.cpp 76.02% <100.00%> (ø)
jbmc/src/jdiff/jdiff_parse_options.cpp 67.74% <100.00%> (-0.35%) ⬇️
src/analyses/goto_check.cpp 81.39% <100.00%> (+17.75%) ⬆️
src/analyses/goto_check_c.cpp 91.60% <100.00%> (-0.01%) ⬇️
src/ansi-c/c_typecheck_type.cpp 77.08% <100.00%> (ø)
.../goto-instrument/goto_instrument_parse_options.cpp 69.39% <100.00%> (+0.03%) ⬆️
... and 7 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 352be59...b16c7d7. Read the comment docs.

This addresses an existing todo in the code base: we need to come up
with a new type based on the actual initializer.

Fixes: diffblue#3653, diffblue#4206

Co-authored-by: Chengyu Zhang <[email protected]>
Co-authored-by: Andreas Tiemeyer <[email protected]>
@tautschnig tautschnig force-pushed the bugfixes/flexible-array-static branch from 4965d64 to b16c7d7 Compare February 26, 2022 17:14
@tautschnig tautschnig marked this pull request as ready for review February 26, 2022 17:15
@tautschnig tautschnig assigned kroening and chris-ryder and unassigned tautschnig Feb 26, 2022
Copy link

@chris-ryder chris-ryder left a comment

Choose a reason for hiding this comment

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

Nothing blocking, just a few stylistic queries that you are free to ignore.

init_array.type() = actual_array_type;

// mimic bits of typecheck_compound_type to produce a new struct tag
actual_struct_type.remove(ID_tag);

Choose a reason for hiding this comment

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

Mildly a shame to have to mimic/duplicate bits of code... but maybe lifting out the duplicated parts into utilities is even messier if the mimicking isn't complete duplication.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did wonder, but cutting out just this bit seemed like it would create a utility function that can only be used in very peculiar circumstances.

to_array_type(actual_struct_type.components().back().type());
actual_array_type.size() = from_integer(
init_array.operands().size(), actual_array_type.index_type());
actual_array_type.set(ID_C_flexible_array_member, true);

Choose a reason for hiding this comment

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

Any point in introducing a to_C_flexible_array_type or something to make this a bit more structured? I always get a bit nervous when there's a bunch of setup being done in non-constructor/utility function code :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the main reason for this being messy is that it adjusts an existing type. So I'll leave it as is for now.

@tautschnig tautschnig merged commit 76c0431 into diffblue:develop Feb 26, 2022
@tautschnig tautschnig deleted the bugfixes/flexible-array-static branch February 26, 2022 21:38
@NlightNFotis NlightNFotis mentioned this pull request Mar 15, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected verification result about nested struct initialization
3 participants