Skip to content

Commit

Permalink
Add a parameter to LoadFromASTFile that accepts a file system and def…
Browse files Browse the repository at this point in the history
…aults to the real file-system.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D126888
  • Loading branch information
asoffer authored and ymand committed Jun 8, 2022
1 parent 51b557a commit 9d6d069
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion clang/include/clang/Frontend/ASTUnit.h
Expand Up @@ -696,7 +696,9 @@ class ASTUnit {
bool UseDebugInfo = false, bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
bool AllowASTWithCompilerErrors = false,
bool UserFilesAreVolatile = false);
bool UserFilesAreVolatile = false,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem());

private:
/// Helper function for \c LoadFromCompilerInvocation() and
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Frontend/ASTUnit.cpp
Expand Up @@ -759,7 +759,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, bool UseDebugInfo,
bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile) {
bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
std::unique_ptr<ASTUnit> AST(new ASTUnit(true));

// Recover resources if we crash before exiting this method.
Expand All @@ -775,8 +776,6 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->Diagnostics = Diags;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem();
AST->FileMgr = new FileManager(FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
Expand Down

0 comments on commit 9d6d069

Please sign in to comment.