Skip to content

Suppress clang-analyzer-optin.core.EnumCastOutOfRange - #3244

Open
Minoru wants to merge 1 commit into
catchorg:develfrom
Minoru:bugfix/2909-suppress-clang-tidy-warning-on-resultdisposition-flags
Open

Minoru wants to merge 1 commit into
catchorg:develfrom
Minoru:bugfix/2909-suppress-clang-tidy-warning-on-resultdisposition-flags

Conversation

@Minoru

@Minoru Minoru commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Description

clang-tidy has a linter for casts from int to enum, which checks if the enum has a constant for the provided int. This linter doesn't work well with "flag enums" that have a constant for each bit and can have values for which they don't have a named constant.

This was reported upstream (llvm/llvm-project#76208 (comment)) and fixed in Clang 21. To suppress the warning, the enum has to be marked with clang::flag_enum attribute, so that's what this PR does. Documentation for the attribute is here: https://clang.llvm.org/docs/AttributeReference.html#flag-enum

The reason I need this change is because I'm running clang-tidy over my tests, and turn warnings into errors. I can't suppress this warning just for Catch on my end.

I admit I haven't ran Catch2 tests, and only checked this by manually editing the amalgamated file I vendor with my project.

Open questions

GitHub Issues

Fixes #2909.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.39%. Comparing base (36c1bc3) to head (f4a4ec4).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3244      +/-   ##
==========================================
- Coverage   91.43%   91.39%   -0.03%     
==========================================
  Files         205      205              
  Lines        9108     9108              
==========================================
- Hits         8327     8324       -3     
- Misses        781      784       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

operator| for ResultDisposition::Flags triggers clang-analyzer-optin.core.EnumCastOutOfRange (clang-tidy-18)

1 participant