This is an archive of the discontinued LLVM Phabricator instance.

[libc++][CI] Fixes robust against ADL for C++03.
ClosedPublic

Authored by Mordante on Dec 28 2022, 11:04 AM.

Details

Reviewers
philnik
Group Reviewers
Restricted Project
Commits
rG0c731b0c00f5: [libc++][CI] Fixes robust against ADL for C++03.
Summary

This was disabled in D139545.

Diff Detail

Event Timeline

Mordante created this revision.Dec 28 2022, 11:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 11:04 AM
Herald added a subscriber: arichardson. · View Herald Transcript
Mordante requested review of this revision.Dec 28 2022, 11:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 11:04 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Where does this fire? noexcept(cond) should never be used in C++03.

Where does this fire? noexcept(cond) should never be used in C++03.

include/__functional/invoke.h lines 431 and 438 are the only two places

template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
{
    typedef __nothrow_invokable_r_imp _ThisT;
  
    template <class _Tp>
    static void __test_noexcept(_Tp) _NOEXCEPT;
  
    static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(  // 431
        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
};    
  
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
    static const bool value = noexcept(                                 / 438
        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); 
};

Where does this fire? noexcept(cond) should never be used in C++03.

include/__functional/invoke.h lines 431 and 438 are the only two places

template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
{
    typedef __nothrow_invokable_r_imp _ThisT;
  
    template <class _Tp>
    static void __test_noexcept(_Tp) _NOEXCEPT;
  
    static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(  // 431
        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
};    
  
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
    static const bool value = noexcept(                                 / 438
        _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); 
};

IMO we should fix the code here. In C++03 the values are always false anyways, so we could just make this

template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
{
    typedef __nothrow_invokable_r_imp _ThisT;
  
    template <class _Tp>
    static void __test_noexcept(_Tp) _NOEXCEPT;

#ifdef _LIBCPP_CXX03_LANG
    static const bool value = false;
#else
    static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
#endif
};    
  
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
#ifdef _LIBCPP_CXX03_LANG
    static const bool value = false;
#else
    static const bool value = noexcept(_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); 
#endif
};

or something similar.

Mordante updated this revision to Diff 487169.Jan 8 2023, 5:17 AM

Uses an alternative approach as suggested by philnik.

philnik accepted this revision.Jan 8 2023, 5:20 AM

LGTM with green CI.

This revision is now accepted and ready to land.Jan 8 2023, 5:20 AM
This revision was landed with ongoing or failed builds.Jan 8 2023, 7:43 AM
This revision was automatically updated to reflect the committed changes.