Skip to content

Remove unnecessary includes #7235

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 9 commits into from
Nov 20, 2022
Merged

Conversation

tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented Oct 12, 2022

Manual removal of includes based on include-what-you-use's output, filtered for includes that should be removed. The goal is to avoid unnecessary build dependencies, reducing the amount of code that needs to be rebuilt during incremental builds.

This is a second iteration of this cleanup; the first round took place in 450845d.

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

@tautschnig tautschnig self-assigned this Oct 12, 2022
@tautschnig tautschnig force-pushed the cleanup/iwyu-2 branch 2 times, most recently from bac0f77 to a0cf7f0 Compare October 12, 2022 21:18
@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Base: 78.34% // Head: 78.03% // Decreases project coverage by -0.30% ⚠️

Coverage data is based on head (cb91b12) compared to base (a53fa0f).
Patch coverage: 92.13% of modified lines in pull request are covered.

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

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7235      +/-   ##
===========================================
- Coverage    78.34%   78.03%   -0.31%     
===========================================
  Files         1644     1625      -19     
  Lines       190313   187422    -2891     
===========================================
- Hits        149097   146252    -2845     
+ Misses       41216    41170      -46     
Impacted Files Coverage Δ
jbmc/src/janalyzer/janalyzer_parse_options.cpp 48.58% <ø> (ø)
.../src/java_bytecode/character_refine_preprocess.cpp 54.27% <ø> (ø)
...mc/src/java_bytecode/character_refine_preprocess.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp 98.41% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods_needed.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/code_with_references.cpp 84.61% <ø> (ø)
jbmc/src/java_bytecode/java_bmc_util.cpp 100.00% <ø> (ø)
...mc/src/java_bytecode/java_bytecode_convert_class.h 0.00% <ø> (ø)
...src/java_bytecode/java_bytecode_convert_method.cpp 97.69% <ø> (ø)
... and 505 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kroening kroening removed their assignment Oct 13, 2022
Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

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

Thanks for this clean up!

@tautschnig
Copy link
Collaborator Author

@chris-ryder Could you please take a look at this one?

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.

Looks like a painful, but very useful cleanup!

@tautschnig tautschnig removed their assignment Oct 27, 2022
#include <util/nodiscard.h>

#include <solvers/smt2_incremental/ast/smt_responses.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

response_or_errort handles the type it is specialised with by-value like optional does. response_or_errort is specialised with smt_responset for the return value of validate_smt_response. Therefore I would say that it is incorrect to remove this include as it is used.

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 have now added // IWYU pragma: keep instead.

@@ -13,7 +13,6 @@

#include <functional>
#include <iostream>
#include <sstream>
Copy link
Contributor

Choose a reason for hiding this comment

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

std::stringstream is used in the smt_to_smt2_string function (all overloads) and is defined in the <sstream> header. Therefore this include should not be removed, as it is used. I assume this file still compiles without the include due to transitive includes of some type. My understanding is that some of these transitive includes can be in implementations of the STL but not required by the standard.

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 have now added // IWYU pragma: keep instead.


#include <solvers/smt2_incremental/ast/smt_terms.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

smt_termtis defined in smt_terms.h and is used in the definition of type_size_mapt in this file. Therefore this include should be kept.

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 have now added // IWYU pragma: keep instead.


#include <solvers/smt2_incremental/ast/smt_commands.h>
#include <solvers/smt2_incremental/ast/smt_logics.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

The logics defined in this header are used as part of the "Test smt_set_logic_commandt to string conversion" test in this file. Removing the include still compiles as it depends on a transitive include via smt_commends.h.

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 have now added // IWYU pragma: keep instead.

@tautschnig tautschnig force-pushed the cleanup/iwyu-2 branch 3 times, most recently from f3c9220 to ae5a2b6 Compare October 27, 2022 18:39
@tautschnig tautschnig force-pushed the cleanup/iwyu-2 branch 2 times, most recently from 8f7394b to ddebc88 Compare November 4, 2022 13:41
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

All areas I am maintainer for look good.

@feliperodri feliperodri assigned tautschnig and unassigned martin-cs Nov 19, 2022
There was a spurious include of the implementation file rather than the
header.
The empty namespace will lack symbol information that may be needed, and
is just unnecessary anyway.
6b88028 removed the existing test (for good reasons) but didn't
replace it with any other.
Whitespace cleanup only so as not to break syntax highlighting.
This enables use of symbol_table_baset instead of symbol_tablet in many
places.
We almost never create a fresh symbol table, and any time we do so we
should really make sure this is the intended behaviour.
This is to make sure that we can run include-what-you-use without being
told to remove includes when doing so would fail the build.
Manual removal of includes based on include-what-you-use's output,
filtered for includes that should be removed. The goal is to avoid
unnecessary build dependencies, reducing the amount of code that needs
to be rebuilt during incremental builds.

This is a second iteration of this cleanup; the first round took place in
450845d.
This is to make sure that future pull requests do not introduce
unnecessary includes (or remove ones that are no longer necessary).
@tautschnig tautschnig merged commit d932d6f into diffblue:develop Nov 20, 2022
@tautschnig tautschnig deleted the cleanup/iwyu-2 branch November 20, 2022 15:01
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.

9 participants