This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Make a few standard types trivially equality comparable
AbandonedPublic

Authored by philnik on May 7 2023, 6:40 PM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Summary

This allows std::equal and other algorithms be optimized better.

Diff Detail

Event Timeline

philnik created this revision.May 7 2023, 6:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2023, 6:40 PM
philnik requested review of this revision.May 7 2023, 6:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2023, 6:40 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested changes to this revision.May 8 2023, 9:27 AM

I think this LGTM w/ comments applied, but I'd like to see it one last time w/ green CI and comments applied before we ship this.

libcxx/include/__exception/exception_ptr.h
1

libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp is very very light, it doesn't even test for != -- can you add a test for that?

39

Please add a comment explaining that this allows making the class trivially equality comparable.

libcxx/include/__expected/unexpected.h
111

Please add a comment like:

// conforming extension: this is not observable beyond SFINAE but it allows making `unexpected` trivially comparable
libcxx/include/array
266

Same thing, please add a comment throughout whenever it's a public API. For example not in __wrap_iter.

libcxx/include/forward_list
395

No need for public:, we're already in public. Please check throughout.

libcxx/include/tuple
1316

Can you please ensure that we have tests for comparing tuples that contain reference types?

This revision now requires changes to proceed.May 8 2023, 9:27 AM
philnik updated this revision to Diff 523819.May 19 2023, 9:17 AM
philnik marked 6 inline comments as done.

Address comments

philnik updated this revision to Diff 523964.May 19 2023, 4:24 PM

Try to fix CI

philnik updated this revision to Diff 524402.May 22 2023, 11:16 AM

Try to fix CI

ldionne added inline comments.May 23 2023, 10:20 AM
libcxx/include/array
266
libcxx/include/tuple
1345

Conforming extension comment?

libcxx/test/libcxx/types_are_trivially_equality_comparable.compile.pass.cpp
39

Per your comment, you might be able to uncomment this now.

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
17

About your CI issues, I think this might be a compiler bug:

Works with all compilers: https://godbolt.org/z/Pc8bqczvo
Works with GCC but not Clang/MSVC: https://godbolt.org/z/j68j4Ezcn

I think they should both work on all compilers.

Edit: The problem seems to be that Clang and MSVC will instantiate operator== a bit too eagerly: https://godbolt.org/z/5hMKWzoMs, which triggers ADL on Holder<Incomplete>.

philnik abandoned this revision.Aug 31 2023, 4:57 PM

Abandoning for now, since this requires some sort of compiler fix to work properly and this won't happen within the next month or so.