Skip to content

Commit 83ce139

Browse files
committed
[libc++] Add hide_from_abi check for classes
We already have a clang-tidy check for making sure that `_LIBCPP_HIDE_FROM_ABI` is on free functions. This patch extends this to class members. The places where we don't check for `_LIBCPP_HIDE_FROM_ABI` are classes for which we have an instantiation in the library. Reviewed By: ldionne, Mordante, #libc Spies: jplehr, mikhail.ramalho, sstefan1, libcxx-commits, krytarowski, miyuki, smeenai Differential Revision: https://reviews.llvm.org/D142332
1 parent b34ca08 commit 83ce139

File tree

111 files changed

+990
-905
lines changed

Some content is hidden

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

111 files changed

+990
-905
lines changed

libcxx/include/__algorithm/comp_ref_type.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ template <class _Compare>
2323
struct __debug_less
2424
{
2525
_Compare &__comp_;
26-
_LIBCPP_CONSTEXPR_SINCE_CXX14
27-
__debug_less(_Compare& __c) : __comp_(__c) {}
26+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI __debug_less(_Compare& __c) : __comp_(__c) {}
2827

2928
template <class _Tp, class _Up>
30-
_LIBCPP_CONSTEXPR_SINCE_CXX14
29+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3130
bool operator()(const _Tp& __x, const _Up& __y)
3231
{
3332
bool __r = __comp_(__x, __y);
@@ -37,7 +36,7 @@ struct __debug_less
3736
}
3837

3938
template <class _Tp, class _Up>
40-
_LIBCPP_CONSTEXPR_SINCE_CXX14
39+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
4140
bool operator()(_Tp& __x, _Up& __y)
4241
{
4342
bool __r = __comp_(__x, __y);

libcxx/include/__algorithm/make_projected.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ struct _ProjectedPred {
3232
_Pred& __pred; // Can be a unary or a binary predicate.
3333
_Proj& __proj;
3434

35-
_LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {}
35+
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg)
36+
: __pred(__pred_arg), __proj(__proj_arg) {}
3637

3738
template <class _Tp>
3839
typename __invoke_of<_Pred&,
3940
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))
4041
>::type
41-
_LIBCPP_CONSTEXPR operator()(_Tp&& __v) const {
42+
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI operator()(_Tp&& __v) const {
4243
return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
4344
}
4445

@@ -47,7 +48,7 @@ struct _ProjectedPred {
4748
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
4849
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))
4950
>::type
50-
_LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const {
51+
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI operator()(_T1&& __lhs, _T2&& __rhs) const {
5152
return std::__invoke(__pred,
5253
std::__invoke(__proj, std::forward<_T1>(__lhs)),
5354
std::__invoke(__proj, std::forward<_T2>(__rhs)));

libcxx/include/__algorithm/shuffle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3131

3232
class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
3333
public:
34-
__libcpp_debug_randomizer() {
34+
_LIBCPP_HIDE_FROM_ABI __libcpp_debug_randomizer() {
3535
__state_ = __seed();
3636
__inc_ = __state_ + 0xda3e39cb94b95bdbULL;
3737
__inc_ = (__inc_ << 1) | 1;
@@ -85,8 +85,8 @@ class _LIBCPP_TYPE_VIS __rs_default
8585

8686
result_type operator()();
8787

88-
static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
89-
static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
88+
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type min() {return _Min;}
89+
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() {return _Max;}
9090

9191
friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
9292
};

libcxx/include/__atomic/atomic_flag.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ struct atomic_flag
7171
_LIBCPP_HIDE_FROM_ABI constexpr
7272
atomic_flag() _NOEXCEPT : __a_(false) {}
7373
#else
74-
_LIBCPP_HIDE_FROM_ABI
7574
atomic_flag() _NOEXCEPT = default;
7675
#endif
7776

libcxx/include/__chrono/calendar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using local_time = time_point<local_t, Duration>;
3131
using local_seconds = local_time<seconds>;
3232
using local_days = local_time<days>;
3333

34-
struct last_spec { _LIBCPP_HIDE_FROM_ABI explicit last_spec() = default; };
34+
struct last_spec { explicit last_spec() = default; };
3535
inline constexpr last_spec last{};
3636

3737

libcxx/include/__chrono/day.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class day {
2929
private:
3030
unsigned char __d_;
3131
public:
32-
_LIBCPP_HIDE_FROM_ABI day() = default;
32+
day() = default;
3333
_LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d_(static_cast<unsigned char>(__val)) {}
3434
_LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d_; return *this; }
3535
_LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }

libcxx/include/__chrono/duration.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,10 @@ class _LIBCPP_TEMPLATE_VIS duration
244244
rep __rep_;
245245
public:
246246

247-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
248247
#ifndef _LIBCPP_CXX03_LANG
249-
duration() = default;
248+
constexpr duration() = default;
250249
#else
251-
duration() {}
250+
_LIBCPP_HIDE_FROM_ABI duration() {}
252251
#endif
253252

254253
template <class _Rep2>

libcxx/include/__chrono/month.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class month {
2929
private:
3030
unsigned char __m_;
3131
public:
32-
_LIBCPP_HIDE_FROM_ABI month() = default;
32+
month() = default;
3333
_LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m_(static_cast<unsigned char>(__val)) {}
3434
_LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m_; return *this; }
3535
_LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }

libcxx/include/__chrono/monthday.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class month_day {
3232
chrono::month __m_;
3333
chrono::day __d_;
3434
public:
35-
_LIBCPP_HIDE_FROM_ABI month_day() = default;
35+
month_day() = default;
3636
_LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
3737
: __m_{__mval}, __d_{__dval} {}
3838
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }

libcxx/include/__chrono/weekday.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class weekday {
3535
unsigned char __wd_;
3636
_LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
3737
public:
38-
_LIBCPP_HIDE_FROM_ABI weekday() = default;
38+
weekday() = default;
3939
_LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd_(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
4040
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept
4141
: __wd_(__weekday_from_days(__sysd.time_since_epoch().count())) {}
@@ -126,7 +126,7 @@ class weekday_indexed {
126126
chrono::weekday __wd_;
127127
unsigned char __idx_;
128128
public:
129-
_LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
129+
weekday_indexed() = default;
130130
_LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
131131
: __wd_{__wdval}, __idx_(__idxval) {}
132132
_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd_; }

0 commit comments

Comments
 (0)