[clang] bcdf7f5 - [clang][deps] NFC: Take and store entry as reference
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 17 05:00:32 PST 2021
Author: Jan Svoboda
Date: 2021-12-17T14:00:20+01:00
New Revision: bcdf7f5e9104cb87d06969d74f4feb0cc7aba08f
URL: https://github.com/llvm/llvm-project/commit/bcdf7f5e9104cb87d06969d74f4feb0cc7aba08f
DIFF: https://github.com/llvm/llvm-project/commit/bcdf7f5e9104cb87d06969d74f4feb0cc7aba08f.diff
LOG: [clang][deps] NFC: Take and store entry as reference
Added:
Modified:
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index 855ab0626b3d..7d0b8f2138f9 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -177,31 +177,31 @@ class EntryRef {
bool Minimized;
/// The underlying cached entry.
- const CachedFileSystemEntry *Entry;
+ const CachedFileSystemEntry &Entry;
public:
- EntryRef(bool Minimized, const CachedFileSystemEntry *Entry)
+ EntryRef(bool Minimized, const CachedFileSystemEntry &Entry)
: Minimized(Minimized), Entry(Entry) {}
llvm::ErrorOr<llvm::vfs::Status> getStatus() const {
- auto MaybeStat = Entry->getStatus();
+ auto MaybeStat = Entry.getStatus();
if (!MaybeStat || MaybeStat->isDirectory())
return MaybeStat;
return llvm::vfs::Status::copyWithNewSize(*MaybeStat,
getContents()->size());
}
- bool isDirectory() const { return Entry->isDirectory(); }
+ bool isDirectory() const { return Entry.isDirectory(); }
- StringRef getName() const { return Entry->getName(); }
+ StringRef getName() const { return Entry.getName(); }
llvm::ErrorOr<StringRef> getContents() const {
- return Minimized ? Entry->getMinimizedContents()
- : Entry->getOriginalContents();
+ return Minimized ? Entry.getMinimizedContents()
+ : Entry.getOriginalContents();
}
const PreprocessorSkippedRangeMapping *getPPSkippedRangeMapping() const {
- return Minimized ? &Entry->getPPSkippedRangeMapping() : nullptr;
+ return Minimized ? &Entry.getPPSkippedRangeMapping() : nullptr;
}
};
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 199ab2bfe882..8ea59cb0d9a4 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -163,7 +163,7 @@ DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
const auto *Entry = LocalCache.getCachedEntry(Filename);
if (Entry && !Entry->needsUpdate(ShouldBeMinimized))
- return EntryRef(ShouldBeMinimized, Entry);
+ return EntryRef(ShouldBeMinimized, *Entry);
// FIXME: Handle PCM/PCH files.
// FIXME: Handle module map files.
@@ -193,7 +193,7 @@ DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
// Store the result in the local cache.
Entry = &SharedCacheEntry.Value;
- return EntryRef(ShouldBeMinimized, Entry);
+ return EntryRef(ShouldBeMinimized, *Entry);
}
llvm::ErrorOr<llvm::vfs::Status>
More information about the cfe-commits
mailing list