[libcxx-commits] [PATCH] D137804: [libc++][clang-tidy] Enable readability-siplify-boolean-expr

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 10 14:58:13 PST 2022


philnik created this revision.
philnik added reviewers: ldionne, Mordante, var-const, huixie90.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
philnik requested review of this revision.
Herald added subscribers: libcxx-commits, aheejin.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137804

Files:
  libcxx/.clang-tidy
  libcxx/include/__format/unicode.h
  libcxx/include/__locale
  libcxx/include/charconv
  libcxx/include/fstream
  libcxx/include/locale


Index: libcxx/include/locale
===================================================================
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -4009,7 +4009,7 @@
         }
         else
         {
-             _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
+             _LIBCPP_ASSERT(__extbufnext_ != NULL || __extbufend_ == __extbufnext_, "underflow moving from NULL" );
              if (__extbufend_ != __extbufnext_)
                 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
Index: libcxx/include/fstream
===================================================================
--- libcxx/include/fstream
+++ libcxx/include/fstream
@@ -751,7 +751,7 @@
         }
         else
         {
-            _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
+            _LIBCPP_ASSERT (__extbufnext_ != NULL || __extbufend_ == __extbufnext_, "underflow moving from NULL" );
             if (__extbufend_ != __extbufnext_)
                 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
Index: libcxx/include/charconv
===================================================================
--- libcxx/include/charconv
+++ libcxx/include/charconv
@@ -250,7 +250,7 @@
         int __i = digits;
         do
         {
-            if (!('0' <= *__p && *__p <= '9'))
+            if ('0' > *__p || *__p > '9')
                 break;
             __cprod[--__i] = *__p++ - '0';
         } while (__p != __ep && __i != 0);
Index: libcxx/include/__locale
===================================================================
--- libcxx/include/__locale
+++ libcxx/include/__locale
@@ -699,7 +699,7 @@
     const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
     {
         for (; __low != __high; ++__low)
-            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
+            if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
                 break;
         return __low;
     }
Index: libcxx/include/__format/unicode.h
===================================================================
--- libcxx/include/__format/unicode.h
+++ libcxx/include/__format/unicode.h
@@ -369,10 +369,7 @@
 
   if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
     __ri_break_allowed = !__ri_break_allowed;
-    if (__ri_break_allowed)
-      return true;
-
-    return false;
+    return __ri_break_allowed;
   }
 
   // *** Otherwise, break everywhere. ***
Index: libcxx/.clang-tidy
===================================================================
--- libcxx/.clang-tidy
+++ libcxx/.clang-tidy
@@ -27,6 +27,7 @@
   readability-redundant-preprocessor,
   readability-simplify-subscript-expr,
   readability-uniqueptr-delete-release,
+  readability-simplify-boolean-expr,
 
 CheckOptions:
   - key:   readability-function-cognitive-complexity.Threshold
@@ -63,4 +64,4 @@
 # readability-redundant-access-specifiers,
 # readability-redundant-declaration,
 # readability-redundant-member-init,
-# readability-simplify-boolean-expr,
+#


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137804.474616.patch
Type: text/x-patch
Size: 3375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221110/db2073b1/attachment.bin>


More information about the libcxx-commits mailing list