EricWF updated this revision to Diff 71570. EricWF added a comment. I'm going to go ahead and commit this w/o review because it's blocking more important changes. Post-commit comments on the documentation are appreciated.
https://reviews.llvm.org/D24602 Files: CMakeLists.txt docs/DesignDocs/VisibilityMacros.rst docs/index.rst include/__config include/__locale include/__string include/experimental/filesystem include/istream include/locale include/ostream include/streambuf include/string include/vector
Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -312,7 +312,7 @@ #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _LIBCPP_MSVC -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common<true>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC Index: include/string =================================================================== --- include/string +++ include/string @@ -574,7 +574,7 @@ #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _LIBCPP_MSVC -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC @@ -1024,7 +1024,7 @@ _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, __self_view __sv) { return replace(__pos1, __n1, __sv.data(), __sv.size()); } basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); - _LIBCPP_INLINE_VISIBILITY + inline _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, __self_view __sv, size_type __pos2, size_type __n2=npos); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); @@ -3910,8 +3910,8 @@ } #endif -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>) _LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) _LIBCPP_END_NAMESPACE_STD Index: include/streambuf =================================================================== --- include/streambuf +++ include/streambuf @@ -574,11 +574,11 @@ return traits_type::eof(); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>) _LIBCPP_END_NAMESPACE_STD Index: include/ostream =================================================================== --- include/ostream +++ include/ostream @@ -1113,8 +1113,8 @@ use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>) _LIBCPP_END_NAMESPACE_STD Index: include/locale =================================================================== --- include/locale +++ include/locale @@ -523,8 +523,8 @@ return 0; } -_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>) -_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY num_get @@ -1042,8 +1042,8 @@ return __b; } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>) struct _LIBCPP_TYPE_VIS __num_put_base { @@ -1192,8 +1192,8 @@ __op = __ob + (__np - __nb); } -_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>) -_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY num_put @@ -1621,8 +1621,8 @@ return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>) template <class _CharT, class _InputIterator> _LIBCPP_HIDDEN @@ -2291,8 +2291,8 @@ return __b; } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>) class _LIBCPP_TYPE_VIS __time_get { @@ -2374,8 +2374,8 @@ virtual const string_type& __X() const {return this->__X_;} }; -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>) class _LIBCPP_TYPE_VIS __time_put { @@ -2487,8 +2487,8 @@ return _VSTD::copy(__nb, __ne, __s); } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY time_put_byname @@ -2508,8 +2508,8 @@ ~time_put_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>) // money_base @@ -2575,10 +2575,10 @@ const bool moneypunct<_CharT, _International>::intl; -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>) // moneypunct_byname @@ -2632,10 +2632,10 @@ template<> void moneypunct_byname<wchar_t, false>::init(const char*); template<> void moneypunct_byname<wchar_t, true>::init(const char*); -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>) // money_get @@ -2691,8 +2691,8 @@ } } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY money_get @@ -3074,8 +3074,8 @@ return __b; } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>) // money_put @@ -3249,8 +3249,8 @@ __mi = __mb; } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY money_put @@ -3402,8 +3402,8 @@ return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>) // messages @@ -3512,8 +3512,8 @@ #endif // _LIBCPP_HAS_CATOPEN } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>) template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY messages_byname @@ -3536,8 +3536,8 @@ ~messages_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>) template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, Index: include/istream =================================================================== --- include/istream +++ include/istream @@ -1741,9 +1741,9 @@ return __is; } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>) _LIBCPP_END_NAMESPACE_STD Index: include/experimental/filesystem =================================================================== --- include/experimental/filesystem +++ include/experimental/filesystem @@ -249,7 +249,7 @@ uintmax_t available; }; -enum class _LIBCPP_TYPE_VIS file_type : signed char +enum class _LIBCPP_ENUM_VIS file_type : signed char { none = 0, not_found = -1, @@ -263,7 +263,7 @@ unknown = 8 }; -enum class _LIBCPP_TYPE_VIS perms : unsigned +enum class _LIBCPP_ENUM_VIS perms : unsigned { none = 0, @@ -323,7 +323,7 @@ inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } -enum class _LIBCPP_TYPE_VIS copy_options : unsigned short +enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { none = 0, skip_existing = 1, @@ -367,7 +367,7 @@ { return _LHS = _LHS ^ _RHS; } -enum class directory_options : unsigned char +enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { none = 0, follow_directory_symlink = 1, Index: include/__string =================================================================== --- include/__string +++ include/__string @@ -701,7 +701,8 @@ } template<class _Ptr> -size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) +inline _LIBCPP_INLINE_VISIBILITY +size_t __do_string_hash(_Ptr __p, _Ptr __e) { typedef typename iterator_traits<_Ptr>::value_type value_type; return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type)); Index: include/__locale =================================================================== --- include/__locale +++ include/__locale @@ -269,8 +269,8 @@ return static_cast<long>(__h); } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>) // template <class CharT> class collate_byname; @@ -1178,10 +1178,10 @@ { } -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -202,90 +202,6 @@ #define _LIBCPP_NO_CFI #endif -#ifdef _WIN32 - -// only really useful for a DLL -#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally... -# ifdef cxx_EXPORTS -# define _LIBCPP_HIDDEN -# define _LIBCPP_FUNC_VIS __declspec(dllexport) -# define _LIBCPP_TYPE_VIS __declspec(dllexport) -# else -# define _LIBCPP_HIDDEN -# define _LIBCPP_FUNC_VIS __declspec(dllimport) -# define _LIBCPP_TYPE_VIS __declspec(dllimport) -# endif -#else -# define _LIBCPP_HIDDEN -# define _LIBCPP_FUNC_VIS -# define _LIBCPP_TYPE_VIS -#endif - -#define _LIBCPP_TYPE_VIS_ONLY -#define _LIBCPP_FUNC_VIS_ONLY - -#ifndef _LIBCPP_INLINE_VISIBILITY -# ifdef _LIBCPP_MSVC -# define _LIBCPP_INLINE_VISIBILITY __forceinline -# else // MinGW GCC and Clang -# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) -# endif -#endif - -#ifndef _LIBCPP_EXCEPTION_ABI -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS -#endif - -#ifndef _LIBCPP_ALWAYS_INLINE -# ifdef _LIBCPP_MSVC -# define _LIBCPP_ALWAYS_INLINE __forceinline -# endif -#endif - -#endif // _WIN32 - -#ifndef _LIBCPP_HIDDEN -#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) -#endif - -#ifndef _LIBCPP_FUNC_VIS -#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) -#endif - -#ifndef _LIBCPP_TYPE_VIS -# if __has_attribute(__type_visibility__) -# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) -# else -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) -# endif -#endif - -#ifndef _LIBCPP_PREFERRED_OVERLOAD -# if __has_attribute(__enable_if__) -# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) -# endif -#endif - -#ifndef _LIBCPP_TYPE_VIS_ONLY -# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS -#endif - -#ifndef _LIBCPP_FUNC_VIS_ONLY -# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS -#endif - -#ifndef _LIBCPP_INLINE_VISIBILITY -#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) -#endif - -#ifndef _LIBCPP_EXCEPTION_ABI -#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) -#endif - -#ifndef _LIBCPP_ALWAYS_INLINE -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) -#endif - #if defined(__clang__) // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for @@ -581,8 +497,6 @@ #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS - - #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std @@ -628,6 +542,86 @@ #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ + +#ifdef _WIN32 +// only really useful for a DLL. _LIBCPP_DLL should be a compiler builtin define ideally... +#if defined(_LIBCPP_DLL) && defined(cxx_EXPORTS) +# define _LIBCPP_DLL_VIS __declspec(dllexport) +#elif defined(_LIBCPP_DLL) +# define _LIBCPP_DLL_VIS __declspec(dllimport) +#else +# define _LIBCPP_DLL_VIS +#endif +#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS +#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS +#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS +#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS +#define _LIBCPP_HIDDEN +#define _LIBCPP_TYPE_VIS_ONLY +#define _LIBCPP_FUNC_VIS_ONLY +#define _LIBCPP_ENUM_VIS +#define _LIBCPP_INLINE_VISIBILITY __forceinline +#define _LIBCPP_ALWAYS_INLINE __forceinline +#endif // _WIN32 + +#ifndef _LIBCPP_HIDDEN +#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) +#endif + +#ifndef _LIBCPP_FUNC_VIS +#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) +#endif + +#ifndef _LIBCPP_TYPE_VIS +# if __has_attribute(__type_visibility__) +# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) +# else +# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) +# endif +#endif + +#ifndef _LIBCPP_TYPE_VIS_ONLY +# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS +#endif + +#ifndef _LIBCPP_FUNC_VIS_ONLY +# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS +#endif + +#ifndef _LIBCPP_EXCEPTION_ABI +#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) +#endif + +#ifndef _LIBCPP_ENUM_VIS +# if __has_attribute(__type_visibility__) +# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) +# else +# define _LIBCPP_ENUM_VIS +# endif +#endif + +#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS +# if __has_attribute(__type_visibility__) +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) +# else +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS +# endif +#endif + +#ifndef _LIBCPP_INLINE_VISIBILITY +#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#endif + +#ifndef _LIBCPP_ALWAYS_INLINE +#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) +#endif + +#ifndef _LIBCPP_PREFERRED_OVERLOAD +# if __has_attribute(__enable_if__) +# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) +# endif +#endif + #ifndef _LIBCPP_HAS_NO_NOEXCEPT # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) @@ -716,7 +710,7 @@ _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ }; #else // _LIBCPP_HAS_NO_STRONG_ENUMS -#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x +#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS Index: docs/index.rst =================================================================== --- docs/index.rst +++ docs/index.rst @@ -129,6 +129,7 @@ DesignDocs/CapturingConfigInfo DesignDocs/ABIVersioning + DesignDocs/VisibilityMacros * `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_ Index: docs/DesignDocs/VisibilityMacros.rst =================================================================== --- /dev/null +++ docs/DesignDocs/VisibilityMacros.rst @@ -0,0 +1,85 @@ +======================== +Symbol Visibility Macros +======================== + +.. contents:: + :local: + +Overview +======== + +Libc++ uses various "visibility" macros in order to provide a stable ABI in +both the library and the headers. These macros work by changing the +visibility and inlining characteristics of the symbols they are applied to. + +Visibility Macros +================= + +**_LIBCPP_HIDDEN** + Mark a symbol as hidden so it will not be exported from shared libraries. + +**_LIBCPP_FUNC_VIS** + Mark a symbol as being exported by the libc++ library. This attribute must + be applied to the declaration of all functions exported by the libc++ dylib. + +**_LIBCPP_INLINE_VISIBILITY** + Mark a function as hidden and force inlining whenever possible. + +**_LIBCPP_ALWAYS_INLINE** + A synonym for `_LIBCPP_INLINE_VISIBILITY` + +**_LIBCPP_TYPE_VIS** + Mark a type's typeinfo and vtable as having default visibility. + `_LIBCPP_TYPE_VIS`. This macro has no effect on the visibility of the + type's member functions. This attribute cannot be used on class templates. + + **GCC Behavior**: GCC does not support Clang's `type_visibility(...)` + attribute. With GCC the `visibility(...)` attribute is used and member + functions are affected. + +**_LIBCPP_TYPE_VIS_ONLY** + The same as `_LIBCPP_TYPE_VIS` except that it may be applied to templates. + + **Windows Behavior**: DLLs do not support dllimport/export on class templates. + The macro has an empty definition on this platform. + + Note: This macro should be renamed `_LIBCPP_TEMPLATE_TYPE_VIS`. + +**_LIBCPP_ENUM_VIS** + Mark the typeinfo of an enum as having default visibility. This attribute + should be applied to all enum declarations. + + **Windows Behavior**: DLLs do not support importing or exporting enumeration + typeinfo. The macro has an empty definition on this platform. + + **GCC Behavior**: GCC un-hides the typeinfo for enumerations by default, even + if `-fvisibility=hidden` is specified. Additionally applying a visibility + attribute to an enum class results in a warning. The macro has an empty + definition with GCC. + +**_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS** + Mark the member functions, typeinfo, and vtable of the type named in + a `_LIBCPP_EXTERN_TEMPLATE` declaration as being exported by the libc++ library. + This attribute must be specified on all extern class template declarations. + + This macro is used to override the `_LIBCPP_TYPE_VIS_ONLY` attribute + specified on the primary template and to export the member functions produced + by the explicit instantiation in the dylib. + + **GCC Behavior**: GCC ignores visibility attributes applied the type in + extern template declarations and applying an attribute results in a warning. + However since `_LIBCPP_TYPE_VIS_ONLY` is the same as `_LIBCPP_TYPE_VIS` the + visibility is already correct. The macro has an empty definition with GCC. + +**_LIBCPP_EXCEPTION_ABI** + Mark the member functions, typeinfo, and vtable of the type as being exported + by the libc++ library. This macro must be applied to all *exception types*. + Exception types must be defined directly in namespace `std` and not the + versioning namespace. + +Links +===== + +* `[cfe-dev] Visibility in libc++ - 1 <http://lists.llvm.org/pipermail/cfe-dev/2013-July/030610.html>`_ +* `[cfe-dev] Visibility in libc++ - 2 <http://lists.llvm.org/pipermail/cfe-dev/2013-August/031195.html>`_ +* `[libcxx] Visibility fixes for Windows <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130805/085461.html>`_ Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -342,7 +342,6 @@ -Wno-covered-switch-default) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") add_compile_flags_if_supported( - -Wno-attributes # FIXME: Fix -Wattribute warnings. -Wno-literal-suffix -Wno-c++14-compat) endif()
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits