summaryrefslogtreecommitdiffstats
path: root/libcxx/src/experimental/filesystem/path.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement filesystem NB comments, relative paths, and related issues.Eric Fiselier2018-04-021-448/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fairly large patch that implements all of the filesystem NB comments and the relative paths changes (ex. adding weakly_canonical). These issues and papers are all interrelated so their implementation couldn't be split up nicely. This patch upgrades <experimental/filesystem> to match the C++17 spec and not the published experimental TS spec. Some of the changes in this patch are both API and ABI breaking, however libc++ makes no guarantee about stability for experimental implementations. The major changes in this patch are: * Implement NB comments for filesystem (P0492R2), including: * Implement `perm_options` enum as part of NB comments, and update the `permissions` function to match. * Implement changes to `remove_filename` and `replace_filename` * Implement changes to `path::stem()` and `path::extension()` which support splitting examples like `.profile`. * Change path iteration to return an empty path instead of '.' for trailing separators. * Change `operator/=` to handle absolute paths on the RHS. * Change `absolute` to no longer accept a current path argument. * Implement relative paths according to NB comments (P0219r1) * Combine `path.cpp` and `operations.cpp` since some path functions require access to the operations internals, and some fs operations require access to the path parser. llvm-svn: 329028
* path: Use string_view_t consistentlyDuncan P. N. Exon Smith2017-06-191-2/+3
| | | | | | | | | Most of filesystem/path.cpp uses string_view_t. This fixes the two spots that use string_view directly. https://reviews.llvm.org/D34332 llvm-svn: 305661
* Fix bugs in filesystem detected by _LIBCPP_ASSERT.Eric Fiselier2017-02-071-5/+13
| | | | | | | | | | | | | | | | | Recently I turned on libc++'s debug mode assertions when CMake is configured with -DLIBCXX_ENABLE_ASSERTIONS=ON. This change exposed assertion failures caused by bugs in filesystem. This patch fixes those failures. The first bug was that `PathParser` was using front()/back() on empty string views in order to get the address of the character. However this is UB on empty strings. Those operations now use data() to obtain the pointer. The second bug was that directory_iterator attempted to capture errno when it was unset and there was an assertion to detect this. llvm-svn: 294360
* Recommit [libcxx] Never use <cassert> within libc++Eric Fiselier2017-02-041-4/+0
| | | | | | | | | | It is my opinion that libc++ should never use `<cassert>`, including in the `dylib`. This patch remove all uses of `assert` from within libc++ and replaces most of them with `_LIBCPP_ASSERT` instead. Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS` off by default, because the standard library should not be aborting user programs unless explicitly asked to. llvm-svn: 294107
* Revert "[libcxx] Never use <cassert> within libc++"Eric Fiselier2017-01-241-0/+4
| | | | | | | | This reverts commit r292883. Unfortunately <string_view> uses _LIBCPP_ASSERT in a way which is not compatible with the C++11 dylib build. I'll investigate more tomorrow. llvm-svn: 292923
* [libcxx] Never use <cassert> within libc++Eric Fiselier2017-01-241-4/+0
| | | | | | | | | | | | | | | | | Summary: It is my opinion that libc++ should never use `<cassert>`, including in the `dylib`. This patch remove all uses of `assert` from within libc++ and replaces most of them with `_LIBCPP_ASSERT` instead. Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS` off by default, because the standard library should not be aborting user programs unless explicitly asked to. Reviewers: mclow.lists, compnerd, smeenai Reviewed By: mclow.lists Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D29063 llvm-svn: 292883
* Make variant's index part of the hash valueEric Fiselier2016-12-021-9/+4
| | | | llvm-svn: 288554
* Improve performance of constructing filesystem::path from strings.Eric Fiselier2016-10-301-8/+1
| | | | | | | | | | | | | This patch fixes a performance bug when constructing or appending to a path from a string or c-string. Previously we called 'push_back' to append every single character. This caused multiple re-allocation and copies when at most one reallocation is necessary. The new behavior is to simply call `string::append` so it can correctly handle reallocation. For large strings this change is a ~4x improvement. This also makes our path faster to construct than libstdc++'s. llvm-svn: 285530
* Rewrite std::filesystem::path iterators and parserEric Fiselier2016-10-301-237/+290
| | | | | | | | | | | | | | | | | | | | | | This patch entirely rewrites the parsing logic for paths. Unlike the previous implementation this one stores information about the current state; For example if we are in a trailing separator or a root separator. This avoids the need for extra lookahead (and extra work) when incrementing or decrementing an iterator. Roughly this gives us a 15% speedup over the previous implementation. Unfortunately this implementation is still a lot slower than libstdc++'s. Because libstdc++ pre-parses and splits the path upon construction their iterators are trivial to increment/decrement. This makes libc++ lazy parsing 100x slower than libstdc++. However the pre-parsing libstdc++ causes a ton of extra and unneeded allocations when constructing the string. For example `path("/foo/bar/")` would require at least 5 allocations with libstdc++ whereas libc++ uses only one. The non-allocating behavior is much preferable when you consider filesystem usages like 'exists("/foo/bar/")'. Even then libc++'s path seems to be twice as slow to simply construct compared to libstdc++. More investigation is needed about this. llvm-svn: 285526
* Fix Clang 3.6 build errorEric Fiselier2016-10-281-1/+1
| | | | llvm-svn: 285445
* Implement modified LWG 2665Eric Fiselier2016-10-151-0/+10
| | | | llvm-svn: 284313
* Implement P0392r0. Integrate filesystem::path and string_view.Eric Fiselier2016-07-231-45/+46
| | | | llvm-svn: 276511
* Remove workarounds for C++17 inline variable ABI break. It has been fixed in ↵Eric Fiselier2016-07-021-4/+0
| | | | | | clang. llvm-svn: 274419
* Add another workaround for C++17 inline variable ABI breakage.Eric Fiselier2016-07-011-1/+4
| | | | llvm-svn: 274408
* Add Filesystem TS -- CompleteEric Fiselier2016-06-171-0/+392
Add the completed std::experimental::filesystem implementation and tests. The implementation supports C++11 or newer. The TS is built as part of 'libc++experimental.a'. Users of the TS need to manually link this library. Building and testing the TS can be disabled using the CMake option '-DLIBCXX_ENABLE_FILESYSTEM=OFF'. Currently 'libc++experimental.a' is not installed by default. To turn on the installation of the library use '-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON'. llvm-svn: 273034
OpenPOWER on IntegriCloud