Commit Graph

121 Commits

Author SHA1 Message Date
Nikolas Klauser
30adaa730c [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-02 21:42:41 +02:00
Nikolas Klauser
84fc2c3cd6 [libc++] Make the naming of private member variables consistent and enforce it through readability-identifier-naming
Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D129386
2022-09-02 21:36:36 +02:00
Nikolas Klauser
4262b523ff [libc++][NFC] Enable modernize-use-override
Reviewed By: Mordante, #libc

Spies: aheejin, libcxx-commits, smeenai

Differential Revision: https://reviews.llvm.org/D124714
2022-08-25 20:55:08 +02:00
Xing Xue
d29c947732 [libc++][AIX] Correct the definition of __regex_word for AIX
Summary:
The patch changes the definition of __regex_word to 0x8000 for AIX because the current definition 0x80 clashes with ctype_base::print (_ISPRINT is defined as 0x80 in AIX ctype.h).

Reviewed by: Mordante, hubert.reinterpretcast, libc++

Differential Revision: https://reviews.llvm.org/D129862
2022-07-16 18:11:04 -04:00
David Tenty
a83004f4ff [libcxx][AIX][z/OS] Remove headers included via _IBMCPP__
D127650 removed support for non-clang-based XL compilers, but left some
of the headers used only by this compiler and included under the
__IBMCPP__ macro. This change cleans this up by deleting these headers.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129491
2022-07-14 15:41:46 -04:00
Louis Dionne
2ae52326da [libc++] Towards a simpler extern template story in libc++
The flexibility around extern template instantiation declarations in
libc++ result in a very complicated model, especially when support for
slightly different configurations (like the debug mode or assertions
in the dylib) are taken into account. That results in unexpected bugs
like http://llvm.org/PR50534 (and there have been multiple similar
bugs in the past, notably around the debug mode).

This patch gets rid of the _LIBCPP_DISABLE_EXTERN_TEMPLATE knob, which
I don't think is fundamental. Indeed, the motivation for that knob was to
avoid taking a dependency on the library, however that can be done better
by linking against the static library instead. And in fact, some parts of
the headers will always depend on things defined in the library, which
defeats the original goal of _LIBCPP_DISABLE_EXTERN_TEMPLATE.

Differential Revision: https://reviews.llvm.org/D103960
2022-06-08 22:05:07 -04:00
Sam Clegg
b86771a2f7 [libc++] Minor emscripten changes from downstream
Differential Revision: https://reviews.llvm.org/D126583
2022-05-28 06:44:27 -07:00
Nikolas Klauser
1458458b55 [libc++] Remove <utility> includes
Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D121054
2022-03-17 00:12:33 +01:00
Nikolas Klauser
52915d78f4 [libc++] Granularize <utility> includes
Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D120466
2022-03-05 19:31:46 +01:00
Martin Storsjö
45415ef91b [libcxx] Fix the ctype is (pointer version) function for Windows
Previously, this test snippet would report incorrect information:

    F::mask m;
    std::wstring in(L"\u00DA"); // LATIN CAPITAL LETTER U WITH ACUTE
    f.is(in.data(), in.data() + 1, &m);
    // m & F::lower would be set

The single-character version of the `is` function wasn't
affected by this issue though.

Define `_LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA` for Windows,
as the `alpha` / `_ALPHA` constant is a mask consisting of
multiple bits set, which avoids setting `alpha` whenver any
of the bits is set, in the `do_is` implementation.

On Windows, with the "C" locale, wchars are classified according
to their Unicode interpretation, just as in the en_US.UTF-8 locale on
all platforms.

Due to the differing classification of some characters, the
`scan_is` and `scan_not` tests are quite annoying to fix, thus just
ifdef out some of the tests for the "C" locale there - the code gets
tested with the more standard en_US.UTF-8 locale anyway.

Differential Revision: https://reviews.llvm.org/D120796
2022-03-05 00:47:19 +02:00
Nikolas Klauser
bd44174547 [libc++] Use -I instead of -isystem to include headers in the test suite
Using -isystem marks the headers as system headers, which means that we
don't actually get all the warnings that we'd normally get if we included
the headers as user headers.

The goal of the test suite is normally to mirror as closely as possible
how users would use the library. Technically, this change goes against
that philosophy, since users should be using `-isystem` (if they ever
need to specify the libc++ path explicitly, which should be a rare
occurence). However, I believe fishing out additional warnings from
the headers provides more value, hence this change. Ideally, we'd be
able to still use `-isystem`, but instruct Clang to still emit warnings
from the libc++ headers (e.g. we could tell Clang to emit warnings in
any file inside `<...>/usr/include/c++/v1`).

Reviewed By: #libc, ldionne, #libc_abi

Spies: Mordante, EricWF, mstorsjo, mgorny, aheejin, arichardson, philnik, jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D118616
2022-03-03 13:19:47 +01:00
Louis Dionne
368faacac7 [libc++] Revert "Protect users from relying on detail headers" & related changes
This commit reverts 5aaefa51 (and also partly 7f285f48e7 and b6d75682f9,
which were related to the original commit). As landed, 5aaefa51 had
unintended consequences on some downstream bots and didn't have proper
coverage upstream due to a few subtle things. Implementing this is
something we should do in libc++, however we'll first need to address
a few issues listed in https://reviews.llvm.org/D106124#3349710.

Differential Revision: https://reviews.llvm.org/D120683
2022-03-01 08:20:24 -05:00
Christopher Di Bella
5aaefa510e [libcxx][modules] protects users from relying on detail headers
libc++ has started splicing standard library headers into much more
fine-grained content for maintainability. It's very likely that outdated
and naive tooling (some of which is outside of LLVM's scope) will
suggest users include things such as <__ranges/access.h> instead of
<ranges>, and Hyrum's law suggests that users will eventually begin to
rely on this without the help of tooling. As such, this commit
intends to protect users from themselves, by making it a hard error for
anyone outside of the standard library to include libc++ detail headers.

Differential Revision: https://reviews.llvm.org/D106124
2022-02-26 09:00:25 +00:00
Arthur O'Dwyer
fa6b9e4010 [libc++] Normalize all our '#pragma GCC system_header', and regression-test.
Now we'll notice if a header forgets to include this magic phrase.

Differential Revision: https://reviews.llvm.org/D118800
2022-02-04 12:27:19 -05:00
Martin Storsjö
eb9645819c [libcxx] [Windows] Pick a unique bit for __regex_word
The old `__regex_word` aliased the mask for `xdigit`, causing stray
test failures.

The diff may look surprising, as if the previous faulty value had
been set specifically for Windows - but this is due to a restructuring
in 411c630bae. Prior to that, there
were OS specific settings for some OSes, and one fallback used for
the rest (which turns out to not work for Windows).

Differential Revision: https://reviews.llvm.org/D118188
2022-01-31 23:13:58 +02:00
Muiez Ahmed
4f8ea3c84f [SystemZ][z/OS][NFC] Remove extra symbol 2022-01-21 16:18:46 -05:00
Muiez Ahmed
a1da73961d [SystemZ][z/OS] ASCII/EBCDIC support with no coexistence
The aim of this patch is to break up the larger patch (https://reviews.llvm.org/D111323) to be more upstream friendly. In particular, this patch adds the char encoding sensitive changes but does not use inline namespaces as before. The use of namespaces to build both versions of the library, and localization of error messages will follow in a subsequent patch.

Differential Revision: https://reviews.llvm.org/D114813
2022-01-14 11:37:09 -05:00
Arthur O'Dwyer
4d81a46f7f [libc++] Alphabetize header #includes. NFCI.
The NFC part of D116809. We still want to enforce this in CI,
but the mechanism for that is still to-be-determined.

Differential Revision: https://reviews.llvm.org/D116809
2022-01-10 16:30:38 -05:00
Nikolas Klauser
feb80aa96b [libc++] = delete member functions with // = delete;
Use `= delete` for member functions that are marked with `// = delete;`

Reviewed By: ldionne, Quuxplusone, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115291
2021-12-08 19:29:44 +01:00
Louis Dionne
f4c1258d56 [libc++] Add an option to disable wide character support in libc++
Some embedded platforms do not wish to support the C library functionality
for handling wchar_t because they have no use for it. It makes sense for
libc++ to work properly on those platforms, so this commit adds a carve-out
of functionality for wchar_t.

Unfortunately, unlike some other carve-outs (e.g. random device), this
patch touches several parts of the library. However, despite the wide
impact of this patch, I still think it is important to support this
configuration since it makes it much simpler to port libc++ to some
embedded platforms.

Differential Revision: https://reviews.llvm.org/D111265
2021-10-12 06:08:23 -04:00
Xiang Xiao
3285c7a436 [libcxx] Remove the locale fallback for NuttX
Since these functions can handled by NuttX's libc now

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D108895
2021-08-31 09:46:55 -04:00
Arthur O'Dwyer
bfbd73f87d [libc++] Alphabetize and include-what-you-use. NFCI.
Differential Revision: https://reviews.llvm.org/D102781
2021-05-29 19:54:48 -04:00
Martin Storsjö
3a6be27978 [libcxx] Make the visibility attributes consistent for __narrow_to_utf8/__widen_from_utf8
Use the same visiblity attributes as for all other template
specializations in the same file; declare the specialization itself
using _LIBCPP_TYPE_VIS, and don't use _LIBCPP_EXPORTED_FROM_ABI on
the destructor. Methods that are excluded from the ABI are marked
with _LIBCPP_INLINE_VISIBILITY.

This makes the vtable exported from DLL builds of libc++. Practically,
it doesn't make any difference for the CI configuration, but it
can make a difference in mingw setups.

Differential Revision: https://reviews.llvm.org/D102717
2021-05-25 22:57:16 +03:00
Arthur O'Dwyer
5c40c994c3 [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g
This was raised in D94511.

Differential Revision: https://reviews.llvm.org/D100736
2021-04-21 12:49:07 -04:00
Louis Dionne
4cd6ca102a [libc++] NFC: Normalize #endif // comment indentation 2021-04-20 12:03:32 -04:00
Louis Dionne
b51756819a [libc++] Rename include/support to include/__support
We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

Differential Revision: https://reviews.llvm.org/D95956
2021-02-04 10:16:33 -05:00
Louis Dionne
68dba7eae1 [libc++] Unbreak the debug mode
When the Debug mode is enabled, we disable extern declarations because we
don't want to use the functions compiled in the library, which might not
have had the debug mode enabled when built. However, some extern declarations
need to be kept, because code correctness depends on it.

31e820378b removed those declarations, which had the unintended
consequence of breaking the debug build. This commit fixes that by
re-introducing a separate macro for the required extern declarations,
and adds a comment so that we don't fall into that trap in the future.

Differential Revision: https://reviews.llvm.org/D94718
2021-01-19 14:15:31 -05:00
Reid Kleckner
4f24d0dd53 Fix libc++ clang-cl build, swap attribute order
Clang insists that __attribute__ attributes precede __declspec
attributes. This is a longstanding known issue:
https://llvm.org/pr24559. Re-order the visibility and deprecation macros
to fix the build.

Differential Revision: https://reviews.llvm.org/D94788
2021-01-15 11:44:13 -08:00
Brad Smith
79f99ba65d [libcxx] Port to OpenBSD
Add initial OpenBSD support.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94205
2021-01-12 14:21:11 -05:00
Arthur O'Dwyer
3696227c10 [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.
Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in <list> and <vector> drag in namespace std
but that's OK; the ones in <fstream> and <strstream> are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.

Also: Include <cstring> and <cwchar> in <__string>.
We seemed to be getting lucky that <memory> included <iterator>
included <iosfwd> included <wchar.h>. That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

I didn't touch these headers:
<ext/__hash> uses strlen, safely
<support/ibm/locale_mgmt_aix.h> uses memcpy, safely
<string.h> uses memchr and strchr, safely
<wchar.h> uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely

Differential Revision: https://reviews.llvm.org/D93061
2020-12-10 22:03:12 -05:00
Marek Kurdej
a984dcaf7c [libc++] [P0482] [C++20] Implement missing bits for codecvt and codecvt_byname.
Add codecvt*<char16_t, char8_t> and codecvt*<char32_t, char8_t>.
Deprecate codecvt<char(16|32)_t, char>.
Enable disabled tests.
Update _LIBCPP_STD_VER to use 20 for C++20. Add _LIBCPP_DEPRECATED_IN_CXX20 macro.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D91517
2020-12-02 09:01:58 +01:00
Bruce Mitchener
527a7fdfbd [libc++] Replace several uses of 0 by nullptr
Differential Revision: https://reviews.llvm.org/D43159
2020-11-27 10:00:21 -05:00
Xiang Xiao
f0785c1f7a [libcxx] Port to NuttX (https://nuttx.apache.org) RTOS
Since NuttX conform to POSIX standard, the code need to add is very simple.

Differential Revision: https://reviews.llvm.org/D88718
2020-11-18 16:20:56 -05:00
Xiang Xiao
20acf6d588 [libcxx] Check _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE first in __locale
This is consistent with what's done in locale.cpp, and it ensures that
we get the default rune table whenever _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
is defined, regardless of the actual platform.

Differential Revision: https://reviews.llvm.org/D91074
2020-11-11 15:32:59 -05:00
Muiez Ahmed
e72e785d47 [SystemZ][z/OS] Enable POSIX_l functions for z/OS
The aim of this patch is to enable POSIX _l functions for z/OS. In particular, the functions are provided with libc++ and this patch resorts to the fallback functions. Nonetheless, the functions are being added so the implementation of the ctype<> member functions can call them. The following changes were needed to allow for a successful build when using the libc++ library for z/OS.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D90319
2020-11-10 09:57:11 -05:00
Louis Dionne
2eadbc8614 [libc++] Rework the whole availability markup implementation
Currently, vendor-specific availability markup is enabled by default.
This means that even when building against trunk libc++, the headers
will by default prevent you from using some features that were not
released in the dylib on your target platform. This is a source of
frustration since people building libc++ from sources are usually not
trying to use some vendor's released dylib.

For that reason, I've been thinking for a long time that availability
annotations should be off by default, which is the primary change that
this commit enables.

In addition, it reworks the implementation to make it easier for new
vendors to add availability annotations for their platform, and it
refreshes the documentation to reflect the current state of the codebase.

Finally, a CMake configuration option is added to control whether
availability annotations should be turned on for the flavor of libc++
being created. The intent is for vendors like Apple to turn it on, and
for the upstream libc++ to leave it off (the default).

Differential Revision: https://reviews.llvm.org/D90843
2020-11-05 12:28:52 -05:00
Louis Dionne
91336a0c61 [libc++] Move the #error message for no localization to <locale.h>
<locale.h> is lower level than <__locale>, so that's where we want the
error to live for systems that don't provide localization support.
2020-10-28 09:49:37 -04:00
Martin Storsjö
70bba9ef35 [libcxx] Don't truncate intermediates to wchar_t when widening
On windows, wchar_t is 16 bit, while we might be widening chars to
char32_t.

This cast had been present since the initial commit, and removing it
doesn't seem to make any tests fail.

Differential Revision: https://reviews.llvm.org/D90228
2020-10-27 23:58:27 +02:00
Louis Dionne
88ffc72717 [libc++] Add a libc++ configuration that does not support localization
When porting libc++ to embedded systems, it can be useful to drop support
for localization, which these systems don't implement or care about.

Differential Revision: https://reviews.llvm.org/D90072
2020-10-27 14:56:30 -04:00
Louis Dionne
1a92de0064 [libc++] NFCI: Remove _LIBCPP_EXTERN_TEMPLATE2
This seems to have been added a long time ago as a temporary help
for debugging some <regex> issue, but it's really the same as
_LIBCPP_EXTERN_TEMPLATE.
2020-10-02 14:31:43 -04:00
Dan Albert
cbf1904a3e Upstream Bionic definitions of ctype_base/regex.
Summary:
This is a patch that Android has been carrying in its tree for several
years. This patch upstreams the existing ABI.

There's some historical cruft here. __regex_word used to be a part of
regex_traits rather than ctype_base. Bionic also used to use its own
ctype implementation because the libc++ builtin one wasn't available
yet. Bionic's ctype masks were 8 bits wide and already saturated, so a
wider type needed to be used for the regex mask, and the existing
value was already used so Android needed to specify its own.

Since then Android has migrated to the builtin ctype implementation
and this patch probably should have been dropped then. Unfortunately
that was not noticed at the time, so now we need to keep this to
maintain the current ABI.

Reviewers: EricWF, #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76171
2020-04-06 13:38:16 -07:00
Mikhail Maltsev
a83220c6f2 [libcxx] Fix build breakage on mips
Fixes https://bugs.llvm.org/show_bug.cgi?id=43011 caused by
https://reviews.llvm.org/D63284.

Committing as obvious.

llvm-svn: 369364
2019-08-20 10:19:55 +00:00
Mikhail Maltsev
411c630bae [libc++] Keep __regex_word in sync with ctype_base
Summary:
The class ctype_base in the header <__locale> contains masks for
character classification functions, which are kept in sync with
platform's C library, hence it contains many special cases.
The value of the bit mask __regex_word in the header <regex> must not
clash with those bit masks.

Currently the default case (i.e. unknown platform/C library) is
handled incorrectly: the __regex_word clashes with ctype_base::punct.

To avoid replicating the whole list of platforms in <regex> this patch
defines __regex_word in <__locale>, so that it is always kept in sync
with other masks.

Reviewers: ldionne, mclow.lists, EricWF

Reviewed By: ldionne

Subscribers: krytarowski, christof, dexonsmith, pbarrio, simon_tatham, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D63284

llvm-svn: 363363
2019-06-14 09:04:16 +00:00
Dan Gohman
3efd6e37e4 [WebAssembly] WASI support for libcxx
This adds explicit support for the WASI platform to libcxx.

WASI libc uses some components from musl, however it's not fully compatible
with musl, so we're planning to stop using _LIBCPP_HAS_MUSL_LIBC and
customize for WASI libc specifically.

Differential Revision: https://reviews.llvm.org/D61336

Reviewers: sbc100, ldionne
llvm-svn: 359703
2019-05-01 16:47:30 +00:00
Thomas Anderson
24812d8ac4 Fix and speedup __libcpp_locale_guard on Windows
The old implementation assumed the POSIX `setlocale()` API where the old
locale is returned.  On Windows, the _new_ locale is returned.  This meant
that `__libcpp_locale_guard` wasn't resetting the locale on destruction.

The new implementation fixes the above issue and takes advantage of
`setlocale(LC_ALL)` to reduce the number of calls, and also avoids setting
the locale at all if it's not necessary.

Differential Revision: https://reviews.llvm.org/D59572

llvm-svn: 357104
2019-03-27 18:09:30 +00:00
Eric Fiselier
411210838d Work around dllimport bug with exclude_from_explicit_instantiation.
When dllimport is specified on a class, and
exclude_from_explicit_instatiation is specified on a member, clang-cl
will still expect a definition to be available externally. But this is
not correct.

Surprisingly one one symbol seems to be consistently affected by this
bug. So this patch simply works around it there.

llvm-svn: 355760
2019-03-08 23:59:29 +00:00
Dimitry Andric
d95da99b91 Fix the build with gcc when -Wredundant-decls is passed
Summary:
gcc warns that `__throw_runtime_error` is declared both in `<__locale>`
and `<stdexcept>`, if `-Wredundant-decls` is passed on the command
line; this is the case with FreeBSD when ${WARNS} == 6.

Since `<__locale>` gets its first declaration via a transitive include
of `<stdexcept>`, and the second declaration is after the first
invocation of `__throw_runtime_error`, delete that second declaration.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>

Reviewers: kristina, MaskRay, EricWF, ldionne, ngie

Reviewed By: EricWF

Subscribers: krytarowski, brooks, emaste, dim, christof, jdoerfert, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D58425

llvm-svn: 354515
2019-02-20 21:01:31 +00:00
Chandler Carruth
57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
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
2019-01-19 10:56:40 +00:00
Louis Dionne
9b3222f613 [libc++] Make sure we can build libc++ with -fvisibility=hidden
Summary:
When building with -fvisibility=hidden, some symbols do not get exported from
libc++.dylib. This means that some entities are not explicitly given default
visibility in the source code, and that we rely on the fact -fvisibility=default
is the default. This commit explicitly gives default visibility to those
symbols to avoid being dependent on the command line flags used.

The commit also remove symbols from the dylib -- those symbols do not
actually need to be exported from the dylib and this should not be an
ABI break.

Finally, in the future, we may want to mark the whole std:: namespace as
having hidden visibility (to switch from opt-out to opt-in), in which
case the changes done in this commit will be required.

Reviewers: EricWF

Subscribers: mgorny, christof, dexonsmith, libcxx-commits

Differential Revision: https://reviews.llvm.org/D52662

llvm-svn: 345260
2018-10-25 12:13:43 +00:00
Louis Dionne
dc7200b486 [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY
Summary:
We never actually mean to always inline a function -- all the uses of
the macro I could find are actually attempts to control the visibility
of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which
is actually always defined the same.

This change is orthogonal to the decision of what we're actually going
to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by
having one canonical way of doing things.

Note that this commit had originally been applied in r336369 and then
reverted in r336382 because of unforeseen problems. Both of these problems
have now been fixed.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, erikvanderpoel

Differential Revision: https://reviews.llvm.org/D48892

llvm-svn: 336866
2018-07-11 23:14:33 +00:00