forked from OSchip/llvm-project
unique_ptr-ify ASTReaderListener in the ASTReader
llvm-svn: 215317
This commit is contained in:
parent
1990aa3a9b
commit
2721c32e47
|
@ -202,8 +202,9 @@ class ChainedASTReaderListener : public ASTReaderListener {
|
|||
|
||||
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;
|
||||
|
@ -1371,17 +1372,18 @@ public:
|
|||
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.
|
||||
|
|
|
@ -728,10 +728,9 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
|
|||
/*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)) {
|
||||
|
|
|
@ -124,7 +124,7 @@ void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
|
|||
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 {
|
||||
|
@ -210,7 +210,7 @@ DependencyFileGenerator *DependencyFileGenerator::CreateAndAttachToPreprocessor(
|
|||
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
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
|
||||
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
|
||||
R.addListener(new ModuleDependencyListener(*this));
|
||||
R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
|
||||
}
|
||||
|
||||
void ModuleDependencyCollector::writeFileMap() {
|
||||
|
|
Loading…
Reference in New Issue