aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Interpreter/Interpreter.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-09-16 08:21:06 -0700
committerGitHub <noreply@github.com>2025-09-16 08:21:06 -0700
commit30633f30894129919050f24fdd1f8f6bc46beae0 (patch)
tree169acbfe0c6a7fdb7a3b135f16b248f3d79a6110 /clang/lib/Interpreter/Interpreter.cpp
parent9865f7ec2bb15f3d8aa25c7e9305393422597dc5 (diff)
downloadllvm-30633f30894129919050f24fdd1f8f6bc46beae0.zip
llvm-30633f30894129919050f24fdd1f8f6bc46beae0.tar.gz
llvm-30633f30894129919050f24fdd1f8f6bc46beae0.tar.bz2
[clang] Initialize the file system explicitly (#158381)
This PR is a part of the effort to make the VFS used in the compiler more explicit and consistent. Instead of creating the VFS deep within the compiler (in `CompilerInstance::createFileManager()`), clients are now required to explicitly call `CompilerInstance::createVirtualFileSystem()` and provide the base VFS from the outside. This PR also helps in breaking up the dependency cycle where creating a properly configured `DiagnosticsEngine` requires a properly configured VFS, but creating properly configuring a VFS requires the `DiagnosticsEngine`. Both `CompilerInstance::create{FileManager,Diagnostics}()` now just use the VFS already in `CompilerInstance` instead of taking one as a parameter, making the VFS consistent across the instance sub-object.
Diffstat (limited to 'clang/lib/Interpreter/Interpreter.cpp')
-rw-r--r--clang/lib/Interpreter/Interpreter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 07c170a..9cc1c45 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -107,8 +107,10 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
Clang->getHeaderSearchOpts().ResourceDir =
CompilerInvocation::GetResourcesPath(Argv[0], nullptr);
+ Clang->createVirtualFileSystem();
+
// Create the actual diagnostics engine.
- Clang->createDiagnostics(*llvm::vfs::getRealFileSystem());
+ Clang->createDiagnostics();
if (!Clang->hasDiagnostics())
return llvm::createStringError(llvm::errc::not_supported,
"Initialization failed. "
@@ -475,7 +477,8 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI,
std::make_unique<llvm::vfs::OverlayFileSystem>(
llvm::vfs::getRealFileSystem());
OverlayVFS->pushOverlay(IMVFS);
- CI->createFileManager(OverlayVFS);
+ CI->createVirtualFileSystem(OverlayVFS);
+ CI->createFileManager();
llvm::Expected<std::unique_ptr<Interpreter>> InterpOrErr =
Interpreter::create(std::move(CI));