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 <josh11b@users.noreply.github.com>
This commit is contained in:
josh11b
2024-11-18 18:24:19 +00:00
committed by GitHub
co-authored by Josh L
parent 825714f06b
commit 47bfa375af
23 changed files with 80 additions and 56 deletions
+7 -5
View File
@@ -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<llvm::vfs::FileSystem> 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<llvm::StringRef> 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.
//