This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Provide c++03 alternative for va_copy if available in xlocale.h
ClosedPublic

Authored by jasonliu on Apr 12 2021, 12:10 PM.

Details

Summary

If we are on c++03 mode for some reason, and __va_copy is available, then use it instead of error out on not having va_copy in 03 mode.

Diff Detail

Event Timeline

jasonliu requested review of this revision.Apr 12 2021, 12:10 PM
jasonliu created this revision.
ldionne requested changes to this revision.Apr 12 2021, 2:44 PM
ldionne added inline comments.
libcxx/include/__support/ibm/xlocale.h
314

This is part of the C standard and should be provided by your implementation. Yes, I know C++03 is technically not built on top of C99 IIRC, but asking your implementation to support it as an extension is the way to go IMO. Using an identifier internal to the specific C library you're using isn't a good solution if there are other alternatives IMO.

This revision now requires changes to proceed.Apr 12 2021, 2:44 PM
jasonliu updated this revision to Diff 337570.Apr 14 2021, 2:54 PM

Use __builtin_va_copy instead.

jasonliu added inline comments.Apr 14 2021, 2:58 PM
libcxx/include/__support/ibm/xlocale.h
314

It might not be a good idea to expose va_copy in non-C99 or above mode because it could pollute user's namespace.
I used the builtin version here instead. Let me know if that address your concern.

Gentle ping.

Ping.
@ldionne Any comments?

ldionne accepted this revision.Jun 30 2021, 2:15 PM
ldionne added inline comments.
libcxx/include/__support/ibm/xlocale.h
314

This seems reasonable to me, but please add a comment like // va_copy may not be provided by the C library in C++03 mode

This revision is now accepted and ready to land.Jun 30 2021, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2021, 11:03 AM