[clang] [clang][deps] Cache `VFS::getRealPath()` (PR #68645)
Ben Langmuir via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 26 09:36:16 PDT 2023
================
@@ -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) {
----------------
benlangmuir wrote:
Since you are storing a pointer to this not the value I would suggest this take a pointer parameter. Otherwise it's easy to assume it's being copied and would be safe to pass a stack variable.
https://github.com/llvm/llvm-project/pull/68645
More information about the cfe-commits
mailing list