[PATCH] D18821: Add bugprone-bool-to-integer-conversion
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 18:06:32 PDT 2016
alexfh requested changes to this revision.
This revision now requires changes to proceed.
================
Comment at: docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst:37
@@ +36,3 @@
+
+It turns out that the common bug is to have function returning only bools but having int as return type.
+If check finds case like this then it function return type to bool.
----------------
It may well not be a bug. It's definitely not a bug for `extern "C"` functions and functions in C code. We definitely don't need to change the function return type, since it's a rather involved change (and clang-tidy checks currently are simply not able to make such change correctly in case of a function with external linkage). So please remove this automated fix.
================
Comment at: docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst:41
@@ +40,3 @@
+
+.. code-block:: C++
+ int fun() {
----------------
Please check that your documentation compiles.
================
Comment at: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp:191
@@ +190,3 @@
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function has return type 'int' but returns only bools
+ // CHECK-FIXES: bool yat2() {
+
----------------
That's a dangerous fix. It should either be removed or guarded by an option.
http://reviews.llvm.org/D18821
More information about the cfe-commits
mailing list