[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
Mon Aug 15 16:34:25 PDT 2022


ddcc created this revision.
ddcc added a reviewer: ldionne.
Herald added a project: All.
ddcc requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

These warning were identified while debugging modules with Wsystem-headers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131929

Files:
  libcxx/include/atomic
  libcxx/include/cmath
  libcxx/include/string_view


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 = ~static_cast<size_type>(0U); // 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.452844.patch
Type: text/x-patch
Size: 3079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220815/3b26bb53/attachment.bin>


More information about the libcxx-commits mailing list