This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Make sure __bit_iterator does not use deprecated SMF generation
ClosedPublic

Authored by Quuxplusone on Apr 23 2021, 10:17 AM.

Details

Summary

This allows us to turn -Wdeprecated-copy back on, which a recent Clang
commit broke when the warning became more stringent.

Diff Detail

Event Timeline

ldionne created this revision.Apr 23 2021, 10:17 AM
ldionne requested review of this revision.Apr 23 2021, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2021, 10:17 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
xbolva00 accepted this revision.Apr 23 2021, 10:36 AM

Thanks for the fix

Quuxplusone requested changes to this revision.EditedApr 23 2021, 12:21 PM

You probably saw my Slack, but for the record, I think we want this:

public:
    _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
    : __seg_(nullptr), __ctz_(0)
#endif
    {}

    // When _IsConst=false, this is the copy constructor.
    // It is non-trivial. We maintain this for ABI purposes.
    _LIBCPP_INLINE_VISIBILITY
    __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
        : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}

    // When _IsConst=false, we have a user-provided copy constructor,
    // so we must also provide a copy assignment operator because
    // the implicit generation of a defaulted one is deprecated.
    _LIBCPP_INLINE_VISIBILITY
    __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
        __seg_ = __it.__seg_;
        __ctz_ = __it.__ctz_;
        return *this;
    }

    _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
        {return reference(__seg_, __storage_type(1) << __ctz_);}
This revision now requires changes to proceed.Apr 23 2021, 12:21 PM
Quuxplusone commandeered this revision.Apr 24 2021, 5:22 AM
Quuxplusone edited reviewers, added: ldionne; removed: Quuxplusone.

Previous (failing) buildkite run is in https://buildkite.com/llvm-project/libcxx-ci/builds/2759 . I'm about to update this PR with my suggested patch.

Apply my suggested patch instead. Let's see what buildkite thinks of this. (I think it'll pass, but let's see.)

Stupid question... but what's SMF?

ldionne accepted this revision.Apr 26 2021, 5:42 AM
ldionne added inline comments.
libcxx/include/__bit_reference
1118

Maybe mention the obvious:

When _IsConst=true, the copy-constructor is the default compiler-generated one, which is trivial.

This revision is now accepted and ready to land.Apr 26 2021, 5:42 AM