[PATCH] D18821: Add bugprone-bool-to-integer-conversion

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 4 01:37:48 PDT 2016


Prazek added inline comments.

================
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.
----------------
alexfh wrote:
> 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.
This check runs only on C++ functions. Maybe checking that the function isExternC() would be enough?

================
Comment at: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp:192
@@ +191,3 @@
+  // CHECK-FIXES: bool yat2() {
+
+  auto l = []() {
----------------
Why it is dangerous? What I see after runnign on llvm code base, that it is one of the most frequent case.
The only bug is the extern "C" thing.


http://reviews.llvm.org/D18821





More information about the cfe-commits mailing list