summaryrefslogtreecommitdiffstats
path: root/unittests/libclang
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-05-20 22:12:58 +0000
committerJustin Bogner <mail@justinbogner.com>2014-05-20 22:12:58 +0000
commitf1b460f9ea35039296905b25cd6871f99b05652a (patch)
treec164381001507542f8e1f2a0022330e48774e7f9 /unittests/libclang
parent3d9f4d1ad48291c1d983e7b6deff4f5d38dca76d (diff)
VirtualFileSystem: Fix false positives in YAMLVFSWriter::containedIn
Checking if a path starts with another path isn't sufficient for determining if one is contained within the heirarchy of the other. We need to ensure that the substring ends at a directory boundary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/libclang')
-rw-r--r--unittests/libclang/LibclangTest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/unittests/libclang/LibclangTest.cpp b/unittests/libclang/LibclangTest.cpp
index 50d4c489f2..61578a4801 100644
--- a/unittests/libclang/LibclangTest.cpp
+++ b/unittests/libclang/LibclangTest.cpp
@@ -184,6 +184,57 @@ TEST(libclang, VirtualFileOverlay) {
T.map("/path/virtual/foo.h", "/real/foo.h");
clang_VirtualFileOverlay_setCaseSensitivity(T.VFO, false);
}
+ {
+ const char *contents =
+ "{\n"
+ " 'version': 0,\n"
+ " 'roots': [\n"
+ " {\n"
+ " 'type': 'directory',\n"
+ " 'name': \"/path/foo\",\n"
+ " 'contents': [\n"
+ " {\n"
+ " 'type': 'file',\n"
+ " 'name': \"bar\",\n"
+ " 'external-contents': \"/real/bar\"\n"
+ " },\n"
+ " {\n"
+ " 'type': 'file',\n"
+ " 'name': \"bar.h\",\n"
+ " 'external-contents': \"/real/bar.h\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " 'type': 'directory',\n"
+ " 'name': \"/path/foobar\",\n"
+ " 'contents': [\n"
+ " {\n"
+ " 'type': 'file',\n"
+ " 'name': \"baz.h\",\n"
+ " 'external-contents': \"/real/baz.h\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " 'type': 'directory',\n"
+ " 'name': \"/path\",\n"
+ " 'contents': [\n"
+ " {\n"
+ " 'type': 'file',\n"
+ " 'name': \"foobarbaz.h\",\n"
+ " 'external-contents': \"/real/foobarbaz.h\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+ TestVFO T(contents);
+ T.map("/path/foo/bar.h", "/real/bar.h");
+ T.map("/path/foo/bar", "/real/bar");
+ T.map("/path/foobar/baz.h", "/real/baz.h");
+ T.map("/path/foobarbaz.h", "/real/foobarbaz.h");
+ }
}
TEST(libclang, ModuleMapDescriptor) {