diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-09 09:54:37 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-09 09:54:37 +0000 |
| commit | c4cb3b10dc8c50e46c9fb1b7ae95e3c3c94975d3 (patch) | |
| tree | 3febe905288d9b7ced868f291c211201a54d72a2 /clang/unittests/Tooling | |
| parent | 859b2ac07d0ce71e3c6ecae6a9e21d87f58d55b8 (diff) | |
| download | bcm5719-llvm-c4cb3b10dc8c50e46c9fb1b7ae95e3c3c94975d3.tar.gz bcm5719-llvm-c4cb3b10dc8c50e46c9fb1b7ae95e3c3c94975d3.zip | |
[VFS] Port tooling to use the in-memory file system.
This means file remappings can now be managed by ClangTool (or a
ToolInvocation user) instead of by ToolInvocation itself. The
ToolInvocation remapping is still in place so users can migrate.
Differential Revision: http://reviews.llvm.org/D13474
llvm-svn: 249815
Diffstat (limited to 'clang/unittests/Tooling')
| -rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index e479af828af..b9f6df487f6 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -149,8 +149,13 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) { } TEST(ToolInvocation, TestMapVirtualFile) { - IntrusiveRefCntPtr<clang::FileManager> Files( - new clang::FileManager(clang::FileSystemOptions())); + llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem( + new vfs::OverlayFileSystem(vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( + new vfs::InMemoryFileSystem); + OverlayFileSystem->pushOverlay(InMemoryFileSystem); + llvm::IntrusiveRefCntPtr<FileManager> Files( + new FileManager(FileSystemOptions(), OverlayFileSystem)); std::vector<std::string> Args; Args.push_back("tool-executable"); Args.push_back("-Idef"); @@ -158,8 +163,10 @@ TEST(ToolInvocation, TestMapVirtualFile) { Args.push_back("test.cpp"); clang::tooling::ToolInvocation Invocation(Args, new SyntaxOnlyAction, Files.get()); - Invocation.mapVirtualFile("test.cpp", "#include <abc>\n"); - Invocation.mapVirtualFile("def/abc", "\n"); + InMemoryFileSystem->addFile( + "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include <abc>\n")); + InMemoryFileSystem->addFile("def/abc", 0, + llvm::MemoryBuffer::getMemBuffer("\n")); EXPECT_TRUE(Invocation.run()); } @@ -168,8 +175,13 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) { // mapped module.map is found on the include path. In the future, expand this // test to run a full modules enabled compilation, so we make sure we can // rerun modules compilations with a virtual file system. - IntrusiveRefCntPtr<clang::FileManager> Files( - new clang::FileManager(clang::FileSystemOptions())); + llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem( + new vfs::OverlayFileSystem(vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( + new vfs::InMemoryFileSystem); + OverlayFileSystem->pushOverlay(InMemoryFileSystem); + llvm::IntrusiveRefCntPtr<FileManager> Files( + new FileManager(FileSystemOptions(), OverlayFileSystem)); std::vector<std::string> Args; Args.push_back("tool-executable"); Args.push_back("-Idef"); @@ -177,11 +189,14 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) { Args.push_back("test.cpp"); clang::tooling::ToolInvocation Invocation(Args, new SyntaxOnlyAction, Files.get()); - Invocation.mapVirtualFile("test.cpp", "#include <abc>\n"); - Invocation.mapVirtualFile("def/abc", "\n"); + InMemoryFileSystem->addFile( + "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include <abc>\n")); + InMemoryFileSystem->addFile("def/abc", 0, + llvm::MemoryBuffer::getMemBuffer("\n")); // Add a module.map file in the include directory of our header, so we trigger // the module.map header search logic. - Invocation.mapVirtualFile("def/module.map", "\n"); + InMemoryFileSystem->addFile("def/module.map", 0, + llvm::MemoryBuffer::getMemBuffer("\n")); EXPECT_TRUE(Invocation.run()); } |

