Skip to content

COMP: Suppress LabelGeometryImageFilter self-deprecation warnings#6446

Open
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-labelgeometry-self-deprecation
Open

COMP: Suppress LabelGeometryImageFilter self-deprecation warnings#6446
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-labelgeometry-self-deprecation

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

itk::LabelGeometryImageFilter is marked [[deprecated]], but its own out-of-line method definitions in the .hxx reference the class name, so every translation unit that includes the header (e.g. ITKReviewHeaderTest1) and the unit test that exercises it emit -Wdeprecated-declarations. This guards the implementation and the test's direct instantiation so a deprecated class no longer warns about its own internal use.

Warning counts (GCC 14)
Translation unit before after
itkLabelGeometryImageFilterTest.cxx 31 0
ITKReviewHeaderTest1.cxx 29 0
Approach

Wrap the self-referential regions in a -Wdeprecated-declarations push/ignore/pop, matching the existing idiom in the Vnl*FFTImageFilter headers:

  • itkLabelGeometryImageFilter.hxx — guard the itk namespace body (out-of-line definitions self-reference the class).
  • itkLabelGeometryImageFilterTest.cxx — guard the single direct using LabelGeometryImageFilter<...> instantiation.

No behavior change. ctest -R LabelGeometry passes (4/4); pre-commit run --all-files clean.

itk::LabelGeometryImageFilter is marked [[deprecated]]. Its own
out-of-line method definitions in the .hxx reference the class name,
emitting -Wdeprecated-declarations for every translation unit that
includes the header (e.g. ITKReviewHeaderTest1) and for the unit
test that exercises it.

Guard the .hxx implementation and the test's direct instantiation
with a -Wdeprecated-declarations push/pop, matching the idiom used
in the Vnl*FFTImageFilter headers.
@github-actions github-actions Bot added type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Jun 16, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review June 16, 2026 02:19
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Suppresses -Wdeprecated-declarations warnings that a [[deprecated]] class inadvertently emits against its own out-of-line method definitions and direct test instantiation.

  • itkLabelGeometryImageFilter.hxx: wraps the full namespace itk {} body with a #pragma GCC diagnostic push/ignored/pop guard, matching the existing Vnl FFT header idiom — no behavior change, only compiler-diagnostic scope adjustment.
  • itkLabelGeometryImageFilterTest.cxx: tightly wraps only the using LabelGeometryType = … declaration; all subsequent code uses the non-deprecated alias, so no wider suppression is needed.

Confidence Score: 5/5

Safe to merge — no logic changes, only compiler-diagnostic scope adjustments using a pattern already established in the codebase.

Both changes are additive-only: they insert matching pragma diagnostic push/pop pairs around code that was already compiling and passing tests. The pattern is copied directly from the Vnl FFT headers; the suppression scope in the .hxx is the established broad-namespace idiom, and the test suppression is deliberately tight.

No files require special attention.

Important Files Changed

Filename Overview
Modules/Nonunit/Review/include/itkLabelGeometryImageFilter.hxx Adds GCC/Clang diagnostic push/pop wrapping the entire namespace itk {} body to suppress -Wdeprecated-declarations triggered by out-of-line method definitions self-referencing the deprecated class name; consistent with the existing Vnl FFT header idiom.
Modules/Nonunit/Review/test/itkLabelGeometryImageFilterTest.cxx Narrowly wraps only the using LabelGeometryType = itk::LabelGeometryImageFilter<...> declaration with the same GCC/Clang diagnostic suppression; subsequent uses via the alias are not deprecated, so the tight scope is correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["TU includes itkLabelGeometryImageFilter.hxx"] --> B["namespace itk open"]
    B --> C["#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored -Wdeprecated-declarations"]
    C --> D["Anonymous namespace helpers\n(no direct class reference)"]
    D --> E["Out-of-line method definitions\nLabelGeometryImageFilter::XXX()\n⚠ self-references deprecated class name"]
    E --> F["#pragma GCC diagnostic pop"]
    F --> G["namespace itk close"]
    H["itkLabelGeometryImageFilterTest.cxx"] --> I["#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored -Wdeprecated-declarations"]
    I --> J["using LabelGeometryType = itk::LabelGeometryImageFilter<...>\n⚠ deprecated class name used here"]
    J --> K["#pragma GCC diagnostic pop"]
    K --> L["LabelGeometryType::New() etc.\n✅ uses alias — no warning"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["TU includes itkLabelGeometryImageFilter.hxx"] --> B["namespace itk open"]
    B --> C["#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored -Wdeprecated-declarations"]
    C --> D["Anonymous namespace helpers\n(no direct class reference)"]
    D --> E["Out-of-line method definitions\nLabelGeometryImageFilter::XXX()\n⚠ self-references deprecated class name"]
    E --> F["#pragma GCC diagnostic pop"]
    F --> G["namespace itk close"]
    H["itkLabelGeometryImageFilterTest.cxx"] --> I["#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored -Wdeprecated-declarations"]
    I --> J["using LabelGeometryType = itk::LabelGeometryImageFilter<...>\n⚠ deprecated class name used here"]
    J --> K["#pragma GCC diagnostic pop"]
    K --> L["LabelGeometryType::New() etc.\n✅ uses alias — no warning"]
Loading

Reviews (1): Last reviewed commit: "COMP: Suppress LabelGeometryImageFilter ..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant