Skip to content

ENH: Rework the clang-tidy configuration for C11 - #97

Open
hjmjohnson wants to merge 1 commit into
masterfrom
pr/clang-tidy-c11-config
Open

hjmjohnson wants to merge 1 commit into
masterfrom
pr/clang-tidy-c11-config

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #32, reverted from master on 2026-09-24 so it can be
reviewed before merging. Content is unchanged from the original.

Base: master. Independent: nothing has to land before it.

Commits
  • ENH: Rework the clang-tidy configuration for C11

Ordering for all the re-submitted work is tracked in #84.

The .clang-tidy file has been in the tree since 2025 but nothing has ever
run it, and it shows: two of its entries name clang-analyzer checks that
upstream renamed some releases ago, so --verify-config warned about them.
Run over the whole tree it produced 1697 findings, of which the great
majority came from three style checks.  At that ratio nobody reads the
output.

Retuned for what this project actually is: C11, with a shipped ABI.
Measured with clang-tidy 22.1.8, USE_FSL_CODE=ON and USE_CIFTI_CODE=ON,
it now gives 331 findings across 15 checks, every one a defect class:

  170  bugprone-macro-parentheses
   44  bugprone-unchecked-string-to-number-conversion
   25  bugprone-multi-level-implicit-pointer-conversion
   19  readability-use-concise-preprocessor-directives
   16  bugprone-switch-missing-default-case
   13  readability-redundant-casting
    5  bugprone-suspicious-string-compare
    4  bugprone-suspicious-realloc-usage
    3  readability-redundant-control-flow
    2  readability-suspicious-call-argument
    2  bugprone-misplaced-widening-cast
    1  each: readability-implicit-bool-conversion,
         readability-function-size, misc-redundant-expression,
         bugprone-float-loop-counter

bugprone-macro-parentheses is re-enabled.  It had been switched off, but
it is the check that catches the real precedence bugs in the NT_DT_*,
QSTR and NT_FILL macro families.

misc-use-internal-linkage is switched off permanently, with the reason
recorded in the file.  It flags 29 functions, 13 of which are symbols
currently exported by libniftiio, libfslio and libcifti.  Applying its
fix-it would delete them from the shared libraries.  That it looks like a
tidy-up is exactly what makes it dangerous, so the file says so next to
the check rather than leaving the next person to rediscover it.

Every disabled check carries its finding count and the reason, so the
list can be re-argued from evidence instead of taste.

(cherry picked from commit 159d11d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants