Author: hhinnant Date: Tue Nov 6 15:08:48 2012 New Revision: 167486 URL: http://llvm.org/viewvc/llvm-project?rev=167486&view=rev Log: Provide a way to disable use of extern templates in libc++. This is intended for the clients of libc++, not the libc++ build. The dylib should always contain the extern templates. To disable the client needs to put -D'_LIBCPP_EXTERN_TEMPLATE(...)=' on the command line.
Modified: libcxx/trunk/include/__config libcxx/trunk/include/__locale libcxx/trunk/include/algorithm libcxx/trunk/include/istream libcxx/trunk/include/locale libcxx/trunk/include/ostream libcxx/trunk/include/streambuf libcxx/trunk/include/string libcxx/trunk/include/valarray libcxx/trunk/include/vector Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Tue Nov 6 15:08:48 2012 @@ -427,6 +427,10 @@ #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS +#ifndef _LIBCPP_EXTERN_TEMPLATE +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +#endif + #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__ #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif Modified: libcxx/trunk/include/__locale URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/__locale (original) +++ libcxx/trunk/include/__locale Tue Nov 6 15:08:48 2012 @@ -254,8 +254,8 @@ return static_cast<long>(__h); } -extern template class _LIBCPP_VISIBLE collate<char>; -extern template class _LIBCPP_VISIBLE collate<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<wchar_t>) // template <class CharT> class collate_byname; @@ -1135,10 +1135,10 @@ { } -extern template class codecvt_byname<char, char, mbstate_t>; -extern template class codecvt_byname<wchar_t, char, mbstate_t>; -extern template class codecvt_byname<char16_t, char, mbstate_t>; -extern template class codecvt_byname<char32_t, char, mbstate_t>; +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_VISIBLE void __throw_runtime_error(const char*); Modified: libcxx/trunk/include/algorithm URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/algorithm (original) +++ libcxx/trunk/include/algorithm Tue Nov 6 15:08:48 2012 @@ -3782,39 +3782,39 @@ #pragma warning( push ) #pragma warning( disable: 4231) #endif // _MSC_VER -extern template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); -extern template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); -extern template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); -extern template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); -extern template void __sort<__less<short>&, short*>(short*, short*, __less<short>&); -extern template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); -extern template void __sort<__less<int>&, int*>(int*, int*, __less<int>&); -extern template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); -extern template void __sort<__less<long>&, long*>(long*, long*, __less<long>&); -extern template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); -extern template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); -extern template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); -extern template void __sort<__less<float>&, float*>(float*, float*, __less<float>&); -extern template void __sort<__less<double>&, double*>(double*, double*, __less<double>&); -extern template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); - -extern template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); -extern template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); -extern template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); -extern template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); -extern template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); -extern template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); -extern template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&); -extern template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); -extern template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&); -extern template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); -extern template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); -extern template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); -extern template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&); -extern template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&); -extern template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) + +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) -extern template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); +_LIBCPP_EXTERN_TEMPLATE(unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&)) #ifdef _MSC_VER #pragma warning( pop ) #endif // _MSC_VER Modified: libcxx/trunk/include/istream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/istream (original) +++ libcxx/trunk/include/istream Tue Nov 6 15:08:48 2012 @@ -1710,9 +1710,9 @@ return __is; } -extern template class basic_istream<char>; -extern template class basic_istream<wchar_t>; -extern template class basic_iostream<char>; +_LIBCPP_EXTERN_TEMPLATE(class basic_istream<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_istream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class basic_iostream<char>) _LIBCPP_END_NAMESPACE_STD Modified: libcxx/trunk/include/locale URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/locale (original) +++ libcxx/trunk/include/locale Tue Nov 6 15:08:48 2012 @@ -692,8 +692,8 @@ return 0; } -extern template struct __num_get<char>; -extern template struct __num_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(struct __num_get<char>) +_LIBCPP_EXTERN_TEMPLATE(struct __num_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_VISIBLE num_get @@ -1314,8 +1314,8 @@ return __b; } -extern template class num_get<char>; -extern template class num_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class num_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class num_get<wchar_t>) struct __num_put_base { @@ -1464,8 +1464,8 @@ __op = __ob + (__np - __nb); } -extern template struct __num_put<char>; -extern template struct __num_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(struct __num_put<char>) +_LIBCPP_EXTERN_TEMPLATE(struct __num_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_VISIBLE num_put @@ -1938,8 +1938,8 @@ return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } -extern template class num_put<char>; -extern template class num_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class num_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class num_put<wchar_t>) template <class _CharT, class _InputIterator> _LIBCPP_HIDDEN @@ -2605,8 +2605,8 @@ return __b; } -extern template class time_get<char>; -extern template class time_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_get<wchar_t>) class __time_get { @@ -2688,8 +2688,8 @@ virtual const string_type& __X() const {return this->__X_;} }; -extern template class time_get_byname<char>; -extern template class time_get_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<wchar_t>) class __time_put { @@ -2801,8 +2801,8 @@ return _VSTD::copy(__nb, __ne, __s); } -extern template class time_put<char>; -extern template class time_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_VISIBLE time_put_byname @@ -2822,8 +2822,8 @@ ~time_put_byname() {} }; -extern template class time_put_byname<char>; -extern template class time_put_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<wchar_t>) // money_base @@ -2885,10 +2885,10 @@ locale::id moneypunct<_CharT, _International>::id; -extern template class moneypunct<char, false>; -extern template class moneypunct<char, true>; -extern template class moneypunct<wchar_t, false>; -extern template class moneypunct<wchar_t, true>; +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, true>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, true>) // moneypunct_byname @@ -2942,10 +2942,10 @@ template<> void moneypunct_byname<wchar_t, false>::init(const char*); template<> void moneypunct_byname<wchar_t, true>::init(const char*); -extern template class moneypunct_byname<char, false>; -extern template class moneypunct_byname<char, true>; -extern template class moneypunct_byname<wchar_t, false>; -extern template class moneypunct_byname<wchar_t, true>; +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, true>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, true>) // money_get @@ -3001,8 +3001,8 @@ } } -extern template class __money_get<char>; -extern template class __money_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class __money_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class __money_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_VISIBLE money_get @@ -3383,8 +3383,8 @@ return __b; } -extern template class money_get<char>; -extern template class money_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class money_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class money_get<wchar_t>) // money_put @@ -3558,8 +3558,8 @@ __mi = __mb; } -extern template class __money_put<char>; -extern template class __money_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class __money_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class __money_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_VISIBLE money_put @@ -3715,8 +3715,8 @@ return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } -extern template class money_put<char>; -extern template class money_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class money_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class money_put<wchar_t>) // messages @@ -3825,8 +3825,8 @@ #endif // !_WIN32 } -extern template class messages<char>; -extern template class messages<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class messages<char>) +_LIBCPP_EXTERN_TEMPLATE(class messages<wchar_t>) template <class _CharT> class _LIBCPP_VISIBLE messages_byname @@ -3849,8 +3849,8 @@ ~messages_byname() {} }; -extern template class messages_byname<char>; -extern template class messages_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class messages_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class messages_byname<wchar_t>) template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, Modified: libcxx/trunk/include/ostream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/ostream (original) +++ libcxx/trunk/include/ostream Tue Nov 6 15:08:48 2012 @@ -1287,8 +1287,8 @@ use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); } -extern template class basic_ostream<char>; -extern template class basic_ostream<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<wchar_t>) _LIBCPP_END_NAMESPACE_STD Modified: libcxx/trunk/include/streambuf URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/streambuf?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/streambuf (original) +++ libcxx/trunk/include/streambuf Tue Nov 6 15:08:48 2012 @@ -553,11 +553,11 @@ return traits_type::eof(); } -extern template class basic_streambuf<char>; -extern template class basic_streambuf<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<wchar_t>) -extern template class basic_ios<char>; -extern template class basic_ios<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_ios<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_ios<wchar_t>) _LIBCPP_END_NAMESPACE_STD Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Tue Nov 6 15:08:48 2012 @@ -1031,7 +1031,7 @@ #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _MSC_VER -extern template class __basic_string_common<true>; +_LIBCPP_EXTERN_TEMPLATE(class __basic_string_common<true>) #ifdef _MSC_VER #pragma warning( pop ) #endif // _MSC_VER @@ -3975,8 +3975,8 @@ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -extern template class basic_string<char>; -extern template class basic_string<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_string<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_string<wchar_t>) extern template string Modified: libcxx/trunk/include/valarray URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/valarray?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/valarray (original) +++ libcxx/trunk/include/valarray Tue Nov 6 15:08:48 2012 @@ -4770,9 +4770,9 @@ return __v.__end_; } -extern template valarray<size_t>::valarray(size_t); -extern template valarray<size_t>::~valarray(); -extern template void valarray<size_t>::resize(size_t, size_t); +_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::valarray(size_t)) +_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::~valarray()) +_LIBCPP_EXTERN_TEMPLATE(void valarray<size_t>::resize(size_t, size_t)) _LIBCPP_END_NAMESPACE_STD Modified: libcxx/trunk/include/vector URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=167486&r1=167485&r2=167486&view=diff ============================================================================== --- libcxx/trunk/include/vector (original) +++ libcxx/trunk/include/vector Tue Nov 6 15:08:48 2012 @@ -313,7 +313,7 @@ #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _MSC_VER -extern template class __vector_base_common<true>; +_LIBCPP_EXTERN_TEMPLATE(class __vector_base_common<true>) #ifdef _MSC_VER #pragma warning( pop ) #endif // _MSC_VER _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits