summaryrefslogtreecommitdiffstats
path: root/libcxx/src/locale.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx][NFC] Strip trailing whitespace, fix typo.Stephan T. Lavavej2019-10-231-2/+2
|
* Fix a '>= 0' test on unsigned that I inadvertantly introduced. Now correctly ↵Marshall Clow2019-06-171-1/+1
| | | | | | '!= 0'. Thanks to Arthur for the catch llvm-svn: 363557
* No longer reject inputs when using a locale that has grouping information ↵Marshall Clow2019-06-041-1/+3
| | | | | | _and_ the input has no grouping characters at all. We continue to reject cases when the input has grouping characters in the wrong place. Fixes PR#28704 llvm-svn: 362508
* [libc++] Avoid UB in the no-exceptions mode in a few placesLouis Dionne2019-02-121-13/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: A few places in the library seem to behave unexpectedly when the library is compiled or used with exceptions disabled. For example, not throwing an exception when a pointer is NULL can lead us to dereference the pointer later on, which is UB. This patch fixes such occurences. It's hard to tell whether there are other places where the no-exceptions mode misbehaves like this, because the replacement for throwing an exception does not always seem to be abort()ing, but at least this patch will improve the situation somewhat. See http://lists.llvm.org/pipermail/libcxx-dev/2019-January/000172.html Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D57761 llvm-svn: 353850
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Fix locale test data for GLIBC 2.27 and newer.Eric Fiselier2018-04-041-0/+1
| | | | | | | | GLIBC 2.27 changed the locale data for fr_FR and ru_RU. In particular they change the decimal and thousands separators used. This patch makes the locale tests tolerate the updated locales. llvm-svn: 329143
* Fix some too-big local arrays. Thanks to dcdillon for the patch. Reviewed as ↵Marshall Clow2018-01-111-2/+2
| | | | | | D28217 llvm-svn: 322295
* [libc++] Replace __sync_* functions with __libcpp_atomic_* functionsWeiming Zhao2017-09-191-1/+2
| | | | | | | | | | | | | | | | Summary: This patch replaces __sync_* with __libcpp_atomic_* and adds a wrapper function for __atomic_exchange to support _LIBCPP_HAS_NO_THREADS. Reviewers: EricWF, jroelofs, mclow.lists, compnerd Reviewed By: EricWF, compnerd Subscribers: compnerd, efriedma, cfe-commits, joerg, llvm-commits Differential Revision: https://reviews.llvm.org/D35235 llvm-svn: 313694
* Revert "[libc++] Refactoring __sync_* builtins; NFC (Reland)"Eric Fiselier2017-07-121-2/+1
| | | | | | | This reverts commit r307595. The commit had some issues that needed to first be addressed in review. llvm-svn: 307746
* [libc++] Refactoring __sync_* builtins; NFC (Reland)Weiming Zhao2017-07-101-1/+2
| | | | | | | | | | | | Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets. Reviewers: danalbert, EricWF, jroelofs Subscribers: joerg, llvm-commits Differential Revision: https://reviews.llvm.org/D34918 llvm-svn: 307595
* Revert "[libc++] Refactoring __sync_* builtins; NFC"Weiming Zhao2017-07-101-1/+1
| | | | | | This reverts commit 72ff8866bca49ee7d24c87673293b4ce88a039ec. llvm-svn: 307593
* [libc++] Refactoring __sync_* builtins; NFCWeiming Zhao2017-07-101-1/+1
| | | | | | | | | | | | Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets. Reviewers: danalbert, EricWF, jroelofs Subscribers: joerg, llvm-commits Differential Revision: https://reviews.llvm.org/D34918 llvm-svn: 307591
* Move external instantiation for __vector_base_common to vector.cppEric Fiselier2017-06-151-2/+0
| | | | | | | | Previously the explicit instantiation for this was in locale.cpp, but that didn't make much sense. This patch creates a new vector.cpp source file to contain the explicit instantiation. llvm-svn: 305442
* [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on WindowsEric Fiselier2017-05-311-0/+1
| | | | | | | | | | | | | | | | Summary: This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning. This patch changes libc++ to use `#pragma push_macro` to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header. Reviewers: mclow.lists, bcraig, compnerd, EricWF Reviewed By: EricWF Subscribers: cfe-commits, krytarowski Differential Revision: https://reviews.llvm.org/D33080 llvm-svn: 304357
* Refactor <locale> RAII guards to aid upcoming Windows locale changes.Eric Fiselier2017-05-081-14/+32
| | | | | | | | | | | | | | | | | | | Previously <locale> used std::unique_ptr<remove_ptr<locale_t>, locale-mgmt-function> as a scope guard for (A) creating new locales, and (B) setting the thread specific locale in RAII safe manner. However using unique_ptr has some problems, first it requires that locale_t is a pointer type, which may not be the case (Windows will need a non-pointer locale_t type that emulates _locale_t). The second problem is that users of the guards had to supply the locale management function to the custom deleter at every call site. However these locale management functions don't exist natively Windows, making a good Windows implementation of locale more difficult. This patch creates distinct and simply RAII guards that replace unique_ptr. These guards handle calling the correct locale management function so that callers don't have too. This simplification will aid in upcoming Windows fixes. llvm-svn: 302474
* Fix new warnings emitted by GCC 7Eric Fiselier2017-05-051-6/+6
| | | | llvm-svn: 302280
* [libc++] Drop support for CRTs older than VS 2015Shoaib Meenai2017-04-071-6/+0
| | | | | | | | | | | LLVM dropped support for Visual Studio versions older than 2015 quite some time ago, so I consider it safe to drop libc++'s support for older CRTs. The CRT in Visual Studio 2015 provides a lot of previously missing functions, so targeting it requires less special casing. Differential Revision: https://reviews.llvm.org/D31798 llvm-svn: 299743
* Remove a now unneeded __CloudABI__ check.Ed Schouten2017-02-111-2/+0
| | | | | | | CloudABI has gained the setlocale() function in the meantime, meaning there is no longer a need to conditionalize this. llvm-svn: 294833
* Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.Eric Fiselier2017-01-061-1/+1
| | | | | | | | | | | | This patch refactors the compiler detection done in `__config` by creating a set of `_LIBCPP_COMPILER_<TYPE>` macros. The goal of this patch is to make it easier to detect what compiler is being used outside of `__config`. Additionally this patch removes workarounds for GCC in `__bit_reference`. I tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it anymore. llvm-svn: 291286
* clean up use of _WIN32Saleem Abdulrasool2017-01-031-3/+3
| | | | | | | | | Replace the use of _WIN32 in libc++. Replace most use with a C runtime check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we are on an environment that has a short wchar_t. llvm-svn: 290910
* locale: update ctype access for MSVC CRT 14+Saleem Abdulrasool2017-01-021-2/+9
| | | | | | | | | | | Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours of the ucrt for different environments. This changed the access to the ctype table by introducing the `__pctype_func` and `__pwctype_func` accessors. Use this rather than directly accessing `_ctype` which allows us to be safer in threaded situations by going through the libc locking. llvm-svn: 290823
* [libc++] Fix support for multibyte thousands_sep and decimal_point in ↵Eric Fiselier2016-12-111-42/+91
| | | | | | | | | | | | | | | | | | moneypunct_byname and numpunct_byname. Summary: The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`. This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value. Reviewers: mclow.lists, EricWF Subscribers: vangyzen, george.burgess.iv, cfe-commits Differential Revision: https://reviews.llvm.org/D24218 llvm-svn: 289347
* [libc++] Fix extern template visibility for WindowsShoaib Meenai2016-09-191-43/+43
| | | | | | | | | | On Windows, marking an `extern template class` declaration as exported actually forces an instantiation, which is not the desired behavior. Instead, the actual explicit instantiations need to be exported. Differential Revision: https://reviews.llvm.org/D24679 llvm-svn: 281925
* Replace __ANDROID__ with __BIONIC__.Dan Albert2016-09-191-1/+1
| | | | | | | | | | | | | | | Summary: None of these checks are specific to Android devices. If libc++ was used with Bionic on a normal Linux system these checks would still be needed. Reviewers: mclow.lists, EricWF Subscribers: compnerd, tberghammer, danalbert, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D24690 llvm-svn: 281921
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-251-57/+35
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* Remove CloudABI specific workaround.Ed Schouten2016-06-161-2/+0
| | | | | | | | CloudABI has gained the mblen_l() function in the meantime that does properly return whether the character set has shift-states (read: never). llvm-svn: 272886
* Fix most GCC attribute ignored warningsEric Fiselier2016-04-211-3/+3
| | | | llvm-svn: 267074
* Reorganize _LIBCPP_LOCALE__L_EXTENSIONSBen Craig2016-03-091-178/+38
| | | | | | | | | | | | | | | | Instead of checking _LIBCPP_LOCALE_L_EXTENSIONS all over, instead check it once, and define the various *_l symbols once. The private redirector symbol names are all prefixed with _libcpp_* so that they won't conflict with user symbols, and so they won't conflict with future C library symbols. In particular, glibc likes providing private symbols such as __locale_t, so we should follow a different naming pattern (like _libcpp_*) to avoid problems on that front. Tested on Linux with glibc. Hoping for the best on OSX and the various BSDs. http://reviews.llvm.org/D17456 llvm-svn: 263016
* [libcxx] Remove pragmas that were needed to suppress warnings producedAkira Hatanaka2016-01-281-9/+0
| | | | | | | | | by -Wpadded. We don't need these pragmas anymore because -Wpadded was removed from buildit in r258900. llvm-svn: 259023
* Use libcxx's default rune table with the Musl C library.Vasileios Kalintiris2015-11-241-12/+12
| | | | | | | | | | | | | | | | | Summary: Also, there are no exported character type tables from Musl so we have to Fallback to the standard functions. This reduces the number of libcxx's test-suite failures down to ~130 for MIPS. Most of the remaining failures come from the atomics (due to the lack of 8-byte atomic-ops in MIPS32) and thread tests. Reviewers: mclow.lists, EricWF, dalias, jroelofs Subscribers: tberghammer, danalbert, srhines, cfe-commits Differential Revision: http://reviews.llvm.org/D14926 llvm-svn: 253972
* Add initial support for the MUSL C library.Vasileios Kalintiris2015-11-091-13/+17
| | | | | | | | | | | | | | | | | | | Summary: This patch adds the LIBCXX_LIBC_IS_MUSL cmake option to allow the building of libcxx with the Musl C library. The option is necessary as Musl does not provide any predefined macro in order to test for its presence, like GLIBC. Most of the changes specify the correct path to choose through the various #if/#else constructs in the locale code. Depends on D13407. Reviewers: mclow.lists, jroelofs, EricWF Subscribers: jfb, tberghammer, danalbert, srhines, cfe-commits Differential Revision: http://reviews.llvm.org/D13673 llvm-svn: 252457
* Make locale code compile on CloudABI.Ed Schouten2015-07-061-10/+13
| | | | | | | | | | | | | | | | | | | After r241454 landed, libc++'s locale code compiles on CloudABI, with the exception of the following two bits: - CloudABI doesn't have setlocale(), as the C library does not keep track of any global state. The global locale is always set to "C". Disable the call to setlocale() on this system. - Similarly, mbtowc_l() is also not present, as it is also not thread-safe. As CloudABI does not support state-dependent encodings, simply disable that part of the logic. The locale code now compiles out of the box on CloudABI. Differential Revision: http://reviews.llvm.org/D10729 Reviewed by: jroelofs llvm-svn: 241455
* Cleanup: prefer _LIBCPP_GET_C_LOCALE over __cloc().Ed Schouten2015-07-061-11/+11
| | | | | | | | | | | | | The __cloc() function is only present in case the environment does not provide a way to refer to the C locale using a compile-time constant expression. _LIBCPP_GET_C_LOCALE seems to be defined unconditionally. This improves compilation of the locale code on CloudABI. Differential Revision: http://reviews.llvm.org/D10690 Reviewed by: jroelofs llvm-svn: 241454
* When building libc++, we use '"' as a delimiter instead of '<' when ↵Marshall Clow2015-06-231-1/+1
| | | | | | including libc++ header files. This is so that the dylib gets built with our headers; rather than the system-installed ones. We do this in most places already, just fixing a couple of inconsistent uses. llvm-svn: 240412
* Avoid C-style cast.Joerg Sonnenberger2015-06-051-1/+1
| | | | llvm-svn: 239160
* Fix incorrect error handling of call to mbrtowc. This is PR#13759. Leaving ↵Marshall Clow2015-03-231-1/+1
| | | | | | the bug open because (1) I'm not sure that we're correct here, only better than before, and (2) no tests llvm-svn: 233012
* Fix build break on Solaris introduced by r231940Jonathan Roelofs2015-03-131-0/+2
| | | | | | | | | Solaris apparently doesn't have iswblank_l. Thanks to C Bergstrom for the report! llvm-svn: 232172
* Fix ctype_byname<wchar_t>::do_is() mask checking.... againJonathan Roelofs2015-03-111-30/+38
| | | | | | | | | This basically reverts the revert in r216508, and fixes a few more cases while I'm at it. Reading my commit message on that commit again, I think it's bupkis. http://reviews.llvm.org/D8237 llvm-svn: 231940
* Move Android to the builtin rune table.Dan Albert2015-03-111-2/+0
| | | | llvm-svn: 231897
* Nbjoerg suggested a better name for the macro for the default rune table: ↵Marshall Clow2015-03-041-1/+1
| | | | | | _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE llvm-svn: 231255
* Create a default rune table for libc++. Initial setting - never enabled. The ↵Marshall Clow2015-03-041-0/+82
| | | | | | expectation is that some targets (Android, cough) will enable it. Note that this is an implementation detail, not an interface change. llvm-svn: 231252
* libc++: support newlib's ctypeJF Bastien2015-02-251-0/+3
| | | | | | | | | | | | Summary: Newlib supports ctype differently from other platforms, this patch teaches libc++ about yet another platform that does ctype differently. Reviewers: jroelofs Subscribers: cfe-commits, danalbert, EricWF, jvoung, jfb, mclow.lists Differential Revision: http://reviews.llvm.org/D7888 llvm-svn: 230557
* Revert r216497: "[libcxx] Fix ctype_byname<wchar_t>::do_is() mask checking."Jonathan Roelofs2014-08-271-30/+30
| | | | | | | | | | | | | | | | After discussing implementing more tests for this with @danalbert & @mclow, I realized this change is not correct. The C++ standard requires do_is() to behave as if it were a loop that checked is(). Furthermore, it requires is() to check "The first form returns the result of the expression (M & m) != 0; i.e., true if the character has the characteristics specified"... which the reverted patch definitely does not conform to. Even further, furthermore, this requires that ctype's mask be an actual bitmask, unlike what android and newlib provide for _ctype_. Fixing the original bug that instigated this patch remains TBD. llvm-svn: 216508
* [libcxx] Fix ctype_byname<wchar_t>::do_is() mask checking.Jonathan Roelofs2014-08-261-30/+30
| | | | | | | This patch: http://reviews.llvm.org/D5081 Original patch: http://reviews.llvm.org/D5071 (from @danalbert) llvm-svn: 216497
* Revert "Turn off extern templates for most uses."Justin Bogner2014-08-151-2/+0
| | | | | | | | | | | Turning off explicit template instantiation leads to a pretty significant build time and code size cost. We're better off dealing with ABI incompatibility issues that come up in a less heavy handed way. This reverts commit r189610. llvm-svn: 215740
* Make Android's ctype_base::mask unsigned.Dan Albert2014-07-311-1/+1
| | | | | | | Keeping the regex code sane is much easier if we match the other platforms and use an unsigned mask. llvm-svn: 214442
* Fix classic_locale for Android.Dan Albert2014-07-221-1/+1
| | | | | | Android's classic_locale begins at _ctype_ + 1. llvm-svn: 213672
* Add support for BIONIC C library (Android). Patch from Dan AlbertMarshall Clow2014-07-101-2/+4
| | | | llvm-svn: 212724
* Switch to using C++ style casts.Joerg Sonnenberger2014-01-041-21/+21
| | | | llvm-svn: 198505
* Patch by Xing Xue to improve libc++ support for AIXMarshall Clow2013-11-191-1/+1
| | | | llvm-svn: 195144
OpenPOWER on IntegriCloud