Commit 1a289fa3 by Jonathan Wakely Committed by Jonathan Wakely

Export explicit instantiations for C++17 members of std::string

The C++17 standard added some new members to std::basic_string, which
were not previously instantiated in the library. This meant that the
extern template declarations had to be disabled for C++17 mode. With
this patch the new members are instantiated in the library and so the
explicit instantiation declarations can be used for C++17.

The new members added by C++2a are still not exported, and so the
explicit instantiation declarations are still disabled for C++2a.

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
	for const member functions of std::basic_string.
	(GLIBCXX_3.4.26): Export member functions of std::basic_string added
	in C++17.
	* include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
	Make non-standard constructor private.
	[!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
	Likewise.
	* include/bits/basic_string.tcc (std::string, std::wstring): Declare
	explicit instantiations for C++17 as well as earlier dialects.
	* src/c++17/Makefile.am: Add new source files.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/cow-string-inst.cc: New file defining explicit
	instantiations for basic_string member functions added in C++17.
	* src/c++17/string-inst.cc: Likewise.

From-SVN: r267585
parent 4ff3e650
2019-01-04 Jonathan Wakely <jwakely@redhat.com>
* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
for const member functions of std::basic_string.
(GLIBCXX_3.4.26): Export member functions of std::basic_string added
in C++17.
* include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
Make non-standard constructor private.
[!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
Likewise.
* include/bits/basic_string.tcc (std::string, std::wstring): Declare
explicit instantiations for C++17 as well as earlier dialects.
* src/c++17/Makefile.am: Add new source files.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-string-inst.cc: New file defining explicit
instantiations for basic_string member functions added in C++17.
* src/c++17/string-inst.cc: Likewise.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export allocator-extended
copy/move constructors for old std::basic_string.
* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
......
......@@ -1742,7 +1742,8 @@ GLIBCXX_3.4.21 {
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]Ev;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]I[PN]*;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE[Daip]*;
_ZNKSt7__cxx1112basic_string*;
_ZNKSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE[1-9]*;
_ZNKSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EEixE[jmy];
# operator+ for ABI-tagged std::basic_string
_ZStplI[cw]St11char_traitsI[cw]ESaI[cw]EENSt7__cxx1112basic_stringIT_T0_T1_EE*;
......@@ -2077,6 +2078,27 @@ GLIBCXX_3.4.26 {
_ZNSbIwSt11char_traitsIwESaIwEEC[12]ERKS2_RKS1_;
_ZNSbIwSt11char_traitsIwESaIwEEC[12]EOS2_RKS1_;
# basic_string<C, T, A>::operator basic_string_view<C, T>() const
_ZNKSscvSt17basic_string_viewIcSt11char_traitsIcEEEv;
_ZNKSbIwSt11char_traitsIwESaIwEEcvSt17basic_string_viewIwS0_EEv;
_ZNKSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EEcvSt17basic_string_viewI[cw]S2_EEv;
# basic_string<C, T, A>::data()
_ZNSs4dataEv;
_ZNSbIwSt11char_traitsIwESaIwEE4dataEv;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE4dataEv;
# basic_string<C, T, A>::_S_to_string_view(basic_string_view<C, T>)
_ZNSs17_S_to_string_viewESt17basic_string_viewIcSt11char_traitsIcEE;
_ZNSbIwSt11char_traitsIwESaIwEE17_S_to_string_viewESt17basic_string_viewIwS0_E;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE17_S_to_string_viewESt17basic_string_viewI[cw]S2_E;
# basic_string<C, T, A>::__sv_wrapper::__sv_wrapper(basic_string_view<C, T>)
_ZNSs12__sv_wrapperC[12]ESt17basic_string_viewIcSt11char_traitsIcEE;
_ZNSbIwSt11char_traitsIwESaIwEE12__sv_wrapperC[12]ESt17basic_string_viewIwS0_E;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12__sv_wrapperC[12]ESt17basic_string_viewI[cw]S2_E;
# basic_string<C, T, A>::basic_string(__sv_wrapper, const allocator_type&)
_ZNSsC[12]ENSs12__sv_wrapperERKSaIcE;
_ZNSbIwSt11char_traitsIwESaIwEEC[12]ENS2_12__sv_wrapperERKS1_;
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]ENS4_12__sv_wrapperERKS3_;
} GLIBCXX_3.4.25;
# Symbols in the support library (libsupc++) have their own tag.
......
......@@ -1604,7 +1604,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Until those definitions are compiled as C++17 suppress the declaration,
// so C++17 code will implicitly instantiate std::string and std::wstring
// as needed.
# if __cplusplus <= 201402L && _GLIBCXX_EXTERN_TEMPLATE > 0
# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
extern template class basic_string<char>;
# elif ! _GLIBCXX_USE_CXX11_ABI
// Still need to prevent implicit instantiation of the COW empty rep,
......@@ -1627,7 +1627,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
getline(basic_istream<char>&, string&);
#ifdef _GLIBCXX_USE_WCHAR_T
# if __cplusplus <= 201402L && _GLIBCXX_EXTERN_TEMPLATE > 0
# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
extern template class basic_string<wchar_t>;
# elif ! _GLIBCXX_USE_CXX11_ABI
extern template basic_string<wchar_t>::size_type
......
......@@ -28,10 +28,11 @@ noinst_LTLIBRARIES = libc++17convenience.la
headers =
sources = \
memory_resource.cc
memory_resource.cc \
string-inst.cc
if ENABLE_DUAL_ABI
extra_string_inst_sources =
extra_string_inst_sources = cow-string-inst.cc
else
extra_string_inst_sources =
endif
......
......@@ -121,8 +121,8 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libc__17convenience_la_LIBADD =
am__objects_1 = memory_resource.lo
am__objects_2 =
am__objects_1 = memory_resource.lo string-inst.lo
@ENABLE_DUAL_ABI_TRUE@am__objects_2 = cow-string-inst.lo
@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_3 = $(am__objects_2)
am_libc__17convenience_la_OBJECTS = $(am__objects_1) $(am__objects_3)
libc__17convenience_la_OBJECTS = $(am_libc__17convenience_la_OBJECTS)
......@@ -411,10 +411,11 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS)
noinst_LTLIBRARIES = libc++17convenience.la
headers =
sources = \
memory_resource.cc
memory_resource.cc \
string-inst.cc
@ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources =
@ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources =
@ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources = cow-string-inst.cc
# XTEMPLATE_FLAGS =
@ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources =
......
// Reference-counted COW string instantiations for C++17 -*- C++ -*-
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:2017 24 Strings library
//
#define _GLIBCXX_USE_CXX11_ABI 0
#include "string-inst.cc"
#if ! _GLIBCXX_USE_DUAL_ABI
# error This file should not be compiled for this configuration.
#endif
// string instantiations for C++17 -*- C++ -*-
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:2017 24 Strings library
//
#include <string>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template basic_string<char>::basic_string(__sv_wrapper, const allocator_type&);
template basic_string<char>::__sv_wrapper::__sv_wrapper(string_view);
template string_view basic_string<char>::_S_to_string_view(string_view);
template basic_string<char>::operator string_view() const noexcept;
template char* basic_string<char>::data() noexcept;
#ifdef _GLIBCXX_USE_WCHAR_T
template basic_string<wchar_t>::basic_string(__sv_wrapper, const allocator_type&);
template basic_string<wchar_t>::__sv_wrapper::__sv_wrapper(wstring_view);
template wstring_view basic_string<wchar_t>::_S_to_string_view(wstring_view);
template basic_string<wchar_t>::operator wstring_view() const noexcept;
template wchar_t* basic_string<wchar_t>::data() noexcept;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment