This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Wrap [[no_unique_address]] in a macro, for clang-cl
ClosedPublic

Authored by mstorsjo on Feb 10 2022, 5:18 AM.

Details

Summary

This, on top of D119134, allows enabling -Werror for the clang-cl
configurations.

Diff Detail

Event Timeline

mstorsjo created this revision.Feb 10 2022, 5:18 AM
mstorsjo requested review of this revision.Feb 10 2022, 5:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2022, 5:18 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision as: philnik.Feb 10 2022, 5:27 AM
philnik added a subscriber: philnik.

LGTM % comments

libcxx/include/__config
1404
1411
libcxx/include/__ranges/join_view.h
72

I'd personally keep [[no_unique_address]] here.

With this (and D119134) I think we could enable LIBCXX_ENABLE_WERROR in all CI configurations except for the couple GCC ones.

GCC builds seem to print (at least) this warning when building:

include/c++/v1/string:2267:32: error: enumerated and non-enumerated type in conditional expression [-Werror=extra]
 2267 |   size_type __cap = __is_short ? __min_cap : __get_long_cap();
mstorsjo marked 2 inline comments as done.Feb 10 2022, 5:32 AM
mstorsjo added inline comments.
libcxx/include/__ranges/join_view.h
72

Oh, oops. Yes this is a victim of search-and-replace...

mstorsjo updated this revision to Diff 407497.Feb 10 2022, 5:32 AM

Updated according to the suggestions.

With this (and D119134) I think we could enable LIBCXX_ENABLE_WERROR in all CI configurations except for the couple GCC ones.

GCC builds seem to print (at least) this warning when building:

include/c++/v1/string:2267:32: error: enumerated and non-enumerated type in conditional expression [-Werror=extra]
 2267 |   size_type __cap = __is_short ? __min_cap : __get_long_cap();

I'm working on making the GCC build warning-free, but I don't know how long it will take. There are still quite a few problems.

Mordante accepted this revision.Feb 10 2022, 9:44 AM
Mordante added a subscriber: Mordante.

LGTM! Do you want to make a similar commit to update the tests? I was there as a discussion on Discord, so please wait a bit before committing in case @ldionne wants to chime in.

libcxx/include/__config
1408

Would it make sense to test this first? Then line 1401 doesn't need _MSC_VER and comment is only needed for msvc::no_unique_address.

1417

I'm not sure we want to make this an error in the future. In general we don't do that so we can use these macros in older language standards.

libcxx/utils/ci/run-buildbot
573 ↗(On Diff #407497)

Can you commit the changes to this file in a separate commit?

This revision is now accepted and ready to land.Feb 10 2022, 9:44 AM

Do you want to make a similar commit to update the tests?

Hmm, is this used in tests somewhere too? (Haven’t grepped there yet, on the phone right now.) Those are already built with -Werror iirc, so they should have caused an issue already, but I can look closer a bit later.

libcxx/include/__config
1408

I think that could work too. Then I think we’d still be warning free, as __has_cpp_attribute() should indicate that it isn’t available in clang-cl now.

1417

No strings opinion on that - but AFAIK we only use this in C++20-only contexts anyway, as we’d have an inconsistent ABI otherwise.

libcxx/utils/ci/run-buildbot
573 ↗(On Diff #407497)

Yeah, it probably makes more sense to split out that too a separate commit - just bundled it here to show that we do get these configs warning free.

Quuxplusone accepted this revision.Feb 10 2022, 10:42 AM

LGTM too, although we should understand whether the CI failures are related, and @ldionne should probably be aware of this new macro.

libcxx/include/__config
1408

+1

1417

Please remove the /* nothing */ comment, as we don't do that anywhere else AFAIK.

libcxx/include/__ranges/join_view.h
72

Nobody knows why this comment is here; we should just remove it. But D119208 is related (and attn @jloser, for the merge conflict that will inevitably occur here)

Do you want to make a similar commit to update the tests?

Hmm, is this used in tests somewhere too? (Haven’t grepped there yet, on the phone right now.) Those are already built with -Werror iirc, so they should have caused an issue already, but I can look closer a bit later.

I knew I had seen it, seems there's only one occurrence. Some other tests will probably start to fail in the near future since they contains XFAIL: msvc due to the lack of [[unique_address]] support.

libcxx/include/__config
1417

@mstorsjo good point regarding the ABI, maybe add that in the comment as justification why we want to make in an #error after clang-cl support the attribute.

@Quuxplusone I considered the same comment, but line 1398 disproves the statement ;-) _LIBCPP_EXTERN_TEMPLATE also has nothings.

1417

No strings opinion on that - but AFAIK we only use this in C++20-only contexts anyway, as we’d have an inconsistent ABI otherwise.

mstorsjo updated this revision to Diff 407657.Feb 10 2022, 1:08 PM

Reordered the preference between [[msvc::no_unique_address]] and [[no_unique_address]] as requestd, adjusted the comments based on that

Mordante accepted this revision.Feb 11 2022, 9:14 AM

Reordered the preference between [[msvc::no_unique_address]] and [[no_unique_address]] as requestd, adjusted the comments based on that

Thanks! Still LGTM!

jloser added inline comments.Feb 11 2022, 9:32 AM
libcxx/include/__ranges/join_view.h
72

@Quuxplusone thanks for the ping here. I certainly don't know why the comment is here as you know. I'd be OK removing it (and also marking __base_ as _LIBCPP_NO_UNIQUE_ADDRESS FWIW - effectively what I did in https://reviews.llvm.org/D119208)

ldionne accepted this revision.Feb 11 2022, 10:07 AM

LGTM, and the CI failures are unrelated.

This revision was landed with ongoing or failed builds.Feb 11 2022, 12:04 PM
This revision was automatically updated to reflect the committed changes.