llvm-project/libcxx/src
Martin Storsjö 7db4f2c694 [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_t
This fixes using non-default locales, which currently can crash when
e.g. formatting numbers.

Within the localeconv_l function, the per-thread locale is temporarily
changed with __libcpp_locale_guard, then localeconv() is called,
returning an lconv * struct pointer.

When localeconv_l returns, the __libcpp_locale_guard dtor restores
the per-thread locale back to the original. This invalidates the
contents of the earlier returned lconv struct, and all C strings
that are pointed to within it are also invalidated.

Thus, to have an actually working localeconv_l function, the
function needs to allocate some sort of storage for the returned
contents, that stays valid for as long as the caller needs to use
the returned struct.

Extend the libcxx/win32 specific locale_t class with storage for
a deep copy of a lconv struct, and change localeconv_l to take
a reference to the locale_t, to allow it to store the returned
lconv struct there.

This works fine for libcxx itself, but wouldn't necessarily be right
for a caller that uses libcxx's localeconv_l function.

This fixes around 11 of libcxx's currently failing tests on windows.

Differential Revision: https://reviews.llvm.org/D69505
2020-01-29 22:37:11 +02:00
..
experimental [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
filesystem [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
include [WebAssembly] WASI support for libcxx 2019-05-01 16:47:30 +00:00
support [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_t 2020-01-29 22:37:11 +02:00
CMakeLists.txt [libc++] Move the linker script generation step to CMake 2019-10-08 21:10:20 +00:00
algorithm.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
any.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
bind.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
charconv.cpp [libc++] Fix leading zeros in std::to_chars 2019-06-10 17:11:46 +00:00
chrono.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
condition_variable.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
condition_variable_destructor.cpp Make ~mutex and ~condition_variable trivial on Windows. 2019-07-07 17:24:03 +00:00
debug.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
exception.cpp [libc++] Remove redundant conditionals for Apple platforms 2019-04-23 14:05:04 +00:00
functional.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
future.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
hash.cpp [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
ios.cpp [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
iostream.cpp Only initialize the streams cout/wcout/cerr/wcerr etc once, rather than any time Init::Init is called. Fixes PR#43300 2019-09-13 15:28:06 +00:00
locale.cpp Replace old-style cast of null pointer with nullptr 2020-01-23 02:20:09 +01:00
memory.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
mutex.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
mutex_destructor.cpp [libc++][NFC] Remove excess trailing newlines from most files 2019-10-23 08:08:57 -07:00
new.cpp [libc++][CMake] Remove unnecessary conditional for defining new handlers 2019-04-17 21:57:49 +00:00
optional.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
random.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
regex.cpp [libc++] Validate the entire regex is consumed 2019-11-09 17:01:37 +01:00
shared_mutex.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
stdexcept.cpp Fix ABI compatibility of `<stdexcept>` with VCRuntime. 2019-03-06 20:31:57 +00:00
string.cpp [libc++] Explicitly enumerate std::string external instantiations - Attempt 2 2020-01-15 17:12:49 -05:00
strstream.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
system_error.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
thread.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
typeinfo.cpp [libc++] Remove redundant conditionals for Apple platforms 2019-04-23 14:05:04 +00:00
utility.cpp [libc++] Take 2: Implement LWG 2510 2019-09-26 14:51:10 +00:00
valarray.cpp [libc++] Always build with -fvisibility=hidden 2019-08-13 15:02:53 +00:00
variant.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
vector.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00