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

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 1 11:18:06 PDT 2023


Mordante updated this revision to Diff 557962.
Mordante added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131929

Files:
  libcxx/include/__atomic/is_always_lock_free.h
  libcxx/include/cmath
  libcxx/include/string
  libcxx/include/string_view
  libcxx/include/variant
  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
@@ -21,6 +21,10 @@
     "-Wextra",
     "-Wshadow",
     "-Wundef",
+    "-Wimplicit-float-conversion",
+    "-Wmacro-redefined",
+    "-Wsign-conversion",
+    "-Wzero-as-null-pointer-constant",
     "-Wunused-template",
     "-Wno-unused-command-line-argument",
     "-Wno-attributes",
Index: libcxx/include/variant
===================================================================
--- libcxx/include/variant
+++ libcxx/include/variant
@@ -342,7 +342,7 @@
   using type = __type_pack_element<_Ip, _Types...>;
 };
 
-inline constexpr size_t variant_npos = static_cast<size_t>(-1);
+inline constexpr size_t variant_npos = numeric_limits<size_type>::max();
 
 _LIBCPP_HIDE_FROM_ABI constexpr int __choose_index_type(unsigned int __num_elem) {
   if (__num_elem < numeric_limits<unsigned char>::max())
Index: libcxx/include/string_view
===================================================================
--- libcxx/include/string_view
+++ libcxx/include/string_view
@@ -286,7 +286,7 @@
     using reverse_iterator       = const_reverse_iterator;
     using size_type              = size_t;
     using difference_type        = ptrdiff_t;
-    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/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -874,7 +874,7 @@
     }
 
 public:
-  _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1;
+  _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = numeric_limits<size_type>::max();
 
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
       _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
Index: libcxx/include/cmath
===================================================================
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -547,8 +547,8 @@
 
 #if _LIBCPP_STD_VER >= 17
 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/is_always_lock_free.h
===================================================================
--- libcxx/include/__atomic/is_always_lock_free.h
+++ libcxx/include/__atomic/is_always_lock_free.h
@@ -20,7 +20,7 @@
 template <class _Tp>
 struct __libcpp_is_always_lock_free {
   // __atomic_always_lock_free is available in all Standard modes
-  static const bool __value = __atomic_always_lock_free(sizeof(_Tp), 0);
+  static const bool __value = __atomic_always_lock_free(sizeof(_Tp), nullptr);
 };
 
 _LIBCPP_END_NAMESPACE_STD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131929.557962.patch
Type: text/x-patch
Size: 3821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20231101/9b35deec/attachment.bin>


More information about the libcxx-commits mailing list