[clang] [llvm] [clang][deps] Cache `VFS::getRealPath()` (PR #68645)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 11 11:08:27 PDT 2024
================
@@ -230,6 +251,26 @@ class DependencyScanningFilesystemLocalCache {
assert(InsertedEntry == &Entry && "entry already present");
return *InsertedEntry;
}
+
+ /// Returns real path associated with the filename or nullptr if none is
+ /// found.
+ const CachedRealPath *findRealPathByFilename(StringRef Filename) const {
+ assert(llvm::sys::path::is_absolute_gnu(Filename));
+ auto It = RealPathCache.find(Filename);
+ return It == RealPathCache.end() ? nullptr : It->getValue();
+ }
+
+ /// Associates the given real path with the filename and returns the given
+ /// entry pointer (for convenience).
+ const CachedRealPath &
+ insertRealPathForFilename(StringRef Filename,
+ const CachedRealPath &RealPath) {
----------------
jansvoboda11 wrote:
Agreed. I'll go over this file and probably turn all nullable pointers into `std::optional<const X *>` (AFAIK these are only function return types and don't get stored in long-lived data structures) and assume plain `const X *` are not null.
https://github.com/llvm/llvm-project/pull/68645
More information about the cfe-commits
mailing list