[PATCH] D79553: [YAMLVFSWriter] Add explicit assert that every file has a parent dir
Jan Korous via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 22:42:17 PDT 2020
jkorous created this revision.
jkorous added a reviewer: JDevlieghere.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.
This is a leftover from me poking the code. There's an implicit assumption that every file has a parent - which if violated blows up later in implementation of `containedIn()`. I don't have any reasonable reproducer except adding root ("/") as file to the mapping but that doesn't make much sense.
Unsure if this should land, happy to hear opinions.
https://reviews.llvm.org/D79553
Files:
llvm/lib/Support/VirtualFileSystem.cpp
Index: llvm/lib/Support/VirtualFileSystem.cpp
===================================================================
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -2028,8 +2028,13 @@
if (!Entries.empty()) {
const YAMLVFSEntry &Entry = Entries.front();
bool first_entry_is_directory = Entry.IsDirectory;
- StringRef Dir =
- first_entry_is_directory ? Entry.VPath : path::parent_path(Entry.VPath);
+ StringRef Dir;
+ if (first_entry_is_directory) {
+ Dir = Entry.VPath;
+ } else {
+ Dir = path::parent_path(Entry.VPath);
+ assert(!Dir.empty() && "No parent directory");
+ }
startDirectory(Dir);
StringRef RPath = Entry.RPath;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79553.262546.patch
Type: text/x-patch
Size: 726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/6660e335/attachment.bin>
More information about the llvm-commits
mailing list