[libcxx] r279926 - Avoid embedded preprocessor directives in __tree

Dimitry Andric via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 27 12:32:03 PDT 2016


Author: dim
Date: Sat Aug 27 14:32:03 2016
New Revision: 279926

URL: http://llvm.org/viewvc/llvm-project?rev=279926&view=rev
Log:
Avoid embedded preprocessor directives in __tree

Similar to rL242623, move C++ version checks outside of _NOEXCEPT_()
macro invocation argument lists, to avoid "embedding a directive within
macro arguments has undefined behavior" warnings.

Differential Revision: https://reviews.llvm.org/D23961

Modified:
    libcxx/trunk/include/__tree

Modified: libcxx/trunk/include/__tree
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=279926&r1=279925&r2=279926&view=diff
==============================================================================
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Sat Aug 27 14:32:03 2016
@@ -1111,14 +1111,15 @@ public:
     void clear() _NOEXCEPT;
 
     void swap(__tree& __t)
+#if _LIBCPP_STD_VER <= 11
         _NOEXCEPT_(
             __is_nothrow_swappable<value_compare>::value
-#if _LIBCPP_STD_VER <= 11
             && (!__node_traits::propagate_on_container_swap::value ||
                  __is_nothrow_swappable<__node_allocator>::value)
-#endif
             );
-
+#else
+        _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
+#endif
 
 #ifndef _LIBCPP_CXX03_LANG
     template <class _Key, class ..._Args>
@@ -1797,13 +1798,15 @@ __tree<_Tp, _Compare, _Allocator>::destr
 template <class _Tp, class _Compare, class _Allocator>
 void
 __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
+#if _LIBCPP_STD_VER <= 11
         _NOEXCEPT_(
             __is_nothrow_swappable<value_compare>::value
-#if _LIBCPP_STD_VER <= 11
             && (!__node_traits::propagate_on_container_swap::value ||
                  __is_nothrow_swappable<__node_allocator>::value)
-#endif
             )
+#else
+        _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value)
+#endif
 {
     using _VSTD::swap;
     swap(__begin_node_, __t.__begin_node_);




More information about the cfe-commits mailing list