This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] adds concept std::movable
ClosedPublic

Authored by cjdb on Feb 23 2021, 11:06 PM.

Details

Summary

Implements parts of:

  • P0898R3 Standard Library Concepts
  • P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97162

Diff Detail

Event Timeline

cjdb requested review of this revision.Feb 23 2021, 11:06 PM
cjdb created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2021, 11:06 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

I had a quick look, I'll have a closer look later.

libcxx/include/concepts
370

T -> _Tp

cjdb updated this revision to Diff 325994.Feb 23 2021, 11:16 PM

uglifies names

cjdb marked an inline comment as done.Feb 23 2021, 11:19 PM

Some small issues, but like to see the build pass before approving.

libcxx/test/std/concepts/object/movable.compile.pass.cpp
13

Please remove class From, .

22

I see the single thread build node is failing. Can you guard the usage of types defined in this header to be excluded if libc++ is build without thread support.

cjdb updated this revision to Diff 326282.Feb 24 2021, 9:54 PM

attempts @Mordante's feedback

cjdb marked 2 inline comments as done.Feb 24 2021, 9:55 PM
cjdb updated this revision to Diff 326283.Feb 24 2021, 10:04 PM

properly applies @Mordante's feedback

cjdb updated this revision to Diff 326286.Feb 24 2021, 10:43 PM

adds more types to test

cjdb updated this revision to Diff 326287.Feb 24 2021, 10:45 PM

adds new types to test

cjdb updated this revision to Diff 326591.Feb 25 2021, 8:38 PM

rebases to activate CI

cjdb updated this revision to Diff 328723.Mar 5 2021, 8:37 PM

rebases and fixes things up to keep in line with prior commits

cjdb updated this revision to Diff 328725.Mar 5 2021, 8:45 PM

renames object.h to movable.h

cjdb updated this revision to Diff 328728.Mar 5 2021, 8:52 PM

gets this passing CI

Quuxplusone added a subscriber: Quuxplusone.

As usual, the code in <concepts> is "obviously correct" (and the tests are more verbose than I'd wish, but I don't intend to hold it up over that). LGTM%nits, if tests pass.

libcxx/test/std/concepts/object/movable.compile.pass.cpp
114

I don't see what these cases have to do with the concept; aren't these just a list of ways a type can fail to be assignable at all? I'd just write one non-assignable type right here in this file and then test that one.
But I guess since you've already written all the code, maybe it's too late to ask for it to be shortened (or maybe you only lengthened it in the first place due to someone else's feedback, I dunno).

libcxx/test/std/concepts/object/movable.h
49 ↗(On Diff #328728)

This is not a move constructor.
Also, I don't know what the overload set ends up looking like here; do you expect there to be a defaulted operator=(const_move_constructor&&) as well? What about a defaulted operator=(const const_move_constructor&)?

cjdb updated this revision to Diff 328822.Mar 6 2021, 3:03 PM

applies some of @Quuxplusone's feedback

libcxx/test/std/concepts/object/movable.compile.pass.cpp
13

Fixed properly this time.

114

I think we're in agreement that these can stay per https://reviews.llvm.org/D97443#inline-920565.

libcxx/test/std/concepts/object/movable.h
49 ↗(On Diff #328728)

This is not a move constructor.

Wow.

Also, I don't know what the overload set ends up looking like here; do you expect there to be a defaulted operator=(const_move_constructor&&) as well? What about a defaulted operator=(const const_move_constructor&)?

I only expected this overload, since it's a user-declared move assignment operator. I've added a few new tests around this topic.

cjdb updated this revision to Diff 328830.Mar 6 2021, 7:31 PM

rebases to activate CI

zoecarver added inline comments.
libcxx/test/std/concepts/object/movable.h
71 ↗(On Diff #328830)

I think it would be good to run added tests through clang-format. (If this is what clang-format generated, no worries.)

cjdb added inline comments.Mar 8 2021, 11:19 AM
libcxx/test/std/concepts/object/movable.h
71 ↗(On Diff #328830)

arc diff won't let you submit without first committing the changes clang-format makes :-)
(FWIW I think our .clang-format is very underspecified.)

zoecarver added inline comments.Mar 8 2021, 11:20 AM
libcxx/test/std/concepts/object/movable.h
71 ↗(On Diff #328830)

Fair enough. Thanks :)

curdeius added inline comments.Mar 8 2021, 1:19 PM
libcxx/test/std/concepts/object/movable.h
71 ↗(On Diff #328830)

You always can use arc diff --nolint.

cjdb updated this revision to Diff 329723.Mar 10 2021, 11:51 AM
cjdb marked 4 inline comments as done.

applies @zoecarver's feedback on headers from D97443

EricWF accepted this revision.Mar 11 2021, 11:19 AM

LGTM. Nice tests, and thank you for moving the test header into support.

This revision is now accepted and ready to land.Mar 11 2021, 11:19 AM
This revision was automatically updated to reflect the committed changes.