r213028 - VirtualFileSystem: Correctly generate the mapping for an empty VFS
Justin Bogner
mail at justinbogner.com
Mon Jul 14 18:24:35 PDT 2014
Author: bogner
Date: Mon Jul 14 20:24:35 2014
New Revision: 213028
URL: http://llvm.org/viewvc/llvm-project?rev=213028&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/libclang/LibclangTest.cpp
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=213028&r1=213027&r2=213028&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Jul 14 20:24:35 2014
@@ -1101,35 +1101,34 @@ void JSONWriter::write(ArrayRef<YAMLVFSE
<< (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);
+ 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();
+ 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";
}
Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=213028&r1=213027&r2=213028&view=diff
==============================================================================
--- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp Mon Jul 14 20:24:35 2014
@@ -316,6 +316,16 @@ TEST(libclang, VirtualFileOverlay_TopLev
T.map("/foo.h", "/real/foo.h");
}
+TEST(libclang, VirtualFileOverlay_Empty) {
+ const char *contents =
+ "{\n"
+ " 'version': 0,\n"
+ " 'roots': [\n"
+ " ]\n"
+ "}\n";
+ TestVFO T(contents);
+}
+
TEST(libclang, ModuleMapDescriptor) {
const char *Contents =
"framework module TestFrame {\n"
More information about the cfe-commits
mailing list