Replace every (void) cast with [[maybe_unused]] - #130
Open
petlenz wants to merge 1 commit into
Open
Conversation
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.
Project style:
(void)casts are out,[[maybe_unused]]is in. Sweeps all 61 sites onmain.The sites split into two kinds and get different treatments:
Unused variable / parameter (14 sites) —
[[maybe_unused]]moves to the declaration and the(void)x;line is deleted:Discarding a
[[nodiscard]]return (47 sites) — an attribute cannot annotate an expression, so these become a named declaration:Discard variables are named after the symbol being declared where one exists (
K,alpha,eps_p),discardedotherwise.Two incidental cleanups found by the sweep:
src/targets/numsim_material.cpp—(void)i;was dead;iis used two lines above asoutputs[i]. Deleted rather than annotated.tests/IntegrationTest.cpp— the natural nameafor one discard collided with a lambda'sfor (auto const &a : args)under-Wshadow; renameda_sv.Verification:
git grep '(void)'over*.cpp/*.hreturns nothing. Debug build clean under-Werror(which has-Wshadowand-Wunusedon), 298/298 unit tests, 337/338 ctest. The one ctest failure,NumSimMaterialEndToEnd.J2PathDependentRetainsPlasticStrainOnUnload, reproduces identically on unmodifiedmain— pre-existing, not from this change.Open PRs that add their own
(void)sites (#120, #121, #122, #123, #127) get the same treatment on their branches separately.