Skip to content

Commit 5e26fb1

Browse files
authored
[libc++] Qualify calls to nullary functions like __throw_foo (#122465)
This is technically not necessary in most cases to prevent issues with ADL, but let's be consistent. This allows us to remove the libcpp-qualify-declval clang-tidy check, which is now enforced by the robust-against-adl clang-tidy check.
1 parent e11ca59 commit 5e26fb1

Some content is hidden

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

58 files changed

+313
-361
lines changed

libcxx/docs/CodingGuidelines.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Function overloading also applies to operators. Using ``&user_object`` may call
3636
...
3737
}
3838
39-
This is mostly enforced by the clang-tidy checks ``libcpp-robust-against-adl`` and ``libcpp-qualify-declval``.
39+
This is mostly enforced by the clang-tidy check ``libcpp-robust-against-adl``.
4040

4141
Avoid including public headers
4242
==============================

libcxx/include/__algorithm/ranges_iterator_concept.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {
4444
}
4545

4646
template <class _Iter>
47-
using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>());
47+
using __iterator_concept _LIBCPP_NODEBUG = decltype(ranges::__get_iterator_concept<_Iter>());
4848

4949
} // namespace ranges
5050
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__algorithm/stable_sort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
252252
is_integral_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;
253253
constexpr auto __allowed_radix_sort = __default_comp && __integral_value;
254254
if constexpr (__allowed_radix_sort) {
255-
if (__len <= __buff_size && __len >= static_cast<difference_type>(__radix_sort_min_bound<value_type>()) &&
256-
__len <= static_cast<difference_type>(__radix_sort_max_bound<value_type>())) {
255+
if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) &&
256+
__len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) {
257257
if (__libcpp_is_constant_evaluated()) {
258258
for (auto* __p = __buff; __p < __buff + __buff_size; ++__p) {
259259
std::__construct_at(__p);

libcxx/include/__chrono/formatter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
315315
case _CharT('T'):
316316
__facet.put(
317317
{__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
318-
if constexpr (__use_fraction<_Tp>())
318+
if constexpr (__formatter::__use_fraction<_Tp>())
319319
__formatter::__format_sub_seconds(__sstr, __value);
320320
break;
321321

@@ -378,7 +378,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
378378
break;
379379

380380
case _CharT('O'):
381-
if constexpr (__use_fraction<_Tp>()) {
381+
if constexpr (__formatter::__use_fraction<_Tp>()) {
382382
// Handle OS using the normal representation for the non-fractional
383383
// part. There seems to be no locale information regarding how the
384384
// fractional part should be formatted.

libcxx/include/__compare/common_comparison_category.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
5555
template <class... _Ts, bool _False = false>
5656
_LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {
5757
using _CCC = _ClassifyCompCategory;
58-
constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
58+
constexpr _CCC __type_kinds[] = {_StrongOrd, __comp_detail::__type_to_enum<_Ts>()...};
5959
constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds);
6060
if constexpr (__cat == _None)
6161
return void();

libcxx/include/__condition_variable/condition_variable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ inline void condition_variable::__do_timed_wait(
210210
unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {
211211
using namespace chrono;
212212
if (!__lk.owns_lock())
213-
__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
213+
std::__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
214214
nanoseconds __d = __tp.time_since_epoch();
215215
timespec __ts;
216216
seconds __s = duration_cast<seconds>(__d);
@@ -225,7 +225,7 @@ inline void condition_variable::__do_timed_wait(
225225
}
226226
int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts);
227227
if (__ec != 0 && __ec != ETIMEDOUT)
228-
__throw_system_error(__ec, "condition_variable timed_wait failed");
228+
std::__throw_system_error(__ec, "condition_variable timed_wait failed");
229229
}
230230
# endif // _LIBCPP_HAS_COND_CLOCKWAIT
231231

libcxx/include/__filesystem/directory_entry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class directory_entry {
286286
return;
287287
}
288288
if (__ec && (!__allow_dne || !__is_dne_error(__ec)))
289-
__throw_filesystem_error(__msg, __p_, __ec);
289+
filesystem::__throw_filesystem_error(__msg, __p_, __ec);
290290
}
291291

292292
_LIBCPP_HIDE_FROM_ABI void __refresh(error_code* __ec = nullptr) {

libcxx/include/__format/format_arg_store.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ consteval __arg_t __determine_arg_t() {
164164
template <class _Context, class _Tp>
165165
_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __value) noexcept {
166166
using _Dp = remove_const_t<_Tp>;
167-
constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>();
167+
constexpr __arg_t __arg = __format::__determine_arg_t<_Context, _Dp>();
168168
static_assert(__arg != __arg_t::__none, "the supplied type is not formattable");
169169
static_assert(__formattable_with<_Tp, _Context>);
170170

libcxx/include/__functional/function.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ class __value_func<_Rp(_ArgTypes...)> {
432432

433433
_LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {
434434
if (__f_ == nullptr)
435-
__throw_bad_function_call();
435+
std::__throw_bad_function_call();
436436
return (*__f_)(std::forward<_ArgTypes>(__args)...);
437437
}
438438

@@ -607,7 +607,7 @@ struct __policy_invoker<_Rp(_ArgTypes...)> {
607607
_LIBCPP_HIDE_FROM_ABI explicit __policy_invoker(__Call __c) : __call_(__c) {}
608608

609609
_LIBCPP_HIDE_FROM_ABI static _Rp __call_empty(const __policy_storage*, __fast_forward<_ArgTypes>...) {
610-
__throw_bad_function_call();
610+
std::__throw_bad_function_call();
611611
}
612612

613613
template <typename _Fun>

libcxx/include/__locale

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f)
154154
template <class _Facet>
155155
locale locale::combine(const locale& __other) const {
156156
if (!std::has_facet<_Facet>(__other))
157-
__throw_runtime_error("locale::combine: locale missing facet");
157+
std::__throw_runtime_error("locale::combine: locale missing facet");
158158

159159
return locale(*this, &const_cast<_Facet&>(std::use_facet<_Facet>(__other)));
160160
}
@@ -1298,7 +1298,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t,
12981298
const char16_t* __wn = (const char16_t*)__wb;
12991299
__r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf + __sz, __bn);
13001300
if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
1301-
__throw_runtime_error("locale not supported");
1301+
std::__throw_runtime_error("locale not supported");
13021302
for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
13031303
*__s = *__p;
13041304
__wb = (const _CharT*)__wn;
@@ -1326,7 +1326,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t,
13261326
const char32_t* __wn = (const char32_t*)__wb;
13271327
__r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf + __sz, __bn);
13281328
if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
1329-
__throw_runtime_error("locale not supported");
1329+
std::__throw_runtime_error("locale not supported");
13301330
for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
13311331
*__s = *__p;
13321332
__wb = (const _CharT*)__wn;
@@ -1370,7 +1370,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t
13701370
const char* __nn = __nb;
13711371
__r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);
13721372
if (__r == codecvt_base::error || __nn == __nb)
1373-
__throw_runtime_error("locale not supported");
1373+
std::__throw_runtime_error("locale not supported");
13741374
for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
13751375
*__s = *__p;
13761376
__nb = __nn;
@@ -1398,7 +1398,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t
13981398
const char* __nn = __nb;
13991399
__r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);
14001400
if (__r == codecvt_base::error || __nn == __nb)
1401-
__throw_runtime_error("locale not supported");
1401+
std::__throw_runtime_error("locale not supported");
14021402
for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
14031403
*__s = *__p;
14041404
__nb = __nn;

0 commit comments

Comments
 (0)