This is an archive of the discontinued LLVM Phabricator instance.

[SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists
AcceptedPublic

Authored by MitalAshok on Jul 23 2023, 1:35 PM.

Details

Reviewers
EricWF
CornedBee
erichkeane
royjacobson
cor3ntin
Group Reviewers
Restricted Project
Summary

This allows the implicitly-generated deduction guide for the copy constructor to be recognised as an initializer-list constructor, allowing CTAD for std::initializer_list

Diff Detail

Event Timeline

MitalAshok created this revision.Jul 23 2023, 1:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2023, 1:35 PM
MitalAshok published this revision for review.Jul 23 2023, 1:59 PM

The implicitly-generated guide for template<class E> struct initializer_list;'s copy constructor's first argument is an injected-class-name. When it was not recognised as an initializer_list, it was erroneously excluded when the initializer was a braced-init-list.

Also falls foul of -Wctad-maybe-unsupported. Looks like this is being worked on in https://reviews.llvm.org/D133425 but should std::initializer_list{ a, b, c } be a built-in exception to this diagnostic? If not, I would recommend using _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(initializer_list) in libc++ from https://reviews.llvm.org/D133535. For comparison, GCC does not warn with -Wctad-maybe-unsupported.

Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2023, 1:59 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Remove now unneeded FIXME

shafik added reviewers: Restricted Project, royjacobson.Jul 24 2023, 2:38 PM
shafik added a subscriber: shafik.Jul 24 2023, 3:01 PM

This makes sense I see that isStdInitializerList(...) is used in a lot of places, this makes me wonder if we need additional test coverage.

I also added some folks for more review visibility.

Rebase changelog to clang 18, add more tests

cor3ntin accepted this revision.Jul 27 2023, 12:36 AM
cor3ntin added a subscriber: cor3ntin.

LGTM, thanks!

This revision is now accepted and ready to land.Jul 27 2023, 12:36 AM
cor3ntin added inline comments.Jul 27 2023, 12:37 AM
clang/docs/ReleaseNotes.rst
111

wording of changelog

MitalAshok edited the summary of this revision. (Show Details)Jul 27 2023, 3:06 AM
MitalAshok marked an inline comment as done.

@MitalAshok Do you need me to land that for you> If so, what email should i use?