aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-21 03:03:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-21 03:03:39 +0000
commit31b87d8006d4863dd9b17e515ac720941efc38e3 (patch)
tree42958d1643a6744e938e5708ada6b96ce4ed5945 /lib/Frontend/ASTUnit.cpp
parenta39075952caea0af902f174ce26ad5ac787b3974 (diff)
Change ASTUnit to take the Diagnostic as an argument, the client should have control of this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r--lib/Frontend/ASTUnit.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 609889aad9..1e2ad46b93 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -13,7 +13,6 @@
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/PCHReader.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/StmtVisitor.h"
@@ -25,7 +24,7 @@
using namespace clang;
-ASTUnit::ASTUnit() { }
+ASTUnit::ASTUnit(Diagnostic &_Diags) : Diags(_Diags) { }
ASTUnit::~ASTUnit() { }
namespace {
@@ -86,19 +85,12 @@ FileManager &ASTUnit::getFileManager() {
}
ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
+ Diagnostic &Diags,
FileManager &FileMgr,
std::string *ErrMsg) {
-
- llvm::OwningPtr<ASTUnit> AST(new ASTUnit());
-
- AST->DiagClient.reset(new TextDiagnosticBuffer());
- AST->Diags.reset(new Diagnostic(AST->DiagClient.get()));
+ llvm::OwningPtr<ASTUnit> AST(new ASTUnit(Diags));
AST->HeaderInfo.reset(new HeaderSearch(FileMgr));
- AST->SourceMgr.reset(new SourceManager());
-
- Diagnostic &Diags = *AST->Diags.get();
- SourceManager &SourceMgr = *AST->SourceMgr.get();
// Gather Info for preprocessor construction later on.
@@ -111,7 +103,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
llvm::OwningPtr<PCHReader> Reader;
llvm::OwningPtr<ExternalASTSource> Source;
- Reader.reset(new PCHReader(SourceMgr, FileMgr, Diags));
+ Reader.reset(new PCHReader(AST->getSourceManager(), FileMgr, AST->Diags));
Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
@@ -130,8 +122,8 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
// Get information about the target being compiled for.
AST->Target.reset(TargetInfo::CreateTargetInfo(TargetTriple));
- AST->PP.reset(new Preprocessor(Diags, LangInfo, *AST->Target.get(),
- SourceMgr, HeaderInfo));
+ AST->PP.reset(new Preprocessor(AST->Diags, LangInfo, *AST->Target.get(),
+ AST->getSourceManager(), HeaderInfo));
Preprocessor &PP = *AST->PP.get();
PP.setPredefines(Predefines);
@@ -141,7 +133,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
// Create and initialize the ASTContext.
AST->Ctx.reset(new ASTContext(LangInfo,
- SourceMgr,
+ AST->getSourceManager(),
*AST->Target.get(),
PP.getIdentifierTable(),
PP.getSelectorTable(),