[PATCH] D79450: [VFS] Fix root directory handling in YAMLVFSWriter

Jan Korous via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 15:08:47 PDT 2020


jkorous created this revision.
jkorous added a reviewer: JDevlieghere.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.
jkorous marked 2 inline comments as done.
jkorous added inline comments.
Herald added a subscriber: ormris.


================
Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2043
+
+    auto GetParentOrIfRootDir = [](StringRef Path) -> StringRef {
+      auto MaybeResult = path::parent_path(Path);
----------------
Not happy with the name - open to suggestions.


================
Comment at: llvm/lib/Support/VirtualFileSystem.cpp:2060
+      auto NewDir = GetParentOrIfRootDir(Entry.VPath);
+      assert(!NewDir.empty() && "VPath doesn't have parent directory and is "
+                                "not a root directory either.");
----------------
Hmm, maybe I should just move the assert to GetParentOrIfRootDir so it's not duplicated.


[VFS] Fix root directory handling in YAMLVFSWriter

- refactor JSONWriter::write
- handle directories uniformly - don't skip writeEntry only for the first Entry
- handle entries without a parent directory
- assert every entry have either a parent dir or is root directory

The testcase previously vioated assert in JSONWriter::containedPart about a previous directory element path being non-empty.


https://reviews.llvm.org/D79450

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79450.262235.patch
Type: text/x-patch
Size: 5053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/0cf94daa/attachment.bin>


More information about the llvm-commits mailing list