InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

COMP: Suppress some Wformat-nonliteral warnings #4616

Closed seanm closed 2 months ago

seanm commented 2 months ago

Introduced GCC_PRAGMA_PUSH macro and friends, similiar to existing CLANG_PRAGMA_PUSH and friends, but that applies to both GCC and Clang, which share many warning flags.

Added macros to suppess -Wformat-nonliteral warnings. Used them in a few places where the warnings are impossible to fix with ITK's current API.

Made -Wfloat-equal apply to GCC now, in addition to Clang.

Also added these macros as StatementMacros in the .clang-format file, so that clang-format formats them more nicely. Redid some formatting.

PR Checklist

Refer to the ITK Software Guide for further development details if necessary.

seanm commented 2 months ago

This should fix some of these warnings:

https://open.cdash.org/viewBuildError.php?type=1&buildid=9572940

hjmjohnson commented 2 months ago

@seanm Ran clang-formatter:

./Utilities/Maintenance/clang-format.bash --clang-format /Users/johnsonhj/Dashboard/src/ITK/cmake-build-release/clang-format-Darwin --tracked
seanm commented 2 months ago

Thanks for the touch-ups!

SimonRit commented 2 months ago

This PR has removed CLANG_SUPPRESS_Wfloat_equal which was used in my code: https://my.cdash.org/viewBuildError.php?buildid=2552633 There is a quick fix of course but other users might still use CLANG_SUPPRESS_Wfloat_equal. Was this intentional? I wonder why it's not been kept since CLANG_PRAGMA_PUSH and CLANG_PRAGMA_POP have been kept.

seanm commented 2 months ago

Hmm, although it's in a public header, I didn't imaging anyone using it.

I'll make a new MR to bring it back. Probably not until later today though, as I'm just recovering from a stomach bug.

seanm commented 2 months ago

@SimonRit https://github.com/InsightSoftwareConsortium/ITK/pull/4644