Add Filesystem TS -- Complete

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'.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273034 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-06-17 19:46:40 +00:00
parent a8f47cc800
commit 6e9a694dce
147 changed files with 15301 additions and 11 deletions

View File

@@ -0,0 +1,101 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Tp> struct __is_pathable
// [path.req]
// In addition to the requirements (5), function template parameters named
// `Source` shall be one of:
// * basic_string<_ECharT, _Traits, _Alloc>
// * InputIterator with a value_type of _ECharT
// * A character array, which points to a NTCTS after array-to-pointer decay.
#include <experimental/filesystem>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
#include "min_allocator.h"
namespace fs = std::experimental::filesystem;
using fs::__is_pathable;
template <class Tp>
struct Identity { typedef Tp type; };
template <class Source>
Identity<Source> CheckSourceType(Source const&);
template <class Tp>
using GetSourceType = typename decltype(CheckSourceType(std::declval<Tp>()))::type;
template <class Tp, class Exp,
class ExpQual = typename std::remove_const<Exp>::type>
using CheckPass = std::is_same<ExpQual, GetSourceType<Tp>>;
template <class Source>
using CheckPassSource = std::integral_constant<bool,
CheckPass<Source&, Source>::value &&
CheckPass<Source const&, Source>::value &&
CheckPass<Source&&, Source>::value &&
CheckPass<Source const&&, Source>::value
>;
template <class CharT>
struct MakeTestType {
using value_type = CharT;
using string_type = std::basic_string<CharT>;
using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>;
using cstr_type = CharT* const;
using const_cstr_type = const CharT*;
using array_type = CharT[25];
using const_array_type = const CharT[25];
using iter_type = input_iterator<CharT*>;
using bad_iter_type = input_iterator<signed char*>;
template <class TestT>
static void AssertPathable() {
static_assert(__is_pathable<TestT>::value, "");
static_assert(CheckPassSource<TestT>::value, "cannot pass as Source const&");
ASSERT_SAME_TYPE(CharT, typename __is_pathable<TestT>::__char_type);
}
template <class TestT>
static void AssertNotPathable() {
static_assert(!__is_pathable<TestT>::value, "");
}
static void Test() {
AssertPathable<string_type>();
AssertPathable<string_type2>();
AssertPathable<cstr_type>();
AssertPathable<const_cstr_type>();
AssertPathable<array_type>();
AssertPathable<const_array_type>();
AssertPathable<iter_type>();
AssertNotPathable<CharT>();
AssertNotPathable<bad_iter_type>();
AssertNotPathable<signed char*>();
}
};
int main() {
MakeTestType<char>::Test();
MakeTestType<wchar_t>::Test();
MakeTestType<char16_t>::Test();
MakeTestType<char32_t>::Test();
}

View File

@@ -0,0 +1,3 @@
# Disable all of the filesystem tests if the correct feature is not available.
if 'c++filesystem' not in config.available_features:
config.unsupported = True

View File

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