Implement filesystem NB comments, relative paths, and related issues.

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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329028 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-04-02 23:03:41 +00:00
parent ead2a54952
commit 1e34c76d33
30 changed files with 1810 additions and 899 deletions

View File

@@ -1,70 +0,0 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// class path
// path& operator/=(path const&)
// path operator/(path const&, path const&)
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
int AssertCount = 0;
#include <experimental/filesystem>
#include <type_traits>
#include <string_view>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
#include "count_new.hpp"
#include "filesystem_test_helper.hpp"
namespace fs = std::experimental::filesystem;
int main()
{
using namespace fs;
{
path lhs("//foo");
path rhs("/bar");
assert(AssertCount == 0);
lhs /= rhs;
assert(AssertCount == 0);
}
{
path lhs("//foo");
path rhs("/bar");
assert(AssertCount == 0);
(void)(lhs / rhs);
assert(AssertCount == 0);
}
{
path lhs("//foo");
path rhs("//bar");
assert(AssertCount == 0);
lhs /= rhs;
assert(AssertCount == 1);
AssertCount = 0;
}
{
path lhs("//foo");
path rhs("//bar");
assert(AssertCount == 0);
(void)(lhs / rhs);
assert(AssertCount == 1);
}
// FIXME The same error is not diagnosed for the append(Source) and
// append(It, It) overloads.
}