[PATCH] D20857: [clang-tidy] Add modernize-explicit-operator-bool check.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 18:35:11 PDT 2016
alexfh added a comment.
Looks like a useful check to have. I'm not sure though, that it has anything to do with "modernize". I'd suggest adding a new "bugprone" module (should be added by http://reviews.llvm.org/D18821, hopefully soon) and moving the check there.
================
Comment at: test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp:6
@@ +5,3 @@
+ operator const void *() const {
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: implicit operator const void* declaration should probably be explicit operator bool [modernize-explicit-operator-bool]
+ return reinterpret_cast<void *>(something != 0);
----------------
>From the first glance, this doesn't look like an easy mistake to make. Have you actually seen this pattern in real code?
================
Comment at: test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp:14
@@ +13,3 @@
+class SomethingGood {
+ //Note: Use modernize-explicit-operator-bool to check for implicit operator bool.
+ explicit operator bool() const {
----------------
nit: Please insert a space after //
http://reviews.llvm.org/D20857
More information about the cfe-commits
mailing list