[clang] 9d6d069 - Add a parameter to LoadFromASTFile that accepts a file system and defaults to the real file-system.

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 8 08:38:21 PDT 2022


Author: Andy Soffer
Date: 2022-06-08T15:37:52Z
New Revision: 9d6d069f4e9a6dd6882aaf896f73f234b3dd7194

URL: https://github.com/llvm/llvm-project/commit/9d6d069f4e9a6dd6882aaf896f73f234b3dd7194
DIFF: https://github.com/llvm/llvm-project/commit/9d6d069f4e9a6dd6882aaf896f73f234b3dd7194.diff

LOG: Add a parameter to LoadFromASTFile that accepts a file system and defaults to the real file-system.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D126888

Added: 
    

Modified: 
    clang/include/clang/Frontend/ASTUnit.h
    clang/lib/Frontend/ASTUnit.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 6cf9f3ff936f..420246278b47 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -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

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 1cf20a0b662a..91dde2d86d46 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -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.
@@ -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(),


        


More information about the cfe-commits mailing list