diff options
author | Harlan Haskins <harlan@harlanhaskins.com> | 2019-03-05 02:27:12 +0000 |
---|---|---|
committer | Harlan Haskins <harlan@harlanhaskins.com> | 2019-03-05 02:27:12 +0000 |
commit | 06f64d53ae5f616e5b860783991844665556064d (patch) | |
tree | 4a4acedb96226ed9fdd28f8a1096b4f3fb9d6592 /clang/lib/Basic/FileSystemStatCache.cpp | |
parent | 1c014d75b4cdcfab5cef304e5f9c5def96468751 (diff) | |
download | bcm5719-llvm-06f64d53ae5f616e5b860783991844665556064d.tar.gz bcm5719-llvm-06f64d53ae5f616e5b860783991844665556064d.zip |
Replace clang::FileData with llvm::vfs::Status
Summary:
FileData was only ever used as a container for the values in
llvm::vfs::Status, so they might as well be consolidated.
The `InPCH` member was also always set to false, and unused.
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58924
llvm-svn: 355368
Diffstat (limited to 'clang/lib/Basic/FileSystemStatCache.cpp')
-rw-r--r-- | clang/lib/Basic/FileSystemStatCache.cpp | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp index d29ebb750fc..2d21c424445 100644 --- a/clang/lib/Basic/FileSystemStatCache.cpp +++ b/clang/lib/Basic/FileSystemStatCache.cpp @@ -21,18 +21,6 @@ using namespace clang; void FileSystemStatCache::anchor() {} -static void copyStatusToFileData(const llvm::vfs::Status &Status, - FileData &Data) { - Data.Name = Status.getName(); - Data.Size = Status.getSize(); - 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; - Data.InPCH = false; - Data.IsVFSMapped = Status.IsVFSMapped; -} - /// FileSystemStatCache::get - Get the 'stat' information for the specified /// path, using the cache to accelerate it if possible. This returns true if /// the path does not exist or false if it exists. @@ -42,7 +30,8 @@ static void copyStatusToFileData(const llvm::vfs::Status &Status, /// success for directories (not files). On a successful file lookup, the /// implementation can optionally fill in FileDescriptor with a valid /// descriptor and the client guarantees that it will close it. -bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile, +bool FileSystemStatCache::get(StringRef Path, llvm::vfs::Status &Status, + bool isFile, std::unique_ptr<llvm::vfs::File> *F, FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS) { @@ -51,16 +40,16 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile, // If we have a cache, use it to resolve the stat query. if (Cache) - R = Cache->getStat(Path, Data, isFile, F, FS); + R = Cache->getStat(Path, Status, isFile, F, FS); else if (isForDir || !F) { // If this is a directory or a file descriptor is not needed and we have // no cache, just go to the file system. - llvm::ErrorOr<llvm::vfs::Status> Status = FS.status(Path); - if (!Status) { + llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = FS.status(Path); + if (!StatusOrErr) { R = CacheMissing; } else { R = CacheExists; - copyStatusToFileData(*Status, Data); + Status = *StatusOrErr; } } else { // Otherwise, we have to go to the filesystem. We can always just use @@ -79,10 +68,10 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile, // Otherwise, the open succeeded. Do an fstat to get the information // about the file. We'll end up returning the open file descriptor to the // client to do what they please with it. - llvm::ErrorOr<llvm::vfs::Status> Status = (*OwnedFile)->status(); - if (Status) { + llvm::ErrorOr<llvm::vfs::Status> StatusOrErr = (*OwnedFile)->status(); + if (StatusOrErr) { R = CacheExists; - copyStatusToFileData(*Status, Data); + Status = *StatusOrErr; *F = std::move(*OwnedFile); } else { // fstat rarely fails. If it does, claim the initial open didn't @@ -98,7 +87,7 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile, // If the path exists, make sure that its "directoryness" matches the clients // demands. - if (Data.IsDirectory != isForDir) { + if (Status.isDirectory() != isForDir) { // If not, close the file if opened. if (F) *F = nullptr; @@ -110,10 +99,11 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile, } MemorizeStatCalls::LookupResult -MemorizeStatCalls::getStat(StringRef Path, FileData &Data, bool isFile, +MemorizeStatCalls::getStat(StringRef Path, llvm::vfs::Status &Status, + bool isFile, std::unique_ptr<llvm::vfs::File> *F, llvm::vfs::FileSystem &FS) { - if (get(Path, Data, isFile, F, nullptr, FS)) { + if (get(Path, Status, isFile, F, nullptr, FS)) { // Do not cache failed stats, it is easy to construct common inconsistent // situations if we do, and they are not important for PCH performance // (which currently only needs the stats to construct the initial @@ -122,8 +112,8 @@ MemorizeStatCalls::getStat(StringRef Path, FileData &Data, bool isFile, } // Cache file 'stat' results and directories with absolutely paths. - if (!Data.IsDirectory || llvm::sys::path::is_absolute(Path)) - StatCalls[Path] = Data; + if (!Status.isDirectory() || llvm::sys::path::is_absolute(Path)) + StatCalls[Path] = Status; return CacheExists; } |