diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2018-08-07 19:05:41 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2018-08-07 19:05:41 +0000 |
commit | 3b2f6a4b29c92c4d4fafe4964ad164f600608f28 (patch) | |
tree | 6f8e4b0f2c233853b33e1cd00bb16d831748d708 /clang/unittests/Basic | |
parent | 98dbbfd85182ec275b102e8d283bd6e4a375bc42 (diff) | |
download | bcm5719-llvm-3b2f6a4b29c92c4d4fafe4964ad164f600608f28.tar.gz bcm5719-llvm-3b2f6a4b29c92c4d4fafe4964ad164f600608f28.zip |
[VFS] Emit an error when entry at root level uses a relative path.
Entries with only a filename prevent us from building a file system tree and
cause the assertion
> Assertion failed: (NewParentE && "Parent entry must exist"), function uniqueOverlayTree, file clang/lib/Basic/VirtualFileSystem.cpp, line 1303.
Entries with a relative path are simply not discoverable during header search.
rdar://problem/28990865
Reviewers: bruno, benlangmuir
Reviewed By: bruno
Subscribers: dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D49518
llvm-svn: 339164
Diffstat (limited to 'clang/unittests/Basic')
-rw-r--r-- | clang/unittests/Basic/VirtualFileSystemTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index a9b39b5b13f..22fbeac3c1d 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -1468,3 +1468,35 @@ TEST_F(VFSFromYAMLTest, RecursiveDirectoryIterationLevel) { } EXPECT_EQ(I, E); } + +TEST_F(VFSFromYAMLTest, RelativePaths) { + IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); + // Filename at root level without a parent directory. + IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString( + "{ 'roots': [\n" + " { 'type': 'file', 'name': 'file-not-in-directory.h',\n" + " 'external-contents': '//root/external/file'\n" + " }\n" + "] }", Lower); + EXPECT_EQ(nullptr, FS.get()); + + // Relative file path. + FS = getFromYAMLString( + "{ 'roots': [\n" + " { 'type': 'file', 'name': 'relative/file/path.h',\n" + " 'external-contents': '//root/external/file'\n" + " }\n" + "] }", Lower); + EXPECT_EQ(nullptr, FS.get()); + + // Relative directory path. + FS = getFromYAMLString( + "{ 'roots': [\n" + " { 'type': 'directory', 'name': 'relative/directory/path.h',\n" + " 'contents': []\n" + " }\n" + "] }", Lower); + EXPECT_EQ(nullptr, FS.get()); + + EXPECT_EQ(3, NumDiagnostics); +} |