summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-10-06 14:45:20 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-10-06 14:45:20 +0000
commitbc632902dceaab23f9f567fa26caed3c41714b34 (patch)
treed35f14d7434dacb62ba20fbbd7a2c3ccf6f58b0e /clang/lib/Frontend/ASTUnit.cpp
parent1b8dbe3738c78240ffdbd67a556d464309b8f504 (diff)
downloadbcm5719-llvm-bc632902dceaab23f9f567fa26caed3c41714b34.tar.gz
bcm5719-llvm-bc632902dceaab23f9f567fa26caed3c41714b34.zip
[Tooling] Reuse FileManager in ASTUnit.
ASTUnit was creating multiple FileManagers and throwing them away. Reuse the one from Tooling. No functionality change now but necessary for VFSifying tooling. llvm-svn: 249410
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 90161af26ca..bac9c386a6a 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1076,11 +1076,10 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
// Configure the various subsystems.
LangOpts = Clang->getInvocation().LangOpts;
FileSystemOpts = Clang->getFileSystemOpts();
- IntrusiveRefCntPtr<vfs::FileSystem> VFS =
- createVFSFromCompilerInvocation(Clang->getInvocation(), getDiagnostics());
- if (!VFS)
- return true;
- FileMgr = new FileManager(FileSystemOpts, VFS);
+ if (!FileMgr) {
+ Clang->createFileManager();
+ FileMgr = &Clang->getFileManager();
+ }
SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
UserFilesAreVolatile);
TheSema.reset();
@@ -1892,8 +1891,8 @@ bool ASTUnit::LoadFromCompilerInvocation(
std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
CompilerInvocation *CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool OnlyLocalDecls,
- bool CaptureDiagnostics, bool PrecompilePreamble,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
+ bool OnlyLocalDecls, bool CaptureDiagnostics, bool PrecompilePreamble,
TranslationUnitKind TUKind, bool CacheCodeCompletionResults,
bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile) {
// Create the AST unit.
@@ -1907,12 +1906,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
AST->IncludeBriefCommentsInCodeCompletion
= IncludeBriefCommentsInCodeCompletion;
AST->Invocation = CI;
- AST->FileSystemOpts = CI->getFileSystemOpts();
- IntrusiveRefCntPtr<vfs::FileSystem> VFS =
- createVFSFromCompilerInvocation(*CI, *Diags);
- if (!VFS)
- return nullptr;
- AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
+ AST->FileSystemOpts = FileMgr->getFileSystemOpts();
+ AST->FileMgr = FileMgr;
AST->UserFilesAreVolatile = UserFilesAreVolatile;
// Recover resources if we crash before exiting this method.
@@ -2043,6 +2038,7 @@ bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation);
// Clear out the diagnostics state.
+ FileMgr.reset();
getDiagnostics().Reset();
ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
if (OverrideMainBuffer)
OpenPOWER on IntegriCloud