r286356 - [VFS] Replace TimeValue usage with std::chrono
Pavel Labath via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 9 02:52:23 PST 2016
Author: labath
Date: Wed Nov 9 04:52:22 2016
New Revision: 286356
URL: http://llvm.org/viewvc/llvm-project?rev=286356&view=rev
Log:
[VFS] Replace TimeValue usage with std::chrono
Summary: NFCI
Reviewers: benlangmuir, zturner
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25948
Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/FileSystemStatCache.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Wed Nov 9 04:52:22 2016
@@ -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 <utility>
@@ -34,7 +34,7 @@ namespace vfs {
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 @@ public:
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 @@ public:
/// @{
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; }
Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp (original)
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp Wed Nov 9 04:52:22 2016
@@ -23,7 +23,7 @@ static void copyStatusToFileData(const v
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;
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Nov 9 04:52:22 2016
@@ -47,7 +47,7 @@ Status::Status(const file_status &Status
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 @@ public:
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 @@ bool InMemoryFileSystem::addFile(const T
// 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 @@ bool InMemoryFileSystem::addFile(const T
// 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<detail::InMemoryDirectory>(Dir->addChild(
Name, llvm::make_unique<detail::InMemoryDirectory>(std::move(Stat))));
continue;
@@ -1073,8 +1073,9 @@ class RedirectingFileSystemParser {
// ... or create a new one
std::unique_ptr<Entry> E = llvm::make_unique<RedirectingDirectoryEntry>(
- 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 @@ class RedirectingFileSystemParser {
case EK_Directory:
Result = llvm::make_unique<RedirectingDirectoryEntry>(
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 @@ class RedirectingFileSystemParser {
Entries.push_back(std::move(Result));
Result = llvm::make_unique<RedirectingDirectoryEntry>(
*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;
}
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Nov 9 04:52:22 2016
@@ -1392,7 +1392,8 @@ ASTUnit::getMainBufferWithPrecompiledPre
}
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 @@ ASTUnit::getMainBufferWithPrecompiledPre
// 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;
}
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Wed Nov 9 04:52:22 2016
@@ -102,7 +102,7 @@ ModuleManager::addModule(StringRef FileN
// 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
Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=286356&r1=286355&r2=286356&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Wed Nov 9 04:52:22 2016
@@ -115,20 +115,23 @@ public:
}
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);
}
};
More information about the cfe-commits
mailing list