r215317 - unique_ptr-ify ASTReaderListener in the ASTReader
David Blaikie
dblaikie at gmail.com
Sun Aug 10 09:54:40 PDT 2014
Author: dblaikie
Date: Sun Aug 10 11:54:39 2014
New Revision: 215317
URL: http://llvm.org/viewvc/llvm-project?rev=215317&view=rev
Log:
unique_ptr-ify ASTReaderListener in the ASTReader
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=215317&r1=215316&r2=215317&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Sun Aug 10 11:54:39 2014
@@ -202,8 +202,9 @@ class ChainedASTReaderListener : public
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.
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=215317&r1=215316&r2=215317&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Sun Aug 10 11:54:39 2014
@@ -728,10 +728,9 @@ ASTUnit *ASTUnit::LoadFromASTFile(const
/*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)) {
Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=215317&r1=215316&r2=215317&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Sun Aug 10 11:54:39 2014
@@ -124,7 +124,7 @@ void DependencyCollector::attachToPrepro
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 *DependencyFileG
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
Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=215317&r1=215316&r2=215317&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Sun Aug 10 11:54:39 2014
@@ -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() {
More information about the cfe-commits
mailing list