diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 00:25:12 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 00:25:12 +0000 |
commit | b59cf679e81483cbb3a9252056b7528f4c49586c (patch) | |
tree | ae28104d1debb052a27b587bf6ce5c5a9ab6d575 /clang/unittests/Basic/VirtualFileSystemTest.cpp | |
parent | cc893386bc9ffbe7d45e2a01193b0a4696fae196 (diff) | |
download | bcm5719-llvm-b59cf679e81483cbb3a9252056b7528f4c49586c.tar.gz bcm5719-llvm-b59cf679e81483cbb3a9252056b7528f4c49586c.zip |
Add a 'use-external-names' option to VFS overlay files
When true, sets the name of the file to be the name from
'external-contents'. Otherwise, you get the virtual path that the file
was looked up by. This will not affect any non-virtual paths, or fully
virtual paths (for which there is no reasonable 'external' name anyway).
The setting is available globally, but can be overriden on a per-file
basis.
The goal is that this setting will control which path you see in debug
info, diagnostics, etc. which are sensitive to which path is used. That
will come in future patches that pass the name through to FileManager.
llvm-svn: 202329
Diffstat (limited to 'clang/unittests/Basic/VirtualFileSystemTest.cpp')
-rw-r--r-- | clang/unittests/Basic/VirtualFileSystemTest.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 334b1a45ddf..367e79492a8 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -290,8 +290,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { // file ErrorOr<vfs::Status> S = O->status("/file1"); ASSERT_EQ(errc::success, S.getError()); - EXPECT_EQ("/file1", S->getName()); - EXPECT_EQ("/foo/bar/a", S->getExternalName()); + EXPECT_EQ("/foo/bar/a", S->getName()); ErrorOr<vfs::Status> SLower = O->status("/foo/bar/a"); EXPECT_EQ("/foo/bar/a", SLower->getName()); @@ -467,6 +466,57 @@ TEST_F(VFSFromYAMLTest, IllegalVFSFile) { EXPECT_EQ(24, NumDiagnostics); } +TEST_F(VFSFromYAMLTest, UseExternalName) { + IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); + Lower->addRegularFile("/external/file"); + + IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString( + "{ 'roots': [\n" + " { 'type': 'file', 'name': '/A',\n" + " 'external-contents': '/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '/B',\n" + " 'use-external-name': true,\n" + " 'external-contents': '/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '/C',\n" + " 'use-external-name': false,\n" + " 'external-contents': '/external/file'\n" + " }\n" + "] }", Lower); + ASSERT_TRUE(NULL != FS.getPtr()); + + // default true + EXPECT_EQ("/external/file", FS->status("/A")->getName()); + // explicit + EXPECT_EQ("/external/file", FS->status("/B")->getName()); + EXPECT_EQ("/C", FS->status("/C")->getName()); + + // global configuration + FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + " { 'type': 'file', 'name': '/A',\n" + " 'external-contents': '/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '/B',\n" + " 'use-external-name': true,\n" + " 'external-contents': '/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '/C',\n" + " 'use-external-name': false,\n" + " 'external-contents': '/external/file'\n" + " }\n" + "] }", Lower); + ASSERT_TRUE(NULL != FS.getPtr()); + + // default + EXPECT_EQ("/A", FS->status("/A")->getName()); + // explicit + EXPECT_EQ("/external/file", FS->status("/B")->getName()); + EXPECT_EQ("/C", FS->status("/C")->getName()); +} + TEST_F(VFSFromYAMLTest, MultiComponentPath) { IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); Lower->addRegularFile("/other"); |