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
This commit is contained in:
Eric Fiselier
2018-07-27 03:07:09 +00:00
parent 47d2a98a33
commit a0866c5fb5
178 changed files with 3978 additions and 3161 deletions

View File

@@ -62,6 +62,7 @@
#include <deque>
#include <errno.h>
#include <exception>
#include <filesystem>
#include <float.h>
#include <forward_list>
#include <fstream>

View File

@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
#include <experimental/filesystem>

View File

@@ -9,11 +9,11 @@
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// <filesystem>
// class directory_entry
// RUN: %build -I%libcxx_src_root/src/experimental/filesystem
// RUN: %build -I%libcxx_src_root/src/filesystem
// RUN: %run
#include "filesystem_include.hpp"

View File

@@ -13,13 +13,13 @@
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
// MODULES_DEFINES: _LIBCPP_DEBUG=0
// <experimental/filesystem>
// <filesystem>
// class path
#define _LIBCPP_DEBUG 0
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <experimental/filesystem>
#include "filesystem_include.hpp"
#include <iterator>
#include <type_traits>
#include <cassert>
@@ -27,8 +27,6 @@
#include "test_macros.h"
#include "filesystem_test_helper.hpp"
namespace fs = std::experimental::filesystem;
int main() {
using namespace fs;
using ExType = std::__libcpp_debug_exception;

View File

@@ -9,16 +9,14 @@
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// <filesystem>
// class path
#include <experimental/filesystem>
#include "filesystem_include.hpp"
#include <iterator>
namespace fs = std::experimental::filesystem;
int main() {
using namespace fs;
using RIt = std::reverse_iterator<path::iterator>;

View File

@@ -9,7 +9,7 @@
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// <filesystem>
// template <class Tp> struct __is_pathable
@@ -21,7 +21,7 @@
// * A character array, which points to a NTCTS after array-to-pointer decay.
#include <experimental/filesystem>
#include "filesystem_include.hpp"
#include <type_traits>
#include <cassert>
@@ -30,8 +30,6 @@
#include "min_allocator.h"
#include "constexpr_char_traits.hpp"
namespace fs = std::experimental::filesystem;
using fs::__is_pathable;
template <class Tp>

View File

@@ -9,14 +9,14 @@
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/filesystem>
// <filesystem>
// typedef TrivialClock file_time_type;
// RUN: %build -I%libcxx_src_root/src/experimental/filesystem
// RUN: %build -I%libcxx_src_root/src/filesystem
// RUN: %run
#include <experimental/filesystem>
#include <filesystem>
#include <chrono>
#include <type_traits>
#include <limits>
@@ -30,7 +30,7 @@
#endif
using namespace std::chrono;
namespace fs = std::experimental::filesystem;
namespace fs = std::__fs::filesystem;
using fs::file_time_type;
using fs::detail::time_util;

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <filesystem>
#include <filesystem>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}