From: Eric Fiselier Date: Mon, 2 Apr 2018 23:03:41 +0000 (+0000) Subject: Implement filesystem NB comments, relative paths, and related issues. X-Git-Tag: llvmorg-7.0.0-rc1~9162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7fae181c3954886257fb33d0a57b954b26da745;p=platform%2Fupstream%2Fllvm.git 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 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 --- diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt index 8a154d8..f557d4a 100644 --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -68,7 +68,7 @@ set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx) set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) set(BENCHMARK_TEST_COMPILE_FLAGS - -std=c++14 -O2 + -std=c++17 -O2 -I${BENCHMARK_LIBCXX_INSTALL}/include -I${LIBCXX_SOURCE_DIR}/test/support ) diff --git a/libcxx/benchmarks/GenerateInput.hpp b/libcxx/benchmarks/GenerateInput.hpp index 9d5adac..8c97f58 100644 --- a/libcxx/benchmarks/GenerateInput.hpp +++ b/libcxx/benchmarks/GenerateInput.hpp @@ -29,14 +29,16 @@ inline std::default_random_engine& getRandomEngine() { return RandEngine; } + inline char getRandomChar() { std::uniform_int_distribution<> LettersDist(0, LettersSize-1); return Letters[LettersDist(getRandomEngine())]; } template -inline IntT getRandomInteger() { - std::uniform_int_distribution dist; +inline IntT getRandomInteger(IntT Min = 0, + IntT Max = std::numeric_limits::max()) { + std::uniform_int_distribution dist(Min, Max); return dist(getRandomEngine()); } diff --git a/libcxx/benchmarks/filesystem.bench.cpp b/libcxx/benchmarks/filesystem.bench.cpp index 6771980..3e49560 100644 --- a/libcxx/benchmarks/filesystem.bench.cpp +++ b/libcxx/benchmarks/filesystem.bench.cpp @@ -1,17 +1,14 @@ -#include - #include "benchmark/benchmark.h" #include "GenerateInput.hpp" #include "test_iterators.h" - -namespace fs = std::experimental::filesystem; +#include "filesystem_include.hpp" static const size_t TestNumInputs = 1024; template void BM_PathConstructString(benchmark::State &st, GenInputs gen) { - using namespace fs; + using fs::path; const auto in = gen(st.range(0)); path PP; for (auto& Part : in) @@ -21,14 +18,15 @@ void BM_PathConstructString(benchmark::State &st, GenInputs gen) { const path P(PP.native()); benchmark::DoNotOptimize(P.native().data()); } + st.SetComplexityN(st.range(0)); } BENCHMARK_CAPTURE(BM_PathConstructString, large_string, - getRandomStringInputs)->Arg(TestNumInputs); + getRandomStringInputs)->Range(8, TestNumInputs)->Complexity(); template void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) { - using namespace fs; + using fs::path; const auto in = gen(st.range(0)); path PP; for (auto& Part : in) @@ -45,7 +43,7 @@ BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string, template