[PATCH] D144036: [clang-tidy] Add bugprone-enum-to-bool-conversion check

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 08:33:43 PST 2023


ClockMan created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
ClockMan updated this revision to Diff 497408.
ClockMan added a comment.
Eugene.Zelenko added reviewers: aaron.ballman, carlosgalvezp.
ClockMan updated this revision to Diff 497692.
ClockMan published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Removed "Offers fixes" from list.rst


ClockMan added a comment.

Correct copyrights and commit author


ClockMan added a comment.

Ready for review



================
Comment at: clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.h:28
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
----------------
Should language be checked for C++?


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:6
+
+Detect implicit and explicit casts of `enum` type into `bool` where `enum` type
+doesn't have a zero-value enumerator. If `enum` is used only to hold values
----------------
Please synchronize first statement with statement in Release Notes. Please use double back-ticks for language constructs.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:49
+
+    Default value: '^$'.
+    Regexp used to ignore usages of enum declarations that match regexp.
----------------
Please use single back-ticks for option values. Default value is usually placed after option description.


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144036

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/enum-to-bool-conversion-cpp11.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/enum-to-bool-conversion.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144036.497692.patch
Type: text/x-patch
Size: 13060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230215/de45fb8d/attachment.bin>


More information about the cfe-commits mailing list