[all-commits] [llvm/llvm-project] 3ef33e: [VirtualFileSystem] Support directory entries in t...

Jonas Devlieghere via All-commits all-commits at lists.llvm.org
Fri Mar 27 15:16:57 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3ef33e69de085cb6bc028b4fc4dd39087631ac12
      https://github.com/llvm/llvm-project/commit/3ef33e69de085cb6bc028b4fc4dd39087631ac12
  Author: Jonas Devlieghere <jonas at devlieghere.com>
  Date:   2020-03-27 (Fri, 27 Mar 2020)

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

  Log Message:
  -----------
  [VirtualFileSystem] Support directory entries in the YAMLVFSWriter

The current implementation of the JSONWriter does not support writing
out directory entries. Earlier today I added a unit test to illustrate
the problem. When an entry is added to the YAMLVFSWriter and the path is
a directory, it will incorrectly emit the directory as a file, and any
files inside that directory will not be found by the VFS.

It's possible to partially work around the issue by only adding "leaf
nodes" (files) to the YAMLVFSWriter. However, this doesn't work for
representing empty directories. This is a problem for clients of the VFS
that want to iterate over a directory. The directory not being there is
not the same as the directory being empty.

This is not just a hypothetical problem. The FileCollector for example
does not differentiate between file and directory paths. I temporarily
worked around the issue for LLDB by ignoring directories, but I suspect
this will prove problematic sooner rather than later.

This patch fixes the issue by extending the JSONWriter to support
writing out directory entries. We store whether an entry should be
emitted as a file or directory.

Differential revision: https://reviews.llvm.org/D76670




More information about the All-commits mailing list