summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-14 21:22:05 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-14 21:22:05 +0000
commit1ac5da10173fa5fe2ec4a63c761c0f1a7b6832ad (patch)
tree17fdae8928d6039a98e1d107c02e7dd4883e5358 /clang/lib/Frontend/ASTUnit.cpp
parent220f2643fa580812709f88e27b2f9d49d910cbd5 (diff)
downloadbcm5719-llvm-1ac5da10173fa5fe2ec4a63c761c0f1a7b6832ad.tar.gz
bcm5719-llvm-1ac5da10173fa5fe2ec4a63c761c0f1a7b6832ad.zip
Allow calling ASTUnit::LoadFromCompilerInvocationAction with a previously created ASTUnit.
llvm-svn: 142004
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index c2c67c12291..032adf3876a 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1511,30 +1511,33 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI,
AST->Invocation = CI;
AST->FileSystemOpts = CI->getFileSystemOpts();
AST->FileMgr = new FileManager(AST->FileSystemOpts);
- AST->SourceMgr = new SourceManager(*Diags, *AST->FileMgr);
+ AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr);
return AST.take();
}
ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- ASTFrontendAction *Action) {
+ ASTFrontendAction *Action,
+ ASTUnit *Unit) {
assert(CI && "A CompilerInvocation is required");
- // Create the AST unit.
- llvm::OwningPtr<ASTUnit> AST;
- AST.reset(new ASTUnit(false));
- ConfigureDiags(Diags, 0, 0, *AST, /*CaptureDiagnostics*/false);
- AST->Diagnostics = Diags;
+ llvm::OwningPtr<ASTUnit> OwnAST;
+ ASTUnit *AST = Unit;
+ if (!AST) {
+ // Create the AST unit.
+ OwnAST.reset(create(CI, Diags));
+ AST = OwnAST.get();
+ }
+
AST->OnlyLocalDecls = false;
AST->CaptureDiagnostics = false;
AST->TUKind = Action ? Action->getTranslationUnitKind() : TU_Complete;
AST->ShouldCacheCodeCompletionResults = false;
- AST->Invocation = CI;
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
- ASTUnitCleanup(AST.get());
+ ASTUnitCleanup(OwnAST.get());
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
DiagCleanup(Diags.getPtr());
@@ -1582,9 +1585,6 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
"IR inputs not supported here!");
// Configure the various subsystems.
- AST->FileSystemOpts = Clang->getFileSystemOpts();
- AST->FileMgr = new FileManager(AST->FileSystemOpts);
- AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr);
AST->TheSema.reset();
AST->Ctx = 0;
AST->PP = 0;
@@ -1625,7 +1625,10 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
Act->EndSourceFile();
- return AST.take();
+ if (OwnAST)
+ return OwnAST.take();
+ else
+ return AST;
}
bool ASTUnit::LoadFromCompilerInvocation(bool PrecompilePreamble) {
OpenPOWER on IntegriCloud