From 47bfa375afe7c0bdaf44838b8a6f0bf62ef82565 Mon Sep 17 00:00:00 2001 From: josh11b <15258583+josh11b@users.noreply.github.com> Date: Mon, 18 Nov 2024 10:24:19 -0800 Subject: [PATCH] Propagate `llvm::vfs::FileSystem` from `driver_env` to Clang (#4537) As discussed in #4530 . This required switching to using `llvm::IntrusiveRefCntPtr` in a number of places. --------- Co-authored-by: Josh L --- explorer/file_test.cpp | 10 ++++++---- testing/base/source_gen_test.cpp | 9 +++++---- testing/file_test/file_test_base.cpp | 11 ++++++----- testing/file_test/file_test_base.h | 2 +- testing/file_test/file_test_base_test.cpp | 17 +++++++++-------- toolchain/check/check_fuzzer.cpp | 5 +++-- toolchain/driver/clang_runner.cpp | 12 +++++++----- toolchain/driver/clang_runner.h | 3 +++ toolchain/driver/clang_runner_test.cpp | 9 ++++++--- toolchain/driver/clang_subcommand.cpp | 3 ++- toolchain/driver/compile_benchmark.cpp | 9 +++++---- toolchain/driver/compile_subcommand.cpp | 2 +- toolchain/driver/driver.h | 3 ++- toolchain/driver/driver_env.h | 2 +- toolchain/driver/driver_fuzzer.cpp | 3 ++- toolchain/driver/driver_test.cpp | 7 ++++--- toolchain/driver/format_subcommand.cpp | 3 ++- toolchain/driver/link_subcommand.cpp | 2 +- toolchain/install/busybox_main.cpp | 2 +- .../install/install_paths_test_helpers.cpp | 5 +++-- toolchain/install/install_paths_test_helpers.h | 5 +++-- toolchain/sem_ir/yaml_test.cpp | 5 +++-- toolchain/testing/file_test.cpp | 7 ++++--- 23 files changed, 80 insertions(+), 56 deletions(-) diff --git a/explorer/file_test.cpp b/explorer/file_test.cpp index 55270c6e743b..e7cf9cf944b0 100644 --- a/explorer/file_test.cpp +++ b/explorer/file_test.cpp @@ -28,8 +28,9 @@ class ExplorerFileTest : public FileTestBase { } auto Run(const llvm::SmallVector& test_args, - llvm::vfs::InMemoryFileSystem& fs, llvm::raw_pwrite_stream& stdout, - llvm::raw_pwrite_stream& stderr) -> ErrorOr override { + llvm::IntrusiveRefCntPtr& fs, + llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr) + -> ErrorOr override { // Add the prelude. llvm::ErrorOr> prelude = llvm::MemoryBuffer::getFile("explorer/data/prelude.carbon"); @@ -41,7 +42,8 @@ class ExplorerFileTest : public FileTestBase { // here. static constexpr llvm::StringLiteral PreludePath = "/explorer/data/prelude.carbon"; - if (!fs.addFile(PreludePath, /*ModificationTime=*/0, std::move(*prelude))) { + if (!fs->addFile(PreludePath, /*ModificationTime=*/0, + std::move(*prelude))) { return ErrorBuilder() << "Duplicate prelude.carbon"; } @@ -52,7 +54,7 @@ class ExplorerFileTest : public FileTestBase { int exit_code = ExplorerMain( args.size(), args.data(), /*install_path=*/"", PreludePath, stdout, - stderr, check_trace_output() ? stdout : trace_stream_, fs); + stderr, check_trace_output() ? stdout : trace_stream_, *fs); return {{.success = exit_code == EXIT_SUCCESS}}; } diff --git a/testing/base/source_gen_test.cpp b/testing/base/source_gen_test.cpp index 360f4d9ff039..9f428bbbd1d5 100644 --- a/testing/base/source_gen_test.cpp +++ b/testing/base/source_gen_test.cpp @@ -143,15 +143,16 @@ TEST(SourceGenTest, UniqueIdentifiers) { // Check that the source code doesn't have compiler errors. auto TestCompile(llvm::StringRef source) -> bool { - llvm::vfs::InMemoryFileSystem fs; + llvm::IntrusiveRefCntPtr fs = + new llvm::vfs::InMemoryFileSystem; InstallPaths installation( InstallPaths::MakeForBazelRunfiles(Testing::GetExePath())); Driver driver(fs, &installation, llvm::outs(), llvm::errs()); - AddPreludeFilesToVfs(installation, &fs); + AddPreludeFilesToVfs(installation, fs); - fs.addFile("test.carbon", /*ModificationTime=*/0, - llvm::MemoryBuffer::getMemBuffer(source)); + fs->addFile("test.carbon", /*ModificationTime=*/0, + llvm::MemoryBuffer::getMemBuffer(source)); return driver.RunCommand({"compile", "--phase=check", "test.carbon"}).success; } diff --git a/testing/file_test/file_test_base.cpp b/testing/file_test/file_test_base.cpp index d2a2094f7385..5bdbab4eb4f7 100644 --- a/testing/file_test/file_test_base.cpp +++ b/testing/file_test/file_test_base.cpp @@ -297,12 +297,13 @@ auto FileTestBase::ProcessTestFileAndRun(TestContext& context) DoArgReplacements(context.test_args, context.test_files)); // Create the files in-memory. - llvm::vfs::InMemoryFileSystem fs; + llvm::IntrusiveRefCntPtr fs = + new llvm::vfs::InMemoryFileSystem; for (const auto& test_file : context.test_files) { - if (!fs.addFile(test_file.filename, /*ModificationTime=*/0, - llvm::MemoryBuffer::getMemBuffer( - test_file.content, test_file.filename, - /*RequiresNullTerminator=*/false))) { + if (!fs->addFile(test_file.filename, /*ModificationTime=*/0, + llvm::MemoryBuffer::getMemBuffer( + test_file.content, test_file.filename, + /*RequiresNullTerminator=*/false))) { return ErrorBuilder() << "File is repeated: " << test_file.filename; } } diff --git a/testing/file_test/file_test_base.h b/testing/file_test/file_test_base.h index 9fa76cb60749..f13e0444f222 100644 --- a/testing/file_test/file_test_base.h +++ b/testing/file_test/file_test_base.h @@ -77,7 +77,7 @@ class FileTestBase : public testing::Test { // The return value should be an error if there was an abnormal error, and // RunResult otherwise. virtual auto Run(const llvm::SmallVector& test_args, - llvm::vfs::InMemoryFileSystem& fs, + llvm::IntrusiveRefCntPtr& fs, llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr) -> ErrorOr = 0; diff --git a/testing/file_test/file_test_base_test.cpp b/testing/file_test/file_test_base_test.cpp index d75890432673..6caa1d6cf84a 100644 --- a/testing/file_test/file_test_base_test.cpp +++ b/testing/file_test/file_test_base_test.cpp @@ -22,8 +22,9 @@ class FileTestBaseTest : public FileTestBase { : FileTestBase(output_mutex, test_name) {} auto Run(const llvm::SmallVector& test_args, - llvm::vfs::InMemoryFileSystem& fs, llvm::raw_pwrite_stream& stdout, - llvm::raw_pwrite_stream& stderr) -> ErrorOr override; + llvm::IntrusiveRefCntPtr& fs, + llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr) + -> ErrorOr override; auto GetArgReplacements() -> llvm::StringMap override { return {{"replacement", "replaced"}}; @@ -217,10 +218,10 @@ static auto EchoFileContent(TestParams& params) return {{.success = true}}; } -auto FileTestBaseTest::Run(const llvm::SmallVector& test_args, - llvm::vfs::InMemoryFileSystem& fs, - llvm::raw_pwrite_stream& stdout, - llvm::raw_pwrite_stream& stderr) +auto FileTestBaseTest::Run( + const llvm::SmallVector& test_args, + llvm::IntrusiveRefCntPtr& fs, + llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr) -> ErrorOr { PrintArgs(test_args, stdout); @@ -260,8 +261,8 @@ auto FileTestBaseTest::Run(const llvm::SmallVector& test_args, .Default(&EchoFileContent); // Call the appropriate test function for the file. - TestParams params = {.fs = fs, .stdout = stdout, .stderr = stderr}; - CARBON_ASSIGN_OR_RETURN(params.files, GetFilesFromArgs(test_args, fs)); + TestParams params = {.fs = *fs, .stdout = stdout, .stderr = stderr}; + CARBON_ASSIGN_OR_RETURN(params.files, GetFilesFromArgs(test_args, *fs)); return test_fn(params); } diff --git a/toolchain/check/check_fuzzer.cpp b/toolchain/check/check_fuzzer.cpp index 0921c901c344..fdad09d5b06f 100644 --- a/toolchain/check/check_fuzzer.cpp +++ b/toolchain/check/check_fuzzer.cpp @@ -31,9 +31,10 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, } static constexpr llvm::StringLiteral TestFileName = "test.carbon"; - llvm::vfs::InMemoryFileSystem fs; + llvm::IntrusiveRefCntPtr fs = + new llvm::vfs::InMemoryFileSystem; llvm::StringRef data_ref(reinterpret_cast(data), size); - CARBON_CHECK(fs.addFile( + CARBON_CHECK(fs->addFile( TestFileName, /*ModificationTime=*/0, llvm::MemoryBuffer::getMemBuffer(data_ref, /*BufferName=*/TestFileName, /*RequiresNullTerminator=*/false))); diff --git a/toolchain/driver/clang_runner.cpp b/toolchain/driver/clang_runner.cpp index 65eec066709e..a4f05bbc65c1 100644 --- a/toolchain/driver/clang_runner.cpp +++ b/toolchain/driver/clang_runner.cpp @@ -26,7 +26,6 @@ #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" -#include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/Host.h" // Defined in: @@ -42,9 +41,12 @@ auto clang_main(int Argc, char** Argv, const llvm::ToolContext& ToolContext) namespace Carbon { ClangRunner::ClangRunner(const InstallPaths* install_paths, - llvm::StringRef target, llvm::raw_ostream* vlog_stream) + llvm::StringRef target, + llvm::IntrusiveRefCntPtr fs, + llvm::raw_ostream* vlog_stream) : installation_(install_paths), target_(target), + fs_(std::move(fs)), vlog_stream_(vlog_stream), diagnostic_ids_(new clang::DiagnosticIDs()) {} @@ -123,10 +125,10 @@ auto ClangRunner::Run(llvm::ArrayRef args) -> bool { clang::DiagnosticsEngine diagnostics( diagnostic_ids_, diagnostic_options.get(), &diagnostic_client, /*ShouldOwnClient=*/false); - auto vfs = llvm::vfs::getRealFileSystem(); - clang::ProcessWarningOptions(diagnostics, *diagnostic_options, *vfs); + clang::ProcessWarningOptions(diagnostics, *diagnostic_options, *fs_); - clang::driver::Driver driver(clang_path, target_, diagnostics); + clang::driver::Driver driver(clang_path, target_, diagnostics, + "clang LLVM compiler", fs_); // Configure the install directory to find other tools and data files. // diff --git a/toolchain/driver/clang_runner.h b/toolchain/driver/clang_runner.h index 5be9e47bd200..43b73c71bc0a 100644 --- a/toolchain/driver/clang_runner.h +++ b/toolchain/driver/clang_runner.h @@ -9,6 +9,7 @@ #include "common/ostream.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/VirtualFileSystem.h" #include "toolchain/install/install_paths.h" namespace Carbon { @@ -42,6 +43,7 @@ class ClangRunner { // If `verbose` is passed as true, will enable verbose logging to the // `err_stream` both from the runner and Clang itself. ClangRunner(const InstallPaths* install_paths, llvm::StringRef target, + llvm::IntrusiveRefCntPtr fs, llvm::raw_ostream* vlog_stream = nullptr); // Run Clang with the provided arguments. @@ -51,6 +53,7 @@ class ClangRunner { const InstallPaths* installation_; llvm::StringRef target_; + llvm::IntrusiveRefCntPtr fs_; llvm::raw_ostream* vlog_stream_; llvm::IntrusiveRefCntPtr diagnostic_ids_; diff --git a/toolchain/driver/clang_runner_test.cpp b/toolchain/driver/clang_runner_test.cpp index 5c59fe1349e0..28c34714c09d 100644 --- a/toolchain/driver/clang_runner_test.cpp +++ b/toolchain/driver/clang_runner_test.cpp @@ -58,7 +58,8 @@ TEST(ClangRunnerTest, Version) { const auto install_paths = InstallPaths::MakeForBazelRunfiles(Testing::GetExePath()); std::string target = llvm::sys::getDefaultTargetTriple(); - ClangRunner runner(&install_paths, target, &test_os); + auto vfs = llvm::vfs::getRealFileSystem(); + ClangRunner runner(&install_paths, target, vfs, &test_os); std::string out; std::string err; @@ -129,7 +130,8 @@ TEST(ClangRunnerTest, LinkCommandEcho) { std::string verbose_out; llvm::raw_string_ostream verbose_os(verbose_out); std::string target = llvm::sys::getDefaultTargetTriple(); - ClangRunner runner(&install_paths, target, &verbose_os); + auto vfs = llvm::vfs::getRealFileSystem(); + ClangRunner runner(&install_paths, target, vfs, &verbose_os); std::string out; std::string err; EXPECT_TRUE(RunWithCapturedOutput(out, err, @@ -162,7 +164,8 @@ TEST(ClangRunnerTest, DashC) { std::string verbose_out; llvm::raw_string_ostream verbose_os(verbose_out); std::string target = llvm::sys::getDefaultTargetTriple(); - ClangRunner runner(&install_paths, target, &verbose_os); + auto vfs = llvm::vfs::getRealFileSystem(); + ClangRunner runner(&install_paths, target, vfs, &verbose_os); std::string out; std::string err; EXPECT_TRUE(RunWithCapturedOutput(out, err, diff --git a/toolchain/driver/clang_subcommand.cpp b/toolchain/driver/clang_subcommand.cpp index 7165331ca261..8b69b5708779 100644 --- a/toolchain/driver/clang_subcommand.cpp +++ b/toolchain/driver/clang_subcommand.cpp @@ -45,7 +45,8 @@ ClangSubcommand::ClangSubcommand() : DriverSubcommand(SubcommandInfo) {} // https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp auto ClangSubcommand::Run(DriverEnv& driver_env) -> DriverResult { std::string target = llvm::sys::getDefaultTargetTriple(); - ClangRunner runner(driver_env.installation, target, driver_env.vlog_stream); + ClangRunner runner(driver_env.installation, target, driver_env.fs, + driver_env.vlog_stream); // Don't run Clang when fuzzing, it is known to not be reliable under fuzzing // due to many unfixed issues. diff --git a/toolchain/driver/compile_benchmark.cpp b/toolchain/driver/compile_benchmark.cpp index 9a92bdc74dda..f31ea9c36790 100644 --- a/toolchain/driver/compile_benchmark.cpp +++ b/toolchain/driver/compile_benchmark.cpp @@ -24,7 +24,7 @@ class CompileBenchmark { CompileBenchmark() : installation_(InstallPaths::MakeForBazelRunfiles(GetExePath())), driver_(fs_, &installation_, llvm::outs(), llvm::errs()) { - AddPreludeFilesToVfs(installation_, &fs_); + AddPreludeFilesToVfs(installation_, fs_); } // Setup a set of source files in the VFS for the driver. Each string input is @@ -35,8 +35,8 @@ class CompileBenchmark { llvm::OwningArrayRef file_names(sources.size()); for (ssize_t i : llvm::seq(sources.size())) { file_names[i] = llvm::formatv("file_{0}.carbon", i).str(); - fs_.addFile(file_names[i], /*ModificationTime=*/0, - llvm::MemoryBuffer::getMemBuffer(sources[i])); + fs_->addFile(file_names[i], /*ModificationTime=*/0, + llvm::MemoryBuffer::getMemBuffer(sources[i])); } return file_names; } @@ -45,7 +45,8 @@ class CompileBenchmark { auto gen() -> SourceGen& { return gen_; } private: - llvm::vfs::InMemoryFileSystem fs_; + llvm::IntrusiveRefCntPtr fs_ = + new llvm::vfs::InMemoryFileSystem; const InstallPaths installation_; Driver driver_; diff --git a/toolchain/driver/compile_subcommand.cpp b/toolchain/driver/compile_subcommand.cpp index e0c0db8dc27c..66a2ada561d7 100644 --- a/toolchain/driver/compile_subcommand.cpp +++ b/toolchain/driver/compile_subcommand.cpp @@ -364,7 +364,7 @@ class CompilationUnit { // Loads source and lexes it. Returns true on success. auto RunLex() -> void { LogCall("SourceBuffer::MakeFromFileOrStdin", "source", [&] { - source_ = SourceBuffer::MakeFromFileOrStdin(driver_env_->fs, + source_ = SourceBuffer::MakeFromFileOrStdin(*driver_env_->fs, input_filename_, *consumer_); }); if (mem_usage_) { diff --git a/toolchain/driver/driver.h b/toolchain/driver/driver.h index 5f3c65e9e082..276cfbe1bb08 100644 --- a/toolchain/driver/driver.h +++ b/toolchain/driver/driver.h @@ -22,7 +22,8 @@ class Driver { public: // Constructs a driver with any error or informational output directed to a // specified stream. - Driver(llvm::vfs::FileSystem& fs, const InstallPaths* installation, + Driver(llvm::IntrusiveRefCntPtr fs, + const InstallPaths* installation, llvm::raw_pwrite_stream& output_stream, llvm::raw_pwrite_stream& error_stream) : driver_env_{.fs = fs, diff --git a/toolchain/driver/driver_env.h b/toolchain/driver/driver_env.h index 03a8f36a5d97..e46327ee15d0 100644 --- a/toolchain/driver/driver_env.h +++ b/toolchain/driver/driver_env.h @@ -13,7 +13,7 @@ namespace Carbon { struct DriverEnv { // The filesystem for source code. - llvm::vfs::FileSystem& fs; + llvm::IntrusiveRefCntPtr fs; // Helper to locate the toolchain installation's files. const InstallPaths* installation; diff --git a/toolchain/driver/driver_fuzzer.cpp b/toolchain/driver/driver_fuzzer.cpp index 592ff2147a46..3a1b46b53db0 100644 --- a/toolchain/driver/driver_fuzzer.cpp +++ b/toolchain/driver/driver_fuzzer.cpp @@ -78,7 +78,8 @@ extern "C" auto LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) size -= arg_length; } - llvm::vfs::InMemoryFileSystem fs; + llvm::IntrusiveRefCntPtr fs = + new llvm::vfs::InMemoryFileSystem; TestRawOstream error_stream; llvm::raw_null_ostream dest; Driver d(fs, install_paths, dest, error_stream); diff --git a/toolchain/driver/driver_test.cpp b/toolchain/driver/driver_test.cpp index a051d9ab6c1d..cb80ae14d73a 100644 --- a/toolchain/driver/driver_test.cpp +++ b/toolchain/driver/driver_test.cpp @@ -53,8 +53,8 @@ class DriverTest : public testing::Test { auto MakeTestFile(llvm::StringRef text, llvm::StringRef filename = "test_file.carbon") -> llvm::StringRef { - fs_.addFile(filename, /*ModificationTime=*/0, - llvm::MemoryBuffer::getMemBuffer(text)); + fs_->addFile(filename, /*ModificationTime=*/0, + llvm::MemoryBuffer::getMemBuffer(text)); return filename; } @@ -91,7 +91,8 @@ class DriverTest : public testing::Test { }); } - llvm::vfs::InMemoryFileSystem fs_; + llvm::IntrusiveRefCntPtr fs_ = + new llvm::vfs::InMemoryFileSystem; const InstallPaths installation_; TestRawOstream test_output_stream_; TestRawOstream test_error_stream_; diff --git a/toolchain/driver/format_subcommand.cpp b/toolchain/driver/format_subcommand.cpp index 6ec25096b95f..714c96252587 100644 --- a/toolchain/driver/format_subcommand.cpp +++ b/toolchain/driver/format_subcommand.cpp @@ -74,7 +74,8 @@ auto FormatSubcommand::Run(DriverEnv& driver_env) -> DriverResult { // TODO: Consider refactoring this for sharing with compile. // TODO: Decide what to do with `-` when there are multiple arguments. - auto source = SourceBuffer::MakeFromFileOrStdin(driver_env.fs, f, consumer); + auto source = + SourceBuffer::MakeFromFileOrStdin(*driver_env.fs, f, consumer); if (!source) { mark_per_file_error(); continue; diff --git a/toolchain/driver/link_subcommand.cpp b/toolchain/driver/link_subcommand.cpp index 043f5edc42c0..60e53f1369b2 100644 --- a/toolchain/driver/link_subcommand.cpp +++ b/toolchain/driver/link_subcommand.cpp @@ -114,7 +114,7 @@ auto LinkSubcommand::Run(DriverEnv& driver_env) -> DriverResult { options_.object_filenames.end()); ClangRunner runner(driver_env.installation, options_.codegen_options.target, - driver_env.vlog_stream); + driver_env.fs, driver_env.vlog_stream); return {.success = runner.Run(clang_args)}; } diff --git a/toolchain/install/busybox_main.cpp b/toolchain/install/busybox_main.cpp index a90a40a4fb27..3928f7bd0366 100644 --- a/toolchain/install/busybox_main.cpp +++ b/toolchain/install/busybox_main.cpp @@ -45,7 +45,7 @@ static auto Main(int argc, char** argv) -> ErrorOr { } args.append(argv + 1, argv + argc); - Driver driver(*fs, &install_paths, llvm::outs(), llvm::errs()); + Driver driver(fs, &install_paths, llvm::outs(), llvm::errs()); bool success = driver.RunCommand(args).success; return success ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/toolchain/install/install_paths_test_helpers.cpp b/toolchain/install/install_paths_test_helpers.cpp index 30a1e7506f19..ef4b968ef8ab 100644 --- a/toolchain/install/install_paths_test_helpers.cpp +++ b/toolchain/install/install_paths_test_helpers.cpp @@ -10,8 +10,9 @@ namespace Carbon::Testing { // Prepares the VFS with prelude files from the real filesystem. Primarily for // tests. -auto AddPreludeFilesToVfs(InstallPaths install_paths, - llvm::vfs::InMemoryFileSystem* vfs) -> void { +auto AddPreludeFilesToVfs( + InstallPaths install_paths, + llvm::IntrusiveRefCntPtr& vfs) -> void { // Load the prelude into the test VFS. auto real_fs = llvm::vfs::getRealFileSystem(); auto prelude = install_paths.ReadPreludeManifest(); diff --git a/toolchain/install/install_paths_test_helpers.h b/toolchain/install/install_paths_test_helpers.h index 1f45e4d9747d..8b14038ef240 100644 --- a/toolchain/install/install_paths_test_helpers.h +++ b/toolchain/install/install_paths_test_helpers.h @@ -11,8 +11,9 @@ namespace Carbon::Testing { // Prepares the VFS with prelude files from the real filesystem. -auto AddPreludeFilesToVfs(InstallPaths install_paths, - llvm::vfs::InMemoryFileSystem* vfs) -> void; +auto AddPreludeFilesToVfs( + InstallPaths install_paths, + llvm::IntrusiveRefCntPtr& vfs) -> void; } // namespace Carbon::Testing diff --git a/toolchain/sem_ir/yaml_test.cpp b/toolchain/sem_ir/yaml_test.cpp index 3d3df143d1f8..77cb606becf3 100644 --- a/toolchain/sem_ir/yaml_test.cpp +++ b/toolchain/sem_ir/yaml_test.cpp @@ -31,8 +31,9 @@ using ::testing::SizeIs; namespace Yaml = ::Carbon::Testing::Yaml; TEST(SemIRTest, YAML) { - llvm::vfs::InMemoryFileSystem fs; - CARBON_CHECK(fs.addFile( + llvm::IntrusiveRefCntPtr fs = + new llvm::vfs::InMemoryFileSystem; + CARBON_CHECK(fs->addFile( "test.carbon", /*ModificationTime=*/0, llvm::MemoryBuffer::getMemBuffer("fn F() { var x: () = (); return; }"))); const auto install_paths = diff --git a/toolchain/testing/file_test.cpp b/toolchain/testing/file_test.cpp index 5012b90b9078..1983beeaa224 100644 --- a/toolchain/testing/file_test.cpp +++ b/toolchain/testing/file_test.cpp @@ -34,11 +34,12 @@ class ToolchainFileTest : public FileTestBase { } auto Run(const llvm::SmallVector& test_args, - llvm::vfs::InMemoryFileSystem& fs, llvm::raw_pwrite_stream& stdout, - llvm::raw_pwrite_stream& stderr) -> ErrorOr override { + llvm::IntrusiveRefCntPtr& fs, + llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr) + -> ErrorOr override { CARBON_ASSIGN_OR_RETURN(auto prelude, installation_.ReadPreludeManifest()); for (const auto& file : prelude) { - CARBON_RETURN_IF_ERROR(AddFile(fs, file)); + CARBON_RETURN_IF_ERROR(AddFile(*fs, file)); } Driver driver(fs, &installation_, stdout, stderr);