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

Richard via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 09:36:27 PDT 2016

LegalizeAdulthood added a subscriber: LegalizeAdulthood.

Comment at: docs/clang-tidy/checks/modernize-use-bool-literals.rst:17
@@ +16,1 @@
+  std::ios_base::sync_with_stdio(false);
\ No newline at end of file

Please ensure the file ends with a newline.

Comment at: test/clang-tidy/modernize-use-bool-literals.cpp:3
@@ +2,3 @@
+bool bar1 = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: implicitly converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
There is more initialization syntax than just assignment.  Here are the ones I can think of:

What happens when I write `bool foo{1};` or `bool foo(1);`?

What happens when I write:

class foo {
  foo() : b(0) {}
  foo(int) : b{0} {}
  bool b;
  bool c{0};
  bool d(0);
  bool e = 0;

Should we warn an a `bool` is initialized by a call to a `constexpr` function that returns an integral type?


More information about the cfe-commits mailing list