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

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 22 11:29:42 PST 2022


philnik updated this revision to Diff 477262.
philnik marked 3 inline comments as done.
philnik added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137804/new/

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,9 +4009,10 @@
         }
         else
         {
-             _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
-             if (__extbufend_ != __extbufnext_)
+             if (__extbufend_ != __extbufnext_) {
+                _LIBCPP_ASSERT(__extbufnext_ != NULL, "underflow moving from NULL" );
                 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+             }
             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
             __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
             streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
Index: libcxx/include/fstream
===================================================================
--- libcxx/include/fstream
+++ libcxx/include/fstream
@@ -751,9 +751,10 @@
         }
         else
         {
-            _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
-            if (__extbufend_ != __extbufnext_)
+            if (__extbufend_ != __extbufnext_) {
+                _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from NULL" );
                 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+            }
             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
             __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
             size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
Index: libcxx/include/charconv
===================================================================
--- libcxx/include/charconv
+++ libcxx/include/charconv
@@ -250,7 +250,7 @@
         int __i = digits;
         do
         {
-            if (!('0' <= *__p && *__p <= '9'))
+            if (*__p < '0' || *__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
@@ -25,6 +25,7 @@
   readability-redundant-control-flow,
   readability-redundant-function-ptr-dereference,
   readability-redundant-preprocessor,
+  readability-simplify-boolean-expr,
   readability-simplify-subscript-expr,
   readability-uniqueptr-delete-release,
 
@@ -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.477262.patch
Type: text/x-patch
Size: 3866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221122/625d8aa9/attachment.bin>


More information about the libcxx-commits mailing list