[all-commits] [llvm/llvm-project] 22555b: [VFS] InMemoryFilesystem's UniqueIDs are a functio...

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Sep 29 14:24:35 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22555bafe90dcb2e3d9d59e41e993edc0e4689fc
      https://github.com/llvm/llvm-project/commit/22555bafe90dcb2e3d9d59e41e993edc0e4689fc
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2021-09-29 (Wed, 29 Sep 2021)

  Changed paths:
    M llvm/lib/Support/VirtualFileSystem.cpp
    M llvm/unittests/Support/VirtualFileSystemTest.cpp

  Log Message:
  -----------
  [VFS] InMemoryFilesystem's UniqueIDs are a function of path and content.

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).

Differential Revision: https://reviews.llvm.org/D110711




More information about the All-commits mailing list