Remove TimeValue usage from llvm/Support

Summary:
This is a follow-up to D25416. It removes all usages of TimeValue from
llvm/Support library (except for the actual TimeValue declaration), and replaces
them with appropriate usages of std::chrono. To facilitate this, I have added
small utility functions for converting time points and durations into appropriate
OS-specific types (FILETIME, struct timespec, ...).

Reviewers: zturner, mehdi_amini

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25730

llvm-svn: 284966
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index b7cb959..18a5f24 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/MachO.h"
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
@@ -353,9 +354,9 @@
     Expected<uint64_t> Size = C.getSize();
     failIfError(Size.takeError());
     outs() << ' ' << format("%6llu", Size.get());
-    Expected<sys::TimeValue> ModTimeOrErr = C.getLastModified();
+    auto ModTimeOrErr = C.getLastModified();
     failIfError(ModTimeOrErr.takeError());
-    outs() << ' ' << ModTimeOrErr.get().str();
+    outs() << ' ' << ModTimeOrErr.get();
     outs() << ' ';
   }
   outs() << Name << "\n";
@@ -387,7 +388,7 @@
   // If we're supposed to retain the original modification times, etc. do so
   // now.
   if (OriginalDates) {
-    Expected<sys::TimeValue> ModTimeOrErr = C.getLastModified();
+    auto ModTimeOrErr = C.getLastModified();
     failIfError(ModTimeOrErr.takeError());
     failIfError(
         sys::fs::setLastModificationAndAccessTime(FD, ModTimeOrErr.get()));
@@ -525,9 +526,9 @@
     // operation.
     sys::fs::file_status Status;
     failIfError(sys::fs::status(*MI, Status), *MI);
-    Expected<sys::TimeValue> ModTimeOrErr = Member.getLastModified();
+    auto ModTimeOrErr = Member.getLastModified();
     failIfError(ModTimeOrErr.takeError());
-    if (Status.getLastModificationTime() < ModTimeOrErr.get()) {
+    if (sys::TimeValue(Status.getLastModificationTime()) < ModTimeOrErr.get()) {
       if (PosName.empty())
         return IA_AddOldMember;
       return IA_MoveOldMember;