[libcxx-commits] [PATCH] D131929: [libcxx] Resolve warnings for Wimplicit-float-conversion, Wmacro-redefined, Wzero-as-null-pointer-constant, Wsign-conversion

Dominic Chen via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 16 14:54:32 PDT 2022


ddcc updated this revision to Diff 453137.
ddcc marked an inline comment as not done.
ddcc added a comment.
Herald added a subscriber: arichardson.

Update test suite flags, use numeric_limits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131929

Files:
  libcxx/include/atomic
  libcxx/include/cmath
  libcxx/include/string_view
  libcxx/utils/libcxx/test/params.py


Index: libcxx/utils/libcxx/test/params.py
===================================================================
--- libcxx/utils/libcxx/test/params.py
+++ libcxx/utils/libcxx/test/params.py
@@ -16,6 +16,10 @@
   '-Wextra',
   '-Wshadow',
   '-Wundef',
+  '-Wimplicit-float-conversion',
+  '-Wmacro-redefined',
+  '-Wsign-conversion',
+  '-Wzero-as-null-pointer-constant',
   '-Wno-unused-command-line-argument',
   '-Wno-attributes',
   '-Wno-pessimizing-move',
Index: libcxx/include/string_view
===================================================================
--- libcxx/include/string_view
+++ libcxx/include/string_view
@@ -285,7 +285,7 @@
     typedef const_reverse_iterator                     reverse_iterator;
     typedef size_t                                     size_type;
     typedef ptrdiff_t                                  difference_type;
-    static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+    static _LIBCPP_CONSTEXPR const size_type npos = numeric_limits<size_type>::max(); // size_type(-1);
 
     static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
     static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
Index: libcxx/include/cmath
===================================================================
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -531,8 +531,8 @@
 
 #if _LIBCPP_STD_VER > 14
 inline _LIBCPP_INLINE_VISIBILITY float       hypot(       float __x,       float __y,       float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
-inline _LIBCPP_INLINE_VISIBILITY double      hypot(      double __x,      double __y,      double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
-inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY double      hypot(      double __x,      double __y,      double __z ) { return sqrtf(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrtl(__x*__x + __y*__y + __z*__z); }
 
 template <class _A1, class _A2, class _A3>
 inline _LIBCPP_INLINE_VISIBILITY
Index: libcxx/include/atomic
===================================================================
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -1561,7 +1561,7 @@
     mutable __cxx_atomic_impl<_Tp> __a_;
 
 #if defined(__cpp_lib_atomic_is_always_lock_free)
-  static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), nullptr);
 #endif
 
     _LIBCPP_INLINE_VISIBILITY
@@ -2664,7 +2664,7 @@
 // atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type
 
 #ifdef __cpp_lib_atomic_is_always_lock_free
-# define _LIBCPP_CONTENTION_LOCK_FREE __atomic_always_lock_free(sizeof(__cxx_contention_t), 0)
+# define _LIBCPP_CONTENTION_LOCK_FREE __atomic_always_lock_free(sizeof(__cxx_contention_t), nullptr)
 #else
 # define _LIBCPP_CONTENTION_LOCK_FREE false
 #endif
@@ -2691,7 +2691,9 @@
 typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
 #endif
 
+#undef ATOMIC_FLAG_INIT
 #define ATOMIC_FLAG_INIT {false}
+#undef ATOMIC_VAR_INIT
 #define ATOMIC_VAR_INIT(__v) {__v}
 
 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131929.453137.patch
Type: text/x-patch
Size: 3544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220816/f2a5b962/attachment.bin>


More information about the libcxx-commits mailing list