[PATCH] D110711: [VFS] InMemoryFilesystem's UniqueIDs are a function of path and content.

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 29 06:26:08 PDT 2021


sammccall created this revision.
sammccall added reviewers: kadircet, kbobyrev.
Herald added subscribers: dexonsmith, hiraditya.
sammccall requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This ensures that re-creating "the same" FS results in the same UIDs for files.
In turn, this means that creating a clang module (preamble) using one in-memory
filesystem and consuming it using another doesn't create duplicate FileEntrys
for files that are the same in both FSes.

It's tempting to give the creator control over the UIDs instead. However that
requires fiddly API changes, e.g. what should the UIDs of intermediate
directories be?
This change is more "magic" but seems safe given:

- InMemoryFilesystem is used in testing more than production
- comparing UIDs across filesystems is unusual
- files with the same path and content are usually logically equivalent

(The usual reason for re-creating virtual filesystems rather than reusing them
is that typical use involves mutating their CWD and so is not threadsafe).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110711

Files:
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110711.375859.patch
Type: text/x-patch
Size: 6626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210929/51661589/attachment.bin>


More information about the llvm-commits mailing list