[libcxx-commits] [libcxx] a319eaf - [libc++] Provide c++03 alternative for va_copy if available in xlocale.h
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 1 11:02:57 PDT 2021
Author: jasonliu
Date: 2021-07-01T18:02:38Z
New Revision: a319eafd160d8d8f3ebd47a3a636e01597b36bff
URL: https://github.com/llvm/llvm-project/commit/a319eafd160d8d8f3ebd47a3a636e01597b36bff
DIFF: https://github.com/llvm/llvm-project/commit/a319eafd160d8d8f3ebd47a3a636e01597b36bff.diff
LOG: [libc++] Provide c++03 alternative for va_copy if available in xlocale.h
Summary:
If we are on c++03 mode for some reason, and __builtin_va_copy is
available, then use it instead of error out on not having va_copy
in 03 mode.
Reviewed by: ldionne
Differential Revision: https://reviews.llvm.org/D100336
Added:
Modified:
libcxx/include/__support/ibm/xlocale.h
Removed:
################################################################################
diff --git a/libcxx/include/__support/ibm/xlocale.h b/libcxx/include/__support/ibm/xlocale.h
index 77ac02a2241ac..58bdc67af9681 100644
--- a/libcxx/include/__support/ibm/xlocale.h
+++ b/libcxx/include/__support/ibm/xlocale.h
@@ -310,7 +310,12 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
}
va_list ap_copy;
+ // va_copy may not be provided by the C library in C++ 03 mode.
+#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
+ __builtin_va_copy(ap_copy, ap);
+#else
va_copy(ap_copy, ap);
+#endif
int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
va_end(ap_copy);
More information about the libcxx-commits
mailing list