public:
/// Takes ownership of \p First and \p Second.
- ChainedASTReaderListener(ASTReaderListener *First, ASTReaderListener *Second)
- : First(First), Second(Second) { }
+ ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First,
+ std::unique_ptr<ASTReaderListener> Second)
+ : First(std::move(First)), Second(std::move(Second)) {}
bool ReadFullVersionInformation(StringRef FullVersion) override;
void ReadModuleName(StringRef ModuleName) override;
bool FromFinalization);
/// \brief Set the AST callbacks listener.
- void setListener(ASTReaderListener *listener) {
- Listener.reset(listener);
+ void setListener(std::unique_ptr<ASTReaderListener> Listener) {
+ this->Listener = std::move(Listener);
}
/// \brief Add an AST callbak listener.
///
/// Takes ownership of \p L.
- void addListener(ASTReaderListener *L) {
+ void addListener(std::unique_ptr<ASTReaderListener> L) {
if (Listener)
- L = new ChainedASTReaderListener(L, Listener.release());
- Listener.reset(L);
+ L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
+ std::move(Listener));
+ Listener = std::move(L);
}
/// \brief Set the AST deserialization listener.
/*DisableValidation=*/disableValid,
AllowPCHWithCompilerErrors);
- AST->Reader->setListener(new ASTInfoCollector(*AST->PP, Context,
- AST->ASTFileLangOpts,
- AST->TargetOpts, AST->Target,
- Counter));
+ AST->Reader->setListener(llvm::make_unique<ASTInfoCollector>(
+ *AST->PP, Context, AST->ASTFileLangOpts, AST->TargetOpts, AST->Target,
+ Counter));
switch (AST->Reader->ReadAST(Filename, serialization::MK_MainFile,
SourceLocation(), ASTReader::ARR_None)) {
PP.addPPCallbacks(new DepCollectorPPCallbacks(*this, PP.getSourceManager()));
}
void DependencyCollector::attachToASTReader(ASTReader &R) {
- R.addListener(new DepCollectorASTListener(*this));
+ R.addListener(llvm::make_unique<DepCollectorASTListener>(*this));
}
namespace {
void DependencyFileGenerator::AttachToASTReader(ASTReader &R) {
DFGImpl *I = reinterpret_cast<DFGImpl *>(Impl);
assert(I && "missing implementation");
- R.addListener(new DFGASTReaderListener(*I));
+ R.addListener(llvm::make_unique<DFGASTReaderListener>(*I));
}
/// FileMatchesDepCriteria - Determine whether the given Filename should be
}
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
- R.addListener(new ModuleDependencyListener(*this));
+ R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
}
void ModuleDependencyCollector::writeFileMap() {