aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-07-15 01:24:35 +0000
committerJustin Bogner <mail@justinbogner.com>2014-07-15 01:24:35 +0000
commit73466400b2dcba1d67a2538684c55907221ade7a (patch)
treec444e8a873985b04a73dee0971a6c328548415bf /clang/lib/Basic/VirtualFileSystem.cpp
parent15fe7a530d352aecea65f952e6b321635b4fe2a8 (diff)
downloadllvm-73466400b2dcba1d67a2538684c55907221ade7a.zip
llvm-73466400b2dcba1d67a2538684c55907221ade7a.tar.gz
llvm-73466400b2dcba1d67a2538684c55907221ade7a.tar.bz2
VirtualFileSystem: Correctly generate the mapping for an empty VFS
In r209332 I accidentally broke generation of empty VFS maps. This fixes the issue and adds a test. llvm-svn: 213028
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 1f2a856..a5c83b8 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -1101,35 +1101,34 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
<< (IsCaseSensitive.getValue() ? "true" : "false") << "',\n";
OS << " 'roots': [\n";
- if (Entries.empty())
- return;
-
- const YAMLVFSEntry &Entry = Entries.front();
- startDirectory(path::parent_path(Entry.VPath));
- writeEntry(path::filename(Entry.VPath), Entry.RPath);
-
- for (const auto &Entry : Entries.slice(1)) {
- StringRef Dir = path::parent_path(Entry.VPath);
- if (Dir == DirStack.back())
- OS << ",\n";
- else {
- while (!DirStack.empty() && !containedIn(DirStack.back(), Dir)) {
- OS << "\n";
- endDirectory();
+ if (!Entries.empty()) {
+ const YAMLVFSEntry &Entry = Entries.front();
+ startDirectory(path::parent_path(Entry.VPath));
+ writeEntry(path::filename(Entry.VPath), Entry.RPath);
+
+ for (const auto &Entry : Entries.slice(1)) {
+ StringRef Dir = path::parent_path(Entry.VPath);
+ if (Dir == DirStack.back())
+ OS << ",\n";
+ else {
+ while (!DirStack.empty() && !containedIn(DirStack.back(), Dir)) {
+ OS << "\n";
+ endDirectory();
+ }
+ OS << ",\n";
+ startDirectory(Dir);
}
- OS << ",\n";
- startDirectory(Dir);
+ writeEntry(path::filename(Entry.VPath), Entry.RPath);
}
- writeEntry(path::filename(Entry.VPath), Entry.RPath);
- }
- while (!DirStack.empty()) {
+ while (!DirStack.empty()) {
+ OS << "\n";
+ endDirectory();
+ }
OS << "\n";
- endDirectory();
}
- OS << "\n"
- << " ]\n"
+ OS << " ]\n"
<< "}\n";
}