Skip to content

Commit f1ea0b1

Browse files
committed
[libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI
These macros are always defined identically, so we can simplify the code a bit by merging them. Reviewed By: ldionne, #libc Spies: libcxx-commits, krytarowski, smeenai Differential Revision: https://reviews.llvm.org/D152652
1 parent 009af3f commit f1ea0b1

File tree

87 files changed

+529
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+529
-575
lines changed

libcxx/.clang-format

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ AttributeMacros: ['_LIBCPP_HIDE_FROM_ABI',
2424
'_LIBCPP_DISABLE_EXTENTSION_WARNING',
2525
'_LIBCPP_HIDDEN',
2626
'_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS',
27-
'_LIBCPP_FUNC_VIS',
28-
'_LIBCPP_TYPE_VIS',
2927
'_LIBCPP_TEMPLATE_VIS',
3028
'_LIBCPP_TEMPLATE_DATA_VIS',
3129
'_LIBCPP_EXPORTED_FROM_ABI',
3230
'_LIBCPP_OVERRIDABLE_FUNC_VIS',
33-
'_LIBCPP_EXCEPTION_ABI',
3431
'_LIBCPP_ENUM_VIS',
3532
'_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS',
3633
'_LIBCPP_INTERNAL_LINKAGE',

libcxx/docs/DesignDocs/VisibilityMacros.rst

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ Visibility Macros
2020
**_LIBCPP_HIDDEN**
2121
Mark a symbol as hidden so it will not be exported from shared libraries.
2222

23-
**_LIBCPP_FUNC_VIS**
24-
Mark a symbol as being exported by the libc++ library. This attribute must
25-
be applied to the declaration of all functions exported by the libc++ dylib.
26-
2723
**_LIBCPP_EXPORTED_FROM_ABI**
28-
Mark a symbol as being exported by the libc++ library. This attribute may
29-
only be applied to objects defined in the libc++ runtime library. On Windows,
24+
Mark a symbol as being part of our ABI. This includes functions that are part
25+
of the libc++ library, type information and other symbols. On Windows,
3026
this macro applies `dllimport`/`dllexport` to the symbol, and on other
3127
platforms it gives the symbol default visibility.
3228

@@ -65,10 +61,6 @@ Visibility Macros
6561
ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can
6662
use it to start removing symbols from the ABI after that stable version.
6763

68-
**_LIBCPP_TYPE_VIS**
69-
Mark a type's typeinfo, vtable and members as having default visibility.
70-
This attribute cannot be used on class templates.
71-
7264
**_LIBCPP_TEMPLATE_VIS**
7365
Mark a type's typeinfo and vtable as having default visibility.
7466
This macro has no effect on the visibility of the type's member functions.
@@ -152,13 +144,6 @@ Visibility Macros
152144
against the libc++ headers after making `_LIBCPP_TYPE_VIS` and
153145
`_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` expand to default visibility.
154146

155-
**_LIBCPP_EXCEPTION_ABI**
156-
Mark the member functions, typeinfo, and vtable of the type as being exported
157-
by the libc++ library. This macro must be applied to all *exception types*.
158-
Exception types should be defined directly in namespace `std` and not the
159-
versioning namespace. This allows throwing and catching some exception types
160-
between libc++ and libstdc++.
161-
162147
Links
163148
=====
164149

libcxx/include/__algorithm/shuffle.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS
2929

3030
_LIBCPP_BEGIN_NAMESPACE_STD
3131

32-
class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
32+
class _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_randomizer {
3333
public:
3434
_LIBCPP_HIDE_FROM_ABI __libcpp_debug_randomizer() {
3535
__state_ = __seed();
@@ -65,11 +65,11 @@ class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
6565

6666
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
6767
|| defined(_LIBCPP_BUILDING_LIBRARY)
68-
class _LIBCPP_TYPE_VIS __rs_default;
68+
class _LIBCPP_EXPORTED_FROM_ABI __rs_default;
6969

70-
_LIBCPP_FUNC_VIS __rs_default __rs_get();
70+
_LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
7171

72-
class _LIBCPP_TYPE_VIS __rs_default
72+
class _LIBCPP_EXPORTED_FROM_ABI __rs_default
7373
{
7474
static unsigned __c_;
7575

@@ -88,10 +88,10 @@ class _LIBCPP_TYPE_VIS __rs_default
8888
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type min() {return _Min;}
8989
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() {return _Max;}
9090

91-
friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
91+
friend _LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
9292
};
9393

94-
_LIBCPP_FUNC_VIS __rs_default __rs_get();
94+
_LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
9595

9696
template <class _RandomAccessIterator>
9797
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void

libcxx/include/__algorithm/sort.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -826,23 +826,23 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
826826
template <class _Comp, class _RandomAccessIterator>
827827
void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
828828

829-
extern template _LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
829+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
830830
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
831-
extern template _LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
831+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
832832
#endif
833-
extern template _LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
834-
extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
835-
extern template _LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
836-
extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
837-
extern template _LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
838-
extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
839-
extern template _LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
840-
extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
841-
extern template _LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
842-
extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
843-
extern template _LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
844-
extern template _LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
845-
extern template _LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
833+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
834+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
835+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
836+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
837+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
838+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
839+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
840+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
841+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
842+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
843+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
844+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
845+
extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
846846

847847
template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
848848
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void

libcxx/include/__charconv/from_chars_result.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
#if _LIBCPP_STD_VER >= 17
2323

24-
struct _LIBCPP_TYPE_VIS from_chars_result {
24+
struct _LIBCPP_EXPORTED_FROM_ABI from_chars_result {
2525
const char* ptr;
2626
errc ec;
2727
# if _LIBCPP_STD_VER >= 20

libcxx/include/__charconv/to_chars_floating_point.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323

2424
#if _LIBCPP_STD_VER >= 17
2525

26-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
26+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
2727
to_chars(char* __first, char* __last, float __value);
2828

29-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
29+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
3030
to_chars(char* __first, char* __last, double __value);
3131

32-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
32+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
3333
to_chars(char* __first, char* __last, long double __value);
3434

35-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
35+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
3636
to_chars(char* __first, char* __last, float __value, chars_format __fmt);
3737

38-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
38+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
3939
to_chars(char* __first, char* __last, double __value, chars_format __fmt);
4040

41-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
41+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
4242
to_chars(char* __first, char* __last, long double __value, chars_format __fmt);
4343

44-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
44+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
4545
to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision);
4646

47-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
47+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
4848
to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision);
4949

50-
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
50+
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
5151
to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
5252
#endif // _LIBCPP_STD_VER >= 17
5353

libcxx/include/__charconv/to_chars_result.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
#if _LIBCPP_STD_VER >= 17
2323

24-
struct _LIBCPP_TYPE_VIS to_chars_result {
24+
struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {
2525
char* ptr;
2626
errc ec;
2727
# if _LIBCPP_STD_VER >= 20

libcxx/include/__chrono/file_clock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct _FilesystemClock {
6363
_LIBCPP_EXPORTED_FROM_ABI
6464
static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
6565

66-
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_FUNC_VIS static time_point now() noexcept;
66+
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI static time_point now() noexcept;
6767

6868
#if _LIBCPP_STD_VER >= 20
6969
template <class _Duration>

libcxx/include/__chrono/steady_clock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace chrono
2424
{
2525

2626
#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
27-
class _LIBCPP_TYPE_VIS steady_clock
27+
class _LIBCPP_EXPORTED_FROM_ABI steady_clock
2828
{
2929
public:
3030
typedef nanoseconds duration;

libcxx/include/__chrono/system_clock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
namespace chrono
2525
{
2626

27-
class _LIBCPP_TYPE_VIS system_clock
27+
class _LIBCPP_EXPORTED_FROM_ABI system_clock
2828
{
2929
public:
3030
typedef microseconds duration;

0 commit comments

Comments
 (0)