Commit Graph

44 Commits

Author SHA1 Message Date
Thomas A
a574ade231 Downgrading libcxx to llvmorg-13.0.1
It turns out that llvmorg-14.0.6 might be too new for dyld (the vector base class no longer exist in that release).
2022-06-26 13:05:32 -07:00
Thomas A
e3bbeb7fdc Update libcxx source to llvmorg-14.0.6 2022-06-26 09:13:52 -07:00
Dan Albert
ba4e717aaf Open fstream files in O_CLOEXEC mode when possible.
Reviewers: EricWF, mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: smeenai, dexonsmith, christof, ldionne, libcxx-commits

Tags: #libc

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@372027 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-16 19:26:41 +00:00
Petr Hosek
c0e405ec62 [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose fails
This issue was detected by ASan in one of our tests. This test manually
invokes basic_filebuf::cloe(). fclose(__h.release() returned a non-zero
exit status, so __file_ wasn't set to 0. Later when basic_filebuf
destructor ran, we would enter the if (__file_) block again leading to
heap-use-after-free error.

The POSIX specification for fclose says that independently of the return
value, fclose closes the underlying file descriptor and any further
access (including another call to fclose()) to the stream results in
undefined behavior. This is exactly what happened in our test case.

To avoid this issue, we have to always set __file_ to 0 independently of
the fclose return value.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366730 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-22 19:54:34 +00:00
Louis Dionne
51ecd6cd07 [libc++] Mark <filesystem> tests as failing when the dylib doesn't support filesystem
This fixes CI for back-deployment testers on platforms that don't have
<filesystem> support in the dylib.

This is effectively half of https://reviews.llvm.org/D59224. The other
half requires fixes in Clang.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356558 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-20 14:34:00 +00:00
Chandler Carruth
7c3769df62 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@351648 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 10:56:40 +00:00
Marshall Clow
11a8815e5a Set the buffer of an fstream to empty when the underlying file is closed. This 'fixes' PR#38052 - std::fstream still good after closing and updating content.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@350603 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-08 02:48:45 +00:00
Eric Fiselier
a0866c5fb5 Implement <filesystem>
This patch implements the <filesystem> header and uses that
to provide <experimental/filesystem>.

Unlike other standard headers, the symbols needed for <filesystem>
have not yet been placed in libc++.so. Instead they live in the
new libc++fs.a library. Users of filesystem are required to link this
library. (Also note that libc++experimental no longer contains the
definition of <experimental/filesystem>, which now requires linking libc++fs).

The reason for keeping <filesystem> out of the dylib for now is that
it's still somewhat experimental, and the possibility of requiring an
ABI breaking change is very real. In the future the symbols will likely
be moved into the dylib, or the dylib will be made to link libc++fs automagically).

Note that moving the symbols out of libc++experimental may break user builds
until they update to -lc++fs. This should be OK, because the experimental
library provides no stability guarantees. However, I plan on looking into
ways we can force libc++experimental to automagically link libc++fs.

In order to use a single implementation and set of tests for <filesystem>, it
has been placed in a special `__fs` namespace. This namespace is inline in
C++17 onward, but not before that. As such implementation is available
in C++11 onward, but no filesystem namespace is present "directly", and
as such name conflicts shouldn't occur in C++11 or C++14.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338093 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-27 03:07:09 +00:00
Eric Fiselier
70c866bfc1 Implement a better copy_file.
This patch improves both the performance, and the safety of the
copy_file implementation.

The performance improvements are achieved by using sendfile on
Linux and copyfile on OS X when available.

The TOCTOU hardening is achieved by opening the source and
destination files and then using fstat to check their attributes to
see if we can copy them.

Unfortunately for the destination file, there is no way to open
it without accidentally creating it, so we first have to use
stat to determine if it exists, and if we should copy to it.
Then, once we're sure we should try to copy, we open the dest
file and ensure it names the same entity we previously stat'ed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337649 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-22 02:00:53 +00:00
Peter Collingbourne
f493c2fed6 libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.
This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323170 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 02:07:27 +00:00
Marshall Clow
29149d3e35 Make pbump (internally) handle sizes bigger than MAX_INT. Fixes PR#33725 - thanks to Jonathan Wakely for the report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@313031 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-12 15:00:43 +00:00
Marshall Clow
ff5f9b28ba Add some const_casts in places where we were implicitly casting away constness. No functional change, but now they're explicit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305410 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-14 20:00:36 +00:00
Eric Fiselier
018a3d51a4 [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304357 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31 22:07:49 +00:00
Eric Fiselier
e915b5c1f2 Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output library
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 23:38:41 +00:00
Eric Fiselier
c3589a8305 [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both
_LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to
__attribute__((__type_visibility__)) with Clang. The only remaining difference
is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas
_LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on
templates).

This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291035 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 23:56:00 +00:00
Shoaib Meenai
3b2cf9659d [libc++] Add configuration define for off_t functions
Create this define in __config and use it elsewhere, instead of checking
the operating system/library defines in other files. The aim is to
reduce the usage of _WIN32 outside __config. No functional change.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285582 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-31 15:09:10 +00:00
Marshall Clow
14c09a2413 Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279744 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 15:09:01 +00:00
Marshall Clow
2700619520 Don't call memmove when there's nothing to move. Fixes PR#27978.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-04 16:16:59 +00:00
Evgeniy Stepanov
9341a8a746 Cleanup: move visibility/linkage attributes to the first declaration.
http://reviews.llvm.org/D15404

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267093 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 01:04:55 +00:00
Ed Schouten
b33ae5ba7d Add option to disable access to the global filesystem namespace.
Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.

This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:

- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
  all tests that use the global filesystem namespace to break, but will
  at least make all the other tests run (as get_temp_file_name will not
  build anyway).

It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).

Differential revision:	http://reviews.llvm.org/D8194
Reviewed by:		jroelofs (thanks!)


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 15:44:39 +00:00
Jonathan Roelofs
c6893aecfd Revert: Revert r227804: Use fseek/ftell instead of fseeko/ftello when Newlib is the libc
EricWF has updated the compilers on his buildbots. Hopefully they won't crash now.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@227971 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-03 15:34:17 +00:00
Jonathan Roelofs
7743dddc8c Revert r227804: Use fseek/ftell instead of fseeko/ftello when Newlib is the libc
This change is causing a driver crash on libcxx-libcxxabi-x86_64-linux-ubuntu-msan


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@227806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 15:56:43 +00:00
Jonathan Roelofs
0c71f582b5 Use fseek/ftell instead of fseeko/ftello when Newlib is the libc
http://reviews.llvm.org/D6626


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@227804 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 15:04:29 +00:00
Howard Hinnant
0f678bd69e Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 18:38:34 +00:00
Howard Hinnant
cf31d3864e Reference: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130325/077133.html
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@178581 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-02 22:14:51 +00:00
Howard Hinnant
83eade6abb No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@176593 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 23:30:19 +00:00
Argyrios Kyrtzidis
1dc6f7ab97 Don't neglect to "return *this".
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@165860 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-13 02:03:45 +00:00
Howard Hinnant
d305d3c1a2 Hyeon-Bin Jeong: 1. sync() should reset it’s external buffer pointers.
Remaining characters should be discarded once sync() called. If don’t, garbage
characters can be inserted to the front of external buffer in underflow().
Because underflow() copies remaining characters in external buffer to it’s
front. This results wrong characters insertion when seekpos() or seekoff() is
called.

this line should be inserted in sync() just before return:
__extbufnext_ = __extbufend_ = __extbuf_;

2. sync() should use length() rather than out() to calculate offset.
Reversing iterators and calling out() to calculate offset from behind is
working fine in stateless character encoding. However, in stateful encoding,
escape sequences could differ in length. As a result, out() could return wrong
length. 

For example, if we have internal buffer converted from this external sequence:
(capital letters mean escape sequence)
… a a a a B b b b b

out() produces this sequence. 
b b b b A a a a a

Because out() inserts escape sequence A rather than B, result sequence doesn't
match to external sequence. A and B could have different lengths, result offset
could be wrong value too.

length() method in codecvt is right for calculating offset, but it counts
offset from the beginning of buffer. So it requires another state member
variable to hold state before conversion.
Fixes http://llvm.org/bugs/show_bug.cgi?id=13667

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162601 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 21:20:56 +00:00
Howard Hinnant
ec423cb8d4 Fix basic_filebuf's internal buffer is shrinking when using with some codecvt. http://llvm.org/bugs/show_bug.cgi?id=13602
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162585 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 20:37:00 +00:00
Howard Hinnant
e7d59f2601 Fixed order of calling use_facet vs setbuf in basic_filebuf default constructor.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162571 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 18:06:47 +00:00
Howard Hinnant
8540d4c9d2 basic_filebuf needs to delay obtaining a codecvt facet from the global locale to give the client a chance to imbue the proper locale. Fixes http://llvm.org/bugs/show_bug.cgi?id=13663.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162567 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 16:52:47 +00:00
Howard Hinnant
e1a7b04c58 Fix http://llvm.org/bugs/show_bug.cgi?id=11752
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@148069 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12 23:37:51 +00:00
Howard Hinnant
66c6f9733b Add protection from min/max macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145407 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 16:45:27 +00:00
Howard Hinnant
08e17472e4 Windows support by Ruben Van Boxem.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@142235 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 20:05:10 +00:00
Howard Hinnant
0949eedbd6 _STD -> _VSTD to avoid macro clash on windows
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134190 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 21:18:19 +00:00
Howard Hinnant
6cf5d8c3aa Chris Jefferson noted many places where function calls needed to be qualified (thanks Chris).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@125510 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 19:12:38 +00:00
Howard Hinnant
47a7cce01e Missing traits::to_int_type in fstream
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@124727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 17:37:16 +00:00
Howard Hinnant
b64f8b07c1 license change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@119395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 22:09:02 +00:00
Howard Hinnant
42a63a781f visibility-decoration.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@114496 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-21 22:55:27 +00:00
Howard Hinnant
73d21a4f07 Changed __config to react to all of clang's currently documented has_feature flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-04 23:28:19 +00:00
Howard Hinnant
324bb03bb9 Fixing whitespace problems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@111750 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 00:02:43 +00:00
Howard Hinnant
639a668b4c Tests for basic posix regex templated on wchar_t
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@108435 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-15 18:18:07 +00:00
Howard Hinnant
f5256e16df Wiped out some non-ascii characters that snuck into the copyright.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 21:36:01 +00:00
Howard Hinnant
bc8d3f97eb libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 19:42:16 +00:00