Skip to content

[libc++][NFC] Add a few explicit 'inline' keywords, mostly in <chrono> #75234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/include/__chrono/day.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const day& __lhs, const day& __rhs) noexcept
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
}

Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__chrono/hh_mm_ss.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ class hh_mm_ss
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(hh_mm_ss);

_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
_LIBCPP_HIDE_FROM_ABI constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); }

_LIBCPP_HIDE_FROM_ABI constexpr hours make12(const hours& __h) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr hours make12(const hours& __h) noexcept
{
if (__h == hours( 0)) return hours(12);
else if (__h <= hours(12)) return __h;
else return __h - hours(12);
}

_LIBCPP_HIDE_FROM_ABI constexpr hours make24(const hours& __h, bool __is_pm) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr hours make24(const hours& __h, bool __is_pm) noexcept
{
if (__is_pm)
return __h == hours(12) ? __h : __h + hours(12);
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__chrono/month.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month& __lhs, const month& __rhs) noexcept
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
}

Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/__chrono/monthday.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
return __c;
return __lhs.day() <=> __rhs.day();
Expand All @@ -69,19 +69,19 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(const month& __lhs, const day& __rhs) noexcept
{ return month_day{__lhs, __rhs}; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(const day& __lhs, const month& __rhs) noexcept
{ return __rhs / __lhs; }

_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(const month& __lhs, int __rhs) noexcept
{ return __lhs / day(__rhs); }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(int __lhs, const day& __rhs) noexcept
{ return month(__lhs) / __rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
month_day operator/(const day& __lhs, int __rhs) noexcept
{ return month(__rhs) / __lhs; }

Expand All @@ -99,7 +99,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
{ return __lhs.month() == __rhs.month(); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering
operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
return __lhs.month() <=> __rhs.month();
}
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__chrono/weekday.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept
{ return !(__lhs < __rhs); }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
weekday operator+(const weekday& __lhs, const days& __rhs) noexcept
{
auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
return weekday{static_cast<unsigned>(__mu - __yr * 7)};
}

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
weekday operator+(const days& __lhs, const weekday& __rhs) noexcept
{ return __rhs + __lhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
weekday operator-(const weekday& __lhs, const days& __rhs) noexcept
{ return __lhs + -__rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
days operator-(const weekday& __lhs, const weekday& __rhs) noexcept
{
const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__chrono/year_month.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
return __c;
return __lhs.month() <=> __rhs.month();
}

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
{
int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
Expand All @@ -68,27 +68,27 @@ year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
}

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator+(const months& __lhs, const year_month& __rhs) noexcept
{ return __rhs + __lhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator+(const year_month& __lhs, const years& __rhs) noexcept
{ return (__lhs.year() + __rhs) / __lhs.month(); }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator+(const years& __lhs, const year_month& __rhs) noexcept
{ return __rhs + __lhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
months operator-(const year_month& __lhs, const year_month& __rhs) noexcept
{ return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator-(const year_month& __lhs, const months& __rhs) noexcept
{ return __lhs + -__rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr
_LIBCPP_HIDE_FROM_ABI inline constexpr
year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
{ return __lhs + -__rhs; }

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__chrono/year_month_day.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering
operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
return __c;
Expand Down
14 changes: 7 additions & 7 deletions libcxx/include/__variant/monostate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD

struct _LIBCPP_TEMPLATE_VIS monostate {};

_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(monostate, monostate) noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }

# if _LIBCPP_STD_VER >= 20

_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
return strong_ordering::equal;
}

# else // _LIBCPP_STD_VER >= 20

_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(monostate, monostate) noexcept { return false; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator!=(monostate, monostate) noexcept { return false; }

_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(monostate, monostate) noexcept { return false; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(monostate, monostate) noexcept { return false; }

_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(monostate, monostate) noexcept { return false; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(monostate, monostate) noexcept { return false; }

_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(monostate, monostate) noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(monostate, monostate) noexcept { return true; }

_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(monostate, monostate) noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noexcept { return true; }

# endif // _LIBCPP_STD_VER >= 20

Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,13 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
return __x < __b ? __x : __b;
}

_LIBCPP_HIDE_FROM_ABI constexpr float
_LIBCPP_HIDE_FROM_ABI inline constexpr float
lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

_LIBCPP_HIDE_FROM_ABI constexpr double
_LIBCPP_HIDE_FROM_ABI inline constexpr double
lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

_LIBCPP_HIDE_FROM_ABI constexpr long double
_LIBCPP_HIDE_FROM_ABI inline constexpr long double
lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }

template <class _A1, class _A2, class _A3>
Expand Down
12 changes: 6 additions & 6 deletions libcxx/include/complex
Original file line number Diff line number Diff line change
Expand Up @@ -1503,34 +1503,34 @@ inline namespace literals
{
inline namespace complex_literals
{
_LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(long double __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(long double __im)
{
return { 0.0l, __im };
}

_LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(unsigned long long __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(unsigned long long __im)
{
return { 0.0l, static_cast<long double>(__im) };
}


_LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(long double __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(long double __im)
{
return { 0.0, static_cast<double>(__im) };
}

_LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(unsigned long long __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(unsigned long long __im)
{
return { 0.0, static_cast<double>(__im) };
}


_LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(long double __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double __im)
{
return { 0.0f, static_cast<float>(__im) };
}

_LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(unsigned long long __im)
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long long __im)
{
return { 0.0f, static_cast<float>(__im) };
}
Expand Down
14 changes: 7 additions & 7 deletions libcxx/include/cstddef
Original file line number Diff line number Diff line change
Expand Up @@ -71,40 +71,40 @@ namespace std // purposefully not versioned
{
enum class byte : unsigned char {};

_LIBCPP_HIDE_FROM_ABI constexpr byte operator| (byte __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator| (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
));
}

_LIBCPP_HIDE_FROM_ABI constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs | __rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr byte operator& (byte __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator& (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
));
}

_LIBCPP_HIDE_FROM_ABI constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs & __rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
));
}

_LIBCPP_HIDE_FROM_ABI constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs ^ __rhs; }

_LIBCPP_HIDE_FROM_ABI constexpr byte operator~ (byte __b) noexcept
_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~ (byte __b) noexcept
{
return static_cast<byte>(
static_cast<unsigned char>(
Expand Down