[libc++][clang-tidy] Enable readability-simplify-boolean-expr
Reviewed By: ldionne, #libc
Spies: Eugene.Zelenko, aheejin, libcxx-commits, xazax.hun
Differential Revision: https://reviews.llvm.org/D137804
NOKEYCHECK=True
GitOrigin-RevId: 3574b800cf72c3209e6200eee9fb93fd0228ad5f
diff --git a/.clang-tidy b/.clang-tidy
index 88b9de1..4bc25c3 100644
--- a/.clang-tidy
+++ b/.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,
+#
diff --git a/include/__format/unicode.h b/include/__format/unicode.h
index 94d3e21..50f66e7 100644
--- a/include/__format/unicode.h
+++ b/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. ***
diff --git a/include/__locale b/include/__locale
index e02724c..f1e0a07 100644
--- a/include/__locale
+++ b/include/__locale
@@ -701,7 +701,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;
}
diff --git a/include/charconv b/include/charconv
index d2031ea..4063117 100644
--- a/include/charconv
+++ b/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);
diff --git a/include/fstream b/include/fstream
index b8417f3..65b22a4 100644
--- a/include/fstream
+++ b/include/fstream
@@ -753,9 +753,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),
diff --git a/include/locale b/include/locale
index 015efd8..c00b1df 100644
--- a/include/locale
+++ b/include/locale
@@ -4013,9 +4013,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),