Page MenuHomePhabricator

[clang-tidy] Add bugprone-enum-to-bool-conversion check
Needs ReviewPublic

Authored by PiotrZSL on Feb 14 2023, 11:51 AM.

Details

Summary

Detect implicit and explicit conversions of enum to bool,
when enum doesn't have a enumerator with value equal to 0.
In theory such conversion should always return TRUE.

Diff Detail

Event Timeline

PiotrZSL created this revision.Feb 14 2023, 11:51 AM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL updated this revision to Diff 497408.Feb 14 2023, 11:54 AM

Removed "Offers fixes" from list.rst

Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.h
29

Should language be checked for C++?

clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst
7

Please synchronize first statement with statement in Release Notes. Please use double back-ticks for language constructs.

50

Please use single back-ticks for option values. Default value is usually placed after option description.

PiotrZSL updated this revision to Diff 497692.Feb 15 2023, 8:32 AM

Correct copyrights and commit author

PiotrZSL published this revision for review.Feb 15 2023, 8:33 AM

Ready for review

Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2023, 8:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
PiotrZSL updated this revision to Diff 497727.Feb 15 2023, 10:14 AM
PiotrZSL marked 3 inline comments as done.

Corrected issues mentioned in review

PiotrZSL planned changes to this revision.Sun, Mar 5, 1:20 PM

Documentation to be updated, option need to be changed to list

PiotrZSL updated this revision to Diff 502752.Mon, Mar 6, 12:14 PM

Ping, Rebase, Changed Option from Regexp to List, Improved documentation, Removed usage of deprecated API