diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h index 0da995028d8e..0cbd955278fe 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h @@ -90,17 +90,21 @@ runCheckOnCode(StringRef Code, std::vector *Errors = nullptr, ArgCXX11.push_back(Filename.str()); ast_matchers::MatchFinder Finder; + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( - new FileManager(FileSystemOptions())); + new FileManager(FileSystemOptions(), InMemoryFileSystem)); SmallVector, 1> Checks; CheckFactory::createChecks(&Context, Checks); tooling::ToolInvocation Invocation( ArgCXX11, new TestClangTidyAction(Checks, Finder, Context), Files.get()); - Invocation.mapVirtualFile(Filename.str(), Code); + InMemoryFileSystem->addFile(Filename, 0, + llvm::MemoryBuffer::getMemBuffer(Code)); for (const auto &FileContent : PathsToContent) { - Invocation.mapVirtualFile(Twine("include/" + FileContent.first).str(), - FileContent.second); + InMemoryFileSystem->addFile( + Twine("include/") + FileContent.first, 0, + llvm::MemoryBuffer::getMemBuffer(FileContent.second)); } Invocation.setDiagnosticConsumer(&DiagConsumer); if (!Invocation.run()) {