aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-12-03 01:45:44 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-12-03 01:45:44 +0000
commit5262fda30b876c8aae95f2eb92e349418d6b14bb (patch)
tree258af401a1fdf30edb4079efece5a40e0ed3551d /lib/Frontend/ASTUnit.cpp
parent7d9bd4257f817494b2fa5b310df05807050a9c18 (diff)
Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r--lib/Frontend/ASTUnit.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index a3db339b83..2afbcd133e 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -34,18 +34,12 @@
#include "llvm/System/Path.h"
using namespace clang;
-ASTUnit::ASTUnit(bool _MainFileIsAST,
- DiagnosticClient *diagClient)
- : tempFile(false), MainFileIsAST(_MainFileIsAST)
-{
- Diags.setClient(diagClient ? diagClient : new TextDiagnosticBuffer());
+ASTUnit::ASTUnit(bool _MainFileIsAST)
+ : tempFile(false), MainFileIsAST(_MainFileIsAST) {
}
ASTUnit::~ASTUnit() {
if (tempFile)
llvm::sys::Path(getPCHFileName()).eraseFromDisk();
-
- // The ASTUnit object owns the DiagnosticClient.
- delete Diags.getClient();
}
namespace {
@@ -107,11 +101,10 @@ const std::string &ASTUnit::getPCHFileName() {
}
ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
- std::string *ErrMsg,
- DiagnosticClient *diagClient,
+ Diagnostic &Diags,
bool OnlyLocalDecls,
bool UseBumpAllocator) {
- llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true, diagClient));
+ llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true));
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->HeaderInfo.reset(new HeaderSearch(AST->getFileManager()));
@@ -127,7 +120,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
llvm::OwningPtr<ExternalASTSource> Source;
Reader.reset(new PCHReader(AST->getSourceManager(), AST->getFileManager(),
- AST->Diags));
+ Diags));
Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
@@ -137,8 +130,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
case PCHReader::Failure:
case PCHReader::IgnorePCH:
- if (ErrMsg)
- *ErrMsg = "Could not load PCH file";
+ Diags.Report(diag::err_fe_unable_to_load_pch);
return NULL;
}
@@ -154,8 +146,8 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
TargetOpts.CPU = "";
TargetOpts.Features.clear();
TargetOpts.Triple = TargetTriple;
- AST->Target.reset(TargetInfo::CreateTargetInfo(AST->Diags, TargetOpts));
- AST->PP.reset(new Preprocessor(AST->Diags, LangInfo, *AST->Target.get(),
+ AST->Target.reset(TargetInfo::CreateTargetInfo(Diags, TargetOpts));
+ AST->PP.reset(new Preprocessor(Diags, LangInfo, *AST->Target.get(),
AST->getSourceManager(), HeaderInfo));
Preprocessor &PP = *AST->PP.get();
@@ -231,8 +223,6 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(const CompilerInvocation &CI,
"FIXME: AST inputs not yet supported here!");
// Create the AST unit.
- //
- // FIXME: Use the provided diagnostic client.
AST.reset(new ASTUnit(false));
AST->OnlyLocalDecls = OnlyLocalDecls;