From 3574b800cf72c3209e6200eee9fb93fd0228ad5f Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Thu, 10 Nov 2022 23:57:43 +0100 Subject: [PATCH] [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 --- libcxx/.clang-tidy | 3 ++- libcxx/include/__format/unicode.h | 5 +---- libcxx/include/__locale | 2 +- libcxx/include/charconv | 2 +- libcxx/include/fstream | 5 +++-- libcxx/include/locale | 5 +++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy index 88b9de1f56a8..4bc25c3ae605 100644 --- a/libcxx/.clang-tidy +++ b/libcxx/.clang-tidy @@ -25,6 +25,7 @@ Checks: > 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 @@ CheckOptions: # readability-redundant-access-specifiers, # readability-redundant-declaration, # readability-redundant-member-init, -# readability-simplify-boolean-expr, +# diff --git a/libcxx/include/__format/unicode.h b/libcxx/include/__format/unicode.h index 94d3e2184836..50f66e72570b 100644 --- a/libcxx/include/__format/unicode.h +++ b/libcxx/include/__format/unicode.h @@ -369,10 +369,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break( 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/libcxx/include/__locale b/libcxx/include/__locale index e02724c862e2..f1e0a07fd06b 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -701,7 +701,7 @@ public: 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(*__low)] & __m))) + if (!isascii(*__low) || !(__tab_[static_cast(*__low)] & __m)) break; return __low; } diff --git a/libcxx/include/charconv b/libcxx/include/charconv index d2031eac8ba9..4063117b30ad 100644 --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -250,7 +250,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> 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/libcxx/include/fstream b/libcxx/include/fstream index b8417f3e6c02..65b22a4db70a 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -753,9 +753,10 @@ basic_filebuf<_CharT, _Traits>::underflow() } 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(__ibs_ - __unget_sz), diff --git a/libcxx/include/locale b/libcxx/include/locale index 015efd8b0dc7..c00b1dfc9375 100644 --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -4013,9 +4013,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } 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(this->egptr() - this->eback() - __unget_sz),