Cleaning up static initializers in TimeValue.
authorChris Bieneman <beanz@apple.com>
Fri, 29 Aug 2014 01:05:12 +0000 (01:05 +0000)
committerChris Bieneman <beanz@apple.com>
Fri, 29 Aug 2014 01:05:12 +0000 (01:05 +0000)
Code reviewed by Chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216703 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/TimeValue.h
lib/Support/TimeValue.cpp
lib/Support/Unix/TimeValue.inc
unittests/Support/ProcessTest.cpp

index ee0e2866d59efedb1e09d63005b69c509c3cd594..6bca58b6bc2085e376e6952740680ea889ca5a5d 100644 (file)
@@ -38,28 +38,38 @@ namespace sys {
     /// value permissible by the class. MinTime is some point
     /// in the distant past, about 300 billion years BCE.
     /// @brief The smallest possible time value.
     /// value permissible by the class. MinTime is some point
     /// in the distant past, about 300 billion years BCE.
     /// @brief The smallest possible time value.
-    static const TimeValue MinTime;
+    static TimeValue MinTime() {
+      return TimeValue ( INT64_MIN,0 );
+    }
 
     /// A constant TimeValue representing the largest time
     /// value permissible by the class. MaxTime is some point
     /// in the distant future, about 300 billion years AD.
     /// @brief The largest possible time value.
 
     /// A constant TimeValue representing the largest time
     /// value permissible by the class. MaxTime is some point
     /// in the distant future, about 300 billion years AD.
     /// @brief The largest possible time value.
-    static const TimeValue MaxTime;
+    static TimeValue MaxTime() {
+      return TimeValue ( INT64_MAX,0 );
+    }
 
     /// A constant TimeValue representing the base time,
     /// or zero time of 00:00:00 (midnight) January 1st, 2000.
     /// @brief 00:00:00 Jan 1, 2000 UTC.
 
     /// A constant TimeValue representing the base time,
     /// or zero time of 00:00:00 (midnight) January 1st, 2000.
     /// @brief 00:00:00 Jan 1, 2000 UTC.
-    static const TimeValue ZeroTime;
+    static TimeValue ZeroTime() {
+      return TimeValue ( 0,0 );
+    }
 
     /// A constant TimeValue for the Posix base time which is
     /// 00:00:00 (midnight) January 1st, 1970.
     /// @brief 00:00:00 Jan 1, 1970 UTC.
 
     /// A constant TimeValue for the Posix base time which is
     /// 00:00:00 (midnight) January 1st, 1970.
     /// @brief 00:00:00 Jan 1, 1970 UTC.
-    static const TimeValue PosixZeroTime;
+    static TimeValue PosixZeroTime() {
+      return TimeValue ( PosixZeroTimeSeconds,0 );
+    }
 
     /// A constant TimeValue for the Win32 base time which is
     /// 00:00:00 (midnight) January 1st, 1601.
     /// @brief 00:00:00 Jan 1, 1601 UTC.
 
     /// A constant TimeValue for the Win32 base time which is
     /// 00:00:00 (midnight) January 1st, 1601.
     /// @brief 00:00:00 Jan 1, 1601 UTC.
-    static const TimeValue Win32ZeroTime;
+    static TimeValue Win32ZeroTime() {
+      return TimeValue ( Win32ZeroTimeSeconds,0 );
+    }
 
   /// @}
   /// @name Types
 
   /// @}
   /// @name Types
index 4a70797942048e4cf5ff3547cdbddfcc7329195e..136b93eceefaa0484d2783f1f8d7c978f8a00785 100644 (file)
@@ -22,12 +22,6 @@ const TimeValue::SecondsType
 const TimeValue::SecondsType
   TimeValue::Win32ZeroTimeSeconds = -12591158400ULL;
 
 const TimeValue::SecondsType
   TimeValue::Win32ZeroTimeSeconds = -12591158400ULL;
 
-const TimeValue TimeValue::MinTime       = TimeValue ( INT64_MIN,0 );
-const TimeValue TimeValue::MaxTime       = TimeValue ( INT64_MAX,0 );
-const TimeValue TimeValue::ZeroTime      = TimeValue ( 0,0 );
-const TimeValue TimeValue::PosixZeroTime = TimeValue ( PosixZeroTimeSeconds,0 );
-const TimeValue TimeValue::Win32ZeroTime = TimeValue ( Win32ZeroTimeSeconds,0 );
-
 void
 TimeValue::normalize( void ) {
   if ( nanos_ >= NANOSECONDS_PER_SECOND ) {
 void
 TimeValue::normalize( void ) {
   if ( nanos_ >= NANOSECONDS_PER_SECOND ) {
index 7d4acf7bf63cf4c61701e203a6be77ff5571d449..042e0dacc346ccfbab772cc3d5a9991fe37765be 100644 (file)
@@ -41,7 +41,7 @@ TimeValue TimeValue::now() {
     // errors concern the timezone parameter which we're passing in as 0.
     // In the unlikely case it does happen, just return MinTime, no error
     // message needed.
     // errors concern the timezone parameter which we're passing in as 0.
     // In the unlikely case it does happen, just return MinTime, no error
     // message needed.
-    return MinTime;
+    return MinTime();
   }
 
   return TimeValue(
   }
 
   return TimeValue(
index f4060720961b64adfafacf4178a5ed3aa6321b19..3045c305bc58c02750870b0b5ee3e12d4c5efe0c 100644 (file)
@@ -31,12 +31,12 @@ TEST(ProcessTest, SelfProcess) {
 
   EXPECT_LT(1u, process::get_self()->page_size());
 
 
   EXPECT_LT(1u, process::get_self()->page_size());
 
-  EXPECT_LT(TimeValue::MinTime, process::get_self()->get_user_time());
-  EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_user_time());
-  EXPECT_LT(TimeValue::MinTime, process::get_self()->get_system_time());
-  EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_system_time());
-  EXPECT_LT(TimeValue::MinTime, process::get_self()->get_wall_time());
-  EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_wall_time());
+  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_user_time());
+  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_user_time());
+  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_system_time());
+  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_system_time());
+  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_wall_time());
+  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_wall_time());
 }
 
 TEST(ProcessTest, GetRandomNumberTest) {
 }
 
 TEST(ProcessTest, GetRandomNumberTest) {