summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2014-08-29 01:05:12 +0000
committerChris Bieneman <beanz@apple.com>2014-08-29 01:05:12 +0000
commit5e7f44c25edb8e16e9250c51674ca9abef20048e (patch)
tree2561046d5592fe6fc09a8cd1540e8cc3cfa9de3a
parent4a9187a8105416b17349d4b589d073fe62a106eb (diff)
downloadbcm5719-llvm-5e7f44c25edb8e16e9250c51674ca9abef20048e.tar.gz
bcm5719-llvm-5e7f44c25edb8e16e9250c51674ca9abef20048e.zip
Cleaning up static initializers in TimeValue.
Code reviewed by Chandlerc llvm-svn: 216703
-rw-r--r--llvm/include/llvm/Support/TimeValue.h20
-rw-r--r--llvm/lib/Support/TimeValue.cpp6
-rw-r--r--llvm/lib/Support/Unix/TimeValue.inc2
-rw-r--r--llvm/unittests/Support/ProcessTest.cpp12
4 files changed, 22 insertions, 18 deletions
diff --git a/llvm/include/llvm/Support/TimeValue.h b/llvm/include/llvm/Support/TimeValue.h
index ee0e2866d59..6bca58b6bc2 100644
--- a/llvm/include/llvm/Support/TimeValue.h
+++ b/llvm/include/llvm/Support/TimeValue.h
@@ -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.
- 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.
- 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.
- 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.
- 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.
- static const TimeValue Win32ZeroTime;
+ static TimeValue Win32ZeroTime() {
+ return TimeValue ( Win32ZeroTimeSeconds,0 );
+ }
/// @}
/// @name Types
diff --git a/llvm/lib/Support/TimeValue.cpp b/llvm/lib/Support/TimeValue.cpp
index 4a707979420..136b93eceef 100644
--- a/llvm/lib/Support/TimeValue.cpp
+++ b/llvm/lib/Support/TimeValue.cpp
@@ -22,12 +22,6 @@ const TimeValue::SecondsType
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 ) {
diff --git a/llvm/lib/Support/Unix/TimeValue.inc b/llvm/lib/Support/Unix/TimeValue.inc
index 7d4acf7bf63..042e0dacc34 100644
--- a/llvm/lib/Support/Unix/TimeValue.inc
+++ b/llvm/lib/Support/Unix/TimeValue.inc
@@ -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.
- return MinTime;
+ return MinTime();
}
return TimeValue(
diff --git a/llvm/unittests/Support/ProcessTest.cpp b/llvm/unittests/Support/ProcessTest.cpp
index f4060720961..3045c305bc5 100644
--- a/llvm/unittests/Support/ProcessTest.cpp
+++ b/llvm/unittests/Support/ProcessTest.cpp
@@ -31,12 +31,12 @@ TEST(ProcessTest, SelfProcess) {
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) {
OpenPOWER on IntegriCloud