[PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 11:22:43 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:39
@@ +38,3 @@
+
+  return LiteralSource.size() >= 1 && isDigit(LiteralSource.front());
+}
----------------
Use `!x.empty()` instead of `x.size() >= 1`.

================
Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.h:19
@@ +18,3 @@
+
+/// Finds integer literals, which are implicitly cast to bool.
+///
----------------
What about the ones explicitly cast to `bool`? Do we want to warn on them?

================
Comment at: test/clang-tidy/modernize-use-bool-literals.cpp:18
@@ +17,3 @@
+bool MacroIntToTrue = TRUE_MACRO; // Not ok, but can't replace
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicitly converting integer literal to bool inside macro, use bool literal instead [modernize-use-bool-literals]
+
----------------
Please add CHECK-FIXES to ensure that both the definition of the macro and the code using it are not changed.


http://reviews.llvm.org/D18745





More information about the cfe-commits mailing list