Skip to content

Commit bcdf7f5

Browse files
committed
[clang][deps] NFC: Take and store entry as reference
1 parent af7a421 commit bcdf7f5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,31 @@ class EntryRef {
177177
bool Minimized;
178178

179179
/// The underlying cached entry.
180-
const CachedFileSystemEntry *Entry;
180+
const CachedFileSystemEntry &Entry;
181181

182182
public:
183-
EntryRef(bool Minimized, const CachedFileSystemEntry *Entry)
183+
EntryRef(bool Minimized, const CachedFileSystemEntry &Entry)
184184
: Minimized(Minimized), Entry(Entry) {}
185185

186186
llvm::ErrorOr<llvm::vfs::Status> getStatus() const {
187-
auto MaybeStat = Entry->getStatus();
187+
auto MaybeStat = Entry.getStatus();
188188
if (!MaybeStat || MaybeStat->isDirectory())
189189
return MaybeStat;
190190
return llvm::vfs::Status::copyWithNewSize(*MaybeStat,
191191
getContents()->size());
192192
}
193193

194-
bool isDirectory() const { return Entry->isDirectory(); }
194+
bool isDirectory() const { return Entry.isDirectory(); }
195195

196-
StringRef getName() const { return Entry->getName(); }
196+
StringRef getName() const { return Entry.getName(); }
197197

198198
llvm::ErrorOr<StringRef> getContents() const {
199-
return Minimized ? Entry->getMinimizedContents()
200-
: Entry->getOriginalContents();
199+
return Minimized ? Entry.getMinimizedContents()
200+
: Entry.getOriginalContents();
201201
}
202202

203203
const PreprocessorSkippedRangeMapping *getPPSkippedRangeMapping() const {
204-
return Minimized ? &Entry->getPPSkippedRangeMapping() : nullptr;
204+
return Minimized ? &Entry.getPPSkippedRangeMapping() : nullptr;
205205
}
206206
};
207207

clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
163163

164164
const auto *Entry = LocalCache.getCachedEntry(Filename);
165165
if (Entry && !Entry->needsUpdate(ShouldBeMinimized))
166-
return EntryRef(ShouldBeMinimized, Entry);
166+
return EntryRef(ShouldBeMinimized, *Entry);
167167

168168
// FIXME: Handle PCM/PCH files.
169169
// FIXME: Handle module map files.
@@ -193,7 +193,7 @@ DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
193193

194194
// Store the result in the local cache.
195195
Entry = &SharedCacheEntry.Value;
196-
return EntryRef(ShouldBeMinimized, Entry);
196+
return EntryRef(ShouldBeMinimized, *Entry);
197197
}
198198

199199
llvm::ErrorOr<llvm::vfs::Status>

0 commit comments

Comments
 (0)