diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -688,17 +688,25 @@ /// lifetime is expected to extend past that of the returned ASTUnit. /// /// \returns - The initialized ASTUnit or null if the AST failed to load. - static std::unique_ptr - LoadFromASTFile(const std::string &Filename, - const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, - IntrusiveRefCntPtr Diags, - const FileSystemOptions &FileSystemOpts, - bool UseDebugInfo = false, bool OnlyLocalDecls = false, - CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None, - bool AllowASTWithCompilerErrors = false, - bool UserFilesAreVolatile = false); + static std::unique_ptr LoadFromASTFile( + const std::string &Filename, const PCHContainerReader &PCHContainerRdr, + WhatToLoad ToLoad, IntrusiveRefCntPtr Diags, + IntrusiveRefCntPtr VFS, + const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false, + bool OnlyLocalDecls = false, + CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None, + bool AllowASTWithCompilerErrors = false, + bool UserFilesAreVolatile = false); + static std::unique_ptr LoadFromASTFile( + const std::string &Filename, const PCHContainerReader &PCHContainerRdr, + WhatToLoad ToLoad, IntrusiveRefCntPtr Diags, + const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false, + bool OnlyLocalDecls = false, + CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None, + bool AllowASTWithCompilerErrors = false, + bool UserFilesAreVolatile = false); -private: + private: /// Helper function for \c LoadFromCompilerInvocation() and /// \c LoadFromCommandLine(), which loads an AST from a compiler invocation. /// diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -757,6 +757,7 @@ std::unique_ptr ASTUnit::LoadFromASTFile( const std::string &Filename, const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, IntrusiveRefCntPtr Diags, + IntrusiveRefCntPtr VFS, const FileSystemOptions &FileSystemOpts, bool UseDebugInfo, bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile) { @@ -775,8 +776,6 @@ AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; AST->Diagnostics = Diags; - IntrusiveRefCntPtr VFS = - llvm::vfs::getRealFileSystem(); AST->FileMgr = new FileManager(FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; AST->SourceMgr = new SourceManager(AST->getDiagnostics(), @@ -867,6 +866,18 @@ return AST; } +std::unique_ptr ASTUnit::LoadFromASTFile( + const std::string &Filename, const PCHContainerReader &PCHContainerRdr, + WhatToLoad ToLoad, IntrusiveRefCntPtr Diags, + const FileSystemOptions &FileSystemOpts, bool UseDebugInfo, + bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics, + bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile) { + return LoadFromASTFile(Filename, PCHContainerRdr, ToLoad, Diags, + llvm::vfs::getRealFileSystem(), FileSystemOpts, + UseDebugInfo, OnlyLocalDecls, CaptureDiagnostics, + AllowASTWithCompilerErrors, UserFilesAreVolatile); +} + /// Add the given macro to the hash of all top-level entities. static void AddDefinedMacroToHash(const Token &MacroNameTok, unsigned &Hash) { Hash = llvm::djbHash(MacroNameTok.getIdentifierInfo()->getName(), Hash);