This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove _LIBCPP_DEFAULT
ClosedPublic

Authored by philnik on Dec 7 2021, 11:43 AM.

Details

Reviewers
ldionne
Quuxplusone
Group Reviewers
Restricted Project
Commits
rG4955095fe69f: [libc++] Remove _LIBCPP_DEFAULT
Summary

clang has = default as an extension in c++03, so just use it.

Diff Detail

Event Timeline

philnik requested review of this revision.Dec 7 2021, 11:43 AM
philnik created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2021, 11:43 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Dec 7 2021, 12:09 PM

Awesome -- LGTM if CI passes.

This revision is now accepted and ready to land.Dec 7 2021, 12:09 PM
Quuxplusone requested changes to this revision.Dec 7 2021, 12:14 PM
Quuxplusone added inline comments.
libcxx/include/__config
840–844

I have looked at this in the past and decided not to mess with it, because it changes our ABI in C++03 mode. @ldionne, could you take another look with ABI in mind and just confirm whether this still LGTY?

Remember =defaulted members can be trivial, but {}'ed members are never trivial, for purposes of ABI.

This revision now requires changes to proceed.Dec 7 2021, 12:14 PM
philnik added inline comments.Dec 7 2021, 12:29 PM
libcxx/include/__config
840–844

Isn't _LIBCPP_HIDE_FROM_ABI supposed to mitiagte that problem?

Quuxplusone accepted this revision.Dec 7 2021, 1:01 PM
Quuxplusone added inline comments.
libcxx/include/__config
840–844

No, in that we're talking about a property of the type (whether it's trivially foo-constructible), not a property of the member function per se.

However, I'm retracting my concern, because I just looked for myself: _LIBCPP_DEFAULT is currently used in only the places touched in this PR, and:

  • std::allocator already does crazy things with inheritance to get the right trivially-default-constructibility in all modes, so it's not affected in C++03 mode by this patch AFAICT
  • std::atomic<T> inherits from __cxx_atomic_base_impl which is non-trivial in C++03 mode, so it remains non-trivial in C++03 mode even after this patch
  • std::error_category is polymorphic, so it's never trivially default constructible in any mode

I now say: Ship it! :)

This revision is now accepted and ready to land.Dec 7 2021, 1:01 PM
This revision was automatically updated to reflect the committed changes.
ldionne added inline comments.Dec 7 2021, 3:04 PM
libcxx/include/__config
840–844

Excellent observation though @Quuxplusone , I hadn't thought about that. I went really fast on the same streak as removing all the other C++03-or-older-compiler workarounds and missed this important fact.

As you say, we're lucky and it's not actually an ABI break, but thanks for paying attention. This sort of ABI break (changing the triviality of widely used types) is the sort of thing that would break in the worst possible ways -- we'd certainly hear about it.