From 866885e12a2278a77dcb195872730d8b0498e43e Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Fri, 21 Dec 2018 03:54:57 +0000 Subject: Implement LWG 3145: file_clock breaks ABI for C++17 implementations. This patch adds std::chrono::file_clock, but without breaking the existing ABI for std::filesystem. llvm-svn: 349883 --- .../time.clock.file/consistency.pass.cpp | 35 ++++++++++++++++++++++ .../time.clock/time.clock.file/file_time.pass.cpp | 29 ++++++++++++++++++ .../time/time.clock/time.clock.file/now.pass.cpp | 35 ++++++++++++++++++++++ .../time.clock/time.clock.file/rep_signed.pass.cpp | 29 ++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp (limited to 'libcxx/test/std') diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp new file mode 100644 index 00000000000..275faa6288d --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 +// +// TODO: Remove this when filesystem gets integrated into the dylib +// REQUIRES: c++filesystem + +// + +// file_clock + +// check clock invariants + +#include + +template +void test(const T &) {} + +int main() +{ + typedef std::chrono::system_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((C::is_steady || !C::is_steady), ""); + test(std::chrono::system_clock::is_steady); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp new file mode 100644 index 00000000000..955e3ebe9d5 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// + +// file_time + +#include + +#include "test_macros.h" + +template +void test() { + ASSERT_SAME_TYPE(std::chrono::file_time, std::chrono::time_point); +} + +int main() { + test(); + test(); + test(); +} \ No newline at end of file diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp new file mode 100644 index 00000000000..69dfa918093 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// TODO: Remove this when filesystem gets integrated into the dylib +// REQUIRES: c++filesystem + +// + +// file_clock + +// static time_point now() noexcept; + +#include +#include + +#include "test_macros.h" + +int main() +{ + typedef std::chrono::file_clock C; + ASSERT_NOEXCEPT(C::now()); + + C::time_point t1 = C::now(); + assert(t1.time_since_epoch().count() != 0); + assert(C::time_point::min() < t1); + assert(C::time_point::max() > t1); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp new file mode 100644 index 00000000000..c0fa0b5beda --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// TODO: Remove this when filesystem gets integrated into the dylib +// REQUIRES: c++filesystem + +// + +// file_clock + +// rep should be signed + +#include +#include + +int main() +{ + static_assert(std::is_signed::value, ""); + assert(std::chrono::file_clock::duration::min() < + std::chrono::file_clock::duration::zero()); +} -- cgit v1.2.3