This is an archive of the discontinued LLVM Phabricator instance.

[libc++] `= delete` member functions with // = delete;
ClosedPublic

Authored by philnik on Dec 7 2021, 3:00 PM.

Details

Summary

Use = delete for member functions that are marked with // = delete;

Diff Detail

Event Timeline

philnik requested review of this revision.Dec 7 2021, 3:00 PM
philnik created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2021, 3:00 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Dec 7 2021, 3:27 PM

LGTM -- this one definitely has no ABI impact :)

I believe this might in some cases turn link errors into compile-time errors, but that's fine.

For some reason, I also have a feeling that this might make code that used to compile not compile anymore. From https://en.cppreference.com/w/cpp/language/function#Deleted_functions:

If the function is overloaded, overload resolution takes place first, and the program is only ill-formed if the deleted function was selected.

I believe I've seen some cases where deleted functions would cause hard errors to happen instead of SFINAE, because the deleted function would be viable, but when the compiler would select and try to instantiate it, it would say "you can't do that, the function is deleted". But I'm failing to reproduce that, so I guess it's not a real issue: https://godbolt.org/z/YjMK9G6qs

This revision is now accepted and ready to land.Dec 7 2021, 3:27 PM
jloser added a subscriber: jloser.Dec 7 2021, 3:37 PM
jloser added inline comments.
libcxx/include/__locale
211

Interesting to see a copy assignment operator with return type of void. Is that actually intended? I suspect this meant to be id& operator=(const id&) = delete; surely, right?

Ditto with seed_seq below in another file.

Quuxplusone accepted this revision.Dec 7 2021, 7:08 PM
Quuxplusone added inline comments.
libcxx/include/__locale
211

The return type of a deleted overload is unobservable, so it doesn't really matter. But this is exactly implementing https://eel.is/c++draft/locale.id<locale> is full of weird return types — so IMHO this diff is good as-is.

libcxx/include/__mutex_base
145–146

Could remove line 146 now.

libcxx/include/__random/random_device.h
53

http://eel.is/c++draft/rand.device specifies this return type as void also. Change it?
Also, I'd actually leave these down around line 60, just to match the order they're specified in [rand.device].

libcxx/include/__random/seed_seq.h
66–68

This unobservable void matches the specification in https://eel.is/c++draft/rand.util.seedseq and therefore LGTM.

libcxx/include/ios
313–314

Remove line 314?

libcxx/include/istream
293–294

Nit: Make these public (and move them down to line 302) to match https://eel.is/c++draft/istream.sentry

libcxx/include/mutex
220

Nit: Let's keep a blank line after 219, for consistency with the spec and with line 241.
Ditto after line 283.

philnik updated this revision to Diff 392684.Dec 8 2021, 1:58 AM
philnik marked 8 inline comments as done.

Style changes that were requested

This revision was automatically updated to reflect the committed changes.