[libcxx] r292159 - Fix std::tuples EBO when targeting the MSVC ABI.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 16 13:15:08 PST 2017


Author: ericwf
Date: Mon Jan 16 15:15:08 2017
New Revision: 292159

URL: http://llvm.org/viewvc/llvm-project?rev=292159&view=rev
Log:
Fix std::tuples EBO when targeting the MSVC ABI.

MSVC/clang-cl doesn't do a full EBO unless __declspec(empty_bases)
is applied to the derived type. This causes certain tuple tests
to fail.

This patch adds the empty_bases attribute to __tuple_impl in order
for tuple to fully provide the EBO.

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/tuple

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=292159&r1=292158&r2=292159&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan 16 15:15:08 2017
@@ -100,6 +100,9 @@
 #ifndef __is_identifier
 #define __is_identifier(__x) 1
 #endif
+#ifndef __has_declspec_attribute
+#define __has_declspec_attribute(__x) 0
+#endif
 
 #define __has_keyword(__x) !(__is_identifier(__x))
 
@@ -1023,6 +1026,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_DIAGNOSE_ERROR(...)
 #endif
 
+#if defined(_LIBCPP_ABI_MICROSOFT) && \
+   (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
+#else
+# define _LIBCPP_DECLSPEC_EMPTY_BASES
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=292159&r1=292158&r2=292159&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Mon Jan 16 15:15:08 2017
@@ -366,7 +366,7 @@ struct __all_default_constructible<__tup
 template<class _Indx, class ..._Tp> struct __tuple_impl;
 
 template<size_t ..._Indx, class ..._Tp>
-struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
+struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
     : public __tuple_leaf<_Indx, _Tp>...
 {
     _LIBCPP_INLINE_VISIBILITY




More information about the cfe-commits mailing list