Index: include/clang/Basic/VirtualFileSystem.h =================================================================== --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @@ -16,10 +16,10 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/Optional.h" +#include "llvm/Support/Chrono.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/Support/TimeValue.h" #include "llvm/Support/raw_ostream.h" #include @@ -34,7 +34,7 @@ class Status { std::string Name; llvm::sys::fs::UniqueID UID; - llvm::sys::TimeValue MTime; + llvm::sys::TimePoint<> MTime; uint32_t User; uint32_t Group; uint64_t Size; @@ -48,7 +48,7 @@ Status() : Type(llvm::sys::fs::file_type::status_error) {} Status(const llvm::sys::fs::file_status &Status); Status(StringRef Name, llvm::sys::fs::UniqueID UID, - llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group, + llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group, uint64_t Size, llvm::sys::fs::file_type Type, llvm::sys::fs::perms Perms); @@ -64,7 +64,7 @@ /// @{ llvm::sys::fs::file_type getType() const { return Type; } llvm::sys::fs::perms getPermissions() const { return Perms; } - llvm::sys::TimeValue getLastModificationTime() const { return MTime; } + llvm::sys::TimePoint<> getLastModificationTime() const { return MTime; } llvm::sys::fs::UniqueID getUniqueID() const { return UID; } uint32_t getUser() const { return User; } uint32_t getGroup() const { return Group; } Index: lib/Basic/FileSystemStatCache.cpp =================================================================== --- lib/Basic/FileSystemStatCache.cpp +++ lib/Basic/FileSystemStatCache.cpp @@ -23,7 +23,7 @@ FileData &Data) { Data.Name = Status.getName(); Data.Size = Status.getSize(); - Data.ModTime = Status.getLastModificationTime().toEpochTime(); + Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime()); Data.UniqueID = Status.getUniqueID(); Data.IsDirectory = Status.isDirectory(); Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file; Index: lib/Basic/VirtualFileSystem.cpp =================================================================== --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -47,7 +47,7 @@ User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()), Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false) {} -Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime, +Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime, uint32_t User, uint32_t Group, uint64_t Size, file_type Type, perms Perms) : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size), @@ -494,8 +494,8 @@ InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths) : Root(new detail::InMemoryDirectory( - Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(), - 0, 0, 0, llvm::sys::fs::file_type::directory_file, + Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0, + 0, llvm::sys::fs::file_type::directory_file, llvm::sys::fs::perms::all_all))), UseNormalizedPaths(UseNormalizedPaths) {} @@ -532,7 +532,7 @@ // End of the path, create a new file. // FIXME: expose the status details in the interface. Status Stat(P.str(), getNextVirtualUniqueID(), - llvm::sys::TimeValue(ModificationTime, 0), 0, 0, + llvm::sys::toTimePoint(ModificationTime), 0, 0, Buffer->getBufferSize(), llvm::sys::fs::file_type::regular_file, llvm::sys::fs::all_all); @@ -545,9 +545,9 @@ // FIXME: expose the status details in the interface. Status Stat( StringRef(Path.str().begin(), Name.end() - Path.str().begin()), - getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime, 0), - 0, 0, Buffer->getBufferSize(), - llvm::sys::fs::file_type::directory_file, llvm::sys::fs::all_all); + getNextVirtualUniqueID(), llvm::sys::toTimePoint(ModificationTime), 0, + 0, Buffer->getBufferSize(), llvm::sys::fs::file_type::directory_file, + llvm::sys::fs::all_all); Dir = cast(Dir->addChild( Name, llvm::make_unique(std::move(Stat)))); continue; @@ -1073,8 +1073,9 @@ // ... or create a new one std::unique_ptr E = llvm::make_unique( - Name, Status("", getNextVirtualUniqueID(), sys::TimeValue::now(), 0, 0, - 0, file_type::directory_file, sys::fs::all_all)); + Name, + Status("", getNextVirtualUniqueID(), std::chrono::system_clock::now(), + 0, 0, 0, file_type::directory_file, sys::fs::all_all)); if (!ParentEntry) { // Add a new root to the overlay FS->Roots.push_back(std::move(E)); @@ -1275,8 +1276,8 @@ case EK_Directory: Result = llvm::make_unique( LastComponent, std::move(EntryArrayContents), - Status("", getNextVirtualUniqueID(), sys::TimeValue::now(), 0, 0, 0, - file_type::directory_file, sys::fs::all_all)); + Status("", getNextVirtualUniqueID(), std::chrono::system_clock::now(), + 0, 0, 0, file_type::directory_file, sys::fs::all_all)); break; } @@ -1292,8 +1293,8 @@ Entries.push_back(std::move(Result)); Result = llvm::make_unique( *I, std::move(Entries), - Status("", getNextVirtualUniqueID(), sys::TimeValue::now(), 0, 0, 0, - file_type::directory_file, sys::fs::all_all)); + Status("", getNextVirtualUniqueID(), std::chrono::system_clock::now(), + 0, 0, 0, file_type::directory_file, sys::fs::all_all)); } return Result; } Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -1392,7 +1392,8 @@ } OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile( - Status.getSize(), Status.getLastModificationTime().toEpochTime()); + Status.getSize(), + llvm::sys::toTimeT(Status.getLastModificationTime())); } for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) { @@ -1433,8 +1434,8 @@ // The file was not remapped; check whether it has changed on disk. if (Status.getSize() != uint64_t(F->second.Size) || - Status.getLastModificationTime().toEpochTime() != - uint64_t(F->second.ModTime)) + llvm::sys::toTimeT(Status.getLastModificationTime()) != + F->second.ModTime) AnyFileChanged = true; } Index: lib/Serialization/ModuleManager.cpp =================================================================== --- lib/Serialization/ModuleManager.cpp +++ lib/Serialization/ModuleManager.cpp @@ -102,7 +102,7 @@ // A cached stat value would be fine as well. if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status)) ModuleEntry->InputFilesValidationTimestamp = - Status.getLastModificationTime().toEpochTime(); + llvm::sys::toTimeT(Status.getLastModificationTime()); } // Load the contents of the module Index: unittests/Basic/VirtualFileSystemTest.cpp =================================================================== --- unittests/Basic/VirtualFileSystemTest.cpp +++ unittests/Basic/VirtualFileSystemTest.cpp @@ -115,20 +115,23 @@ } void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) { - vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0, - 1024, sys::fs::file_type::regular_file, Perms); + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 1024, + sys::fs::file_type::regular_file, Perms); addEntry(Path, S); } void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) { - vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0, - 0, sys::fs::file_type::directory_file, Perms); + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 0, + sys::fs::file_type::directory_file, Perms); addEntry(Path, S); } void addSymlink(StringRef Path) { - vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0, - 0, sys::fs::file_type::symlink_file, sys::fs::all_all); + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 0, + sys::fs::file_type::symlink_file, sys::fs::all_all); addEntry(Path, S); } };