[PATCH] D18821: Add modernize-bool-to-integer-conversion
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 7 08:48:56 PDT 2016
alexfh added a comment.
Actually, did you think about adding this as a clang diagnostic?
Richard, what do you think about complaining in Clang about `int i = true;` kind of code?
================
Comment at: clang-tidy/modernize/BoolToIntegerConversionCheck.cpp:49
@@ +48,3 @@
+ diag(BoolLiteral->getLocation(), "implicitly converting bool literal to "
+ "%0. Use integer literal instead")
+ << Type
----------------
s/. Use/; use/
Same below.
================
Comment at: docs/ReleaseNotes.rst:119
@@ +118,3 @@
+
+ Replaces implicit cast from bool literals to integers with int literals.
+
----------------
The phrase is technically incorrect. The check does not replace `implicit cast from bool literals`. It replaces bool literals (which are being implicitly cast to integers) with integer literals.
================
Comment at: docs/clang-tidy/checks/modernize-bool-to-integer-conversion.rst:9
@@ +8,3 @@
+.. code-block:: C++
+ int a = false;
+ vector<bool> v(true); // Makes vector of one element
----------------
There should be an empty line after `.. code-block ...`.
http://reviews.llvm.org/D18821
More information about the cfe-commits
mailing list