[libcxx] r283714 - Workaround missing C++14 constexpr semantics in filesystem

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 9 22:19:59 PDT 2016


Author: ericwf
Date: Mon Oct 10 00:19:59 2016
New Revision: 283714

URL: http://llvm.org/viewvc/llvm-project?rev=283714&view=rev
Log:
Workaround missing C++14 constexpr semantics in filesystem

Modified:
    libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=283714&r1=283713&r2=283714&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Mon Oct 10 00:19:59 2016
@@ -536,7 +536,8 @@ constexpr auto min_time_t = numeric_limi
 #pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
 #endif
 
-constexpr bool is_representable(TimeSpec const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+bool is_representable(TimeSpec const& tm) {
   if (tm.tv_sec >= 0) {
     return (tm.tv_sec < max_seconds) ||
         (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
@@ -546,7 +547,7 @@ constexpr bool is_representable(TimeSpec
     return (tm.tv_sec >= min_seconds);
   }
 }
-
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(is_representable({max_seconds, max_nsec}), "");
 static_assert(!is_representable({max_seconds + 1, 0}), "");
@@ -562,8 +563,10 @@ static_assert(is_representable({max_time
 static_assert(is_representable({max_time_t, 1000000000}), "");
 static_assert(is_representable({min_time_t, 0}), "");
 #endif
+#endif
 
-constexpr bool is_representable(file_time_type const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+bool is_representable(file_time_type const& tm) {
   auto secs = duration_cast<seconds>(tm.time_since_epoch());
   auto nsecs = duration_cast<nanoseconds>(tm.time_since_epoch() - secs);
   if (nsecs.count() < 0) {
@@ -575,6 +578,7 @@ constexpr bool is_representable(file_tim
     return secs.count() <= TLim::max();
   return secs.count() >= TLim::min();
 }
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(is_representable(file_time_type::max()), "");
 static_assert(is_representable(file_time_type::min()), "");
@@ -584,9 +588,10 @@ static_assert(!is_representable(file_tim
 static_assert(is_representable(file_time_type(seconds(max_time_t))), "");
 static_assert(is_representable(file_time_type(seconds(min_time_t))), "");
 #endif
+#endif
 
-template <long long V> struct Dummy;
-constexpr file_time_type convert_timespec(TimeSpec const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+file_time_type convert_timespec(TimeSpec const& tm) {
   auto adj_msec = duration_cast<microseconds>(nanoseconds(tm.tv_nsec));
   if (tm.tv_sec >= 0) {
     auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
@@ -599,6 +604,7 @@ constexpr file_time_type convert_timespe
     return file_time_type(Dur);
   }
 }
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(convert_timespec({max_seconds, max_nsec}) == file_time_type::max(), "");
 static_assert(convert_timespec({max_seconds, max_nsec - 1}) < file_time_type::max(), "");
@@ -609,6 +615,7 @@ static_assert(convert_timespec({min_seco
 #else
 // FIXME add tests for 32 bit builds
 #endif
+#endif
 
 #if !defined(__LP64__) && defined(__clang__)
 #pragma clang diagnostic pop




More information about the cfe-commits mailing list