Refactor: remove some unhealthy include dependencies#7512
Open
Critsium-xy wants to merge 5 commits into
Open
Conversation
HamiltPW does not reference any ESolver symbol; the include of source_esolver/esolver_ks_pw.h was unused. Removing it cuts the only source_pw -> source_esolver back-edge (an operator header depending on its driver) and drops 15 transitively-included headers from every consumer of hamilt_pw.h (fan 114 -> 99). All types named in the header (UnitCell, ModulePW::PW_Basis_K, etc.) remain provided by klist.h / vnl_pw.h -> structure_factor.h. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Structure_Factor and Parallel_Grid are used in surchem.h only as pointer/reference parameters, so replace the heavy source_pw includes with forward declarations. This cuts the hamilt -> pw back-edge from surchem.h (hamilt->pw edge 4 -> 2) and drops 6 transitively-included headers from surchem.h's closure (54 -> 48), benefiting its ~160 transitive consumers. Two consumers relied on the transitive include and now include it directly (include-what-you-use): - esolver_fp.h: has a Parallel_Grid value member -> add parallel_grid.h - forces.cpp: accesses p_sf->strucFac -> add structure_factor.h Other surchem.h consumers use these types only via pointer/reference and are covered by the forward declarations; verified the remaining parallel_grid.h users still reach it through other includes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
cal_pseudo.cpp dereferences Structure_Factor (sf->strucFac) but only included surchem.h, which now forward-declares the type. Add the direct include so the complete type is available. Fixes the CI build error "invalid use of incomplete type 'class Structure_Factor'". Verified via closure analysis that this is the only remaining file in surchem.h's affected set that requires the complete type; all other consumers use Structure_Factor / Parallel_Grid by pointer or reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Match the house style used across the codebase (e.g. makov_payne.h, exx_helper_base.h, cube_io.h), where forward declarations are bare `class Foo;` lines without an explanatory comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Brief comment explaining why the source_pw types are forward-declared (pointer/reference use only) so the includes are not re-added later. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HamiltPW does not reference any ESolver symbol; the include of source_esolver/esolver_ks_pw.h was unused. Removing it cuts the only source_pw -> source_esolver back-edge (an operator header depending on its driver) and drops 15 transitively-included headers from every consumer of hamilt_pw.h (fan 114 -> 99).
All types named in the header (UnitCell, ModulePW::PW_Basis_K, etc.) remain provided by klist.h / vnl_pw.h -> structure_factor.h.
source/source_hamilt/module_surchem/surchem.h also get a header removal.
Because the codes are getting complex in some modules, so I'm starting the refactor work from simpler files instead of a whole folder.