Revert "unique_ptr-ify ownership of ASTConsumers"

This reverts commit r213308.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

llvm-svn: 213324
This commit is contained in:
David Blaikie 2014-07-17 22:33:56 +00:00
parent bbe75b99f0
commit 5bae2c87d5
7 changed files with 28 additions and 32 deletions

View File

@ -49,8 +49,7 @@ private:
FactoryAdaptor(MatchFinder &Finder, Transform &Owner) FactoryAdaptor(MatchFinder &Finder, Transform &Owner)
: Finder(Finder), Owner(Owner) {} : Finder(Finder), Owner(Owner) {}
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &, ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) {
StringRef) {
return Finder.newASTConsumer(); return Finder.newASTConsumer();
} }

View File

@ -179,10 +179,10 @@ private:
class ClangTidyASTConsumer : public MultiplexConsumer { class ClangTidyASTConsumer : public MultiplexConsumer {
public: public:
ClangTidyASTConsumer(std::vector<std::unique_ptr<ASTConsumer>> Consumers, ClangTidyASTConsumer(const SmallVectorImpl<ASTConsumer *> &Consumers,
std::unique_ptr<ast_matchers::MatchFinder> Finder, std::unique_ptr<ast_matchers::MatchFinder> Finder,
std::vector<std::unique_ptr<ClangTidyCheck>> Checks) std::vector<std::unique_ptr<ClangTidyCheck>> Checks)
: MultiplexConsumer(std::move(Consumers)), Finder(std::move(Finder)), : MultiplexConsumer(Consumers), Finder(std::move(Finder)),
Checks(std::move(Checks)) {} Checks(std::move(Checks)) {}
private: private:
@ -203,8 +203,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
} }
} }
std::unique_ptr<clang::ASTConsumer>
ClangTidyASTConsumerFactory::CreateASTConsumer( clang::ASTConsumer *ClangTidyASTConsumerFactory::CreateASTConsumer(
clang::CompilerInstance &Compiler, StringRef File) { clang::CompilerInstance &Compiler, StringRef File) {
// FIXME: Move this to a separate method, so that CreateASTConsumer doesn't // FIXME: Move this to a separate method, so that CreateASTConsumer doesn't
// modify Compiler. // modify Compiler.
@ -224,7 +224,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
Check->registerPPCallbacks(Compiler); Check->registerPPCallbacks(Compiler);
} }
std::vector<std::unique_ptr<ASTConsumer>> Consumers; SmallVector<ASTConsumer *, 2> Consumers;
if (!Checks.empty()) if (!Checks.empty())
Consumers.push_back(Finder->newASTConsumer()); Consumers.push_back(Finder->newASTConsumer());
@ -240,16 +240,15 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
AnalyzerOptions->AnalysisDiagOpt = PD_NONE; AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
AnalyzerOptions->AnalyzeNestedBlocks = true; AnalyzerOptions->AnalyzeNestedBlocks = true;
AnalyzerOptions->eagerlyAssumeBinOpBifurcation = true; AnalyzerOptions->eagerlyAssumeBinOpBifurcation = true;
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer = ento::AnalysisASTConsumer *AnalysisConsumer = ento::CreateAnalysisConsumer(
ento::CreateAnalysisConsumer( Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile,
Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile, AnalyzerOptions, Compiler.getFrontendOpts().Plugins);
AnalyzerOptions, Compiler.getFrontendOpts().Plugins);
AnalysisConsumer->AddDiagnosticConsumer( AnalysisConsumer->AddDiagnosticConsumer(
new AnalyzerDiagnosticConsumer(Context)); new AnalyzerDiagnosticConsumer(Context));
Consumers.push_back(std::move(AnalysisConsumer)); Consumers.push_back(AnalysisConsumer);
} }
return llvm::make_unique<ClangTidyASTConsumer>( return new ClangTidyASTConsumer(Consumers, std::move(Finder),
std::move(Consumers), std::move(Finder), std::move(Checks)); std::move(Checks));
} }
std::vector<std::string> std::vector<std::string>
@ -340,8 +339,8 @@ ClangTidyStats runClangTidy(ClangTidyOptionsProvider *OptionsProvider,
class Action : public ASTFrontendAction { class Action : public ASTFrontendAction {
public: public:
Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {} Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler, ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler,
StringRef File) override { StringRef File) override {
return Factory->CreateASTConsumer(Compiler, File); return Factory->CreateASTConsumer(Compiler, File);
} }

View File

@ -99,8 +99,8 @@ public:
ClangTidyASTConsumerFactory(ClangTidyContext &Context); ClangTidyASTConsumerFactory(ClangTidyContext &Context);
/// \brief Returns an ASTConsumer that runs the specified clang-tidy checks. /// \brief Returns an ASTConsumer that runs the specified clang-tidy checks.
std::unique_ptr<clang::ASTConsumer> clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &Compiler,
CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File); StringRef File);
/// \brief Get the list of enabled checks. /// \brief Get the list of enabled checks.
std::vector<std::string> getCheckNames(ChecksFilter &Filter); std::vector<std::string> getCheckNames(ChecksFilter &Filter);

View File

@ -652,10 +652,10 @@ public:
HadErrors(HadErrors) {} HadErrors(HadErrors) {}
protected: protected:
std::unique_ptr<clang::ASTConsumer> virtual clang::ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { StringRef InFile) {
return llvm::make_unique<CollectEntitiesConsumer>( return new CollectEntitiesConsumer(Entities, PPTracker,
Entities, PPTracker, CI.getPreprocessor(), InFile, HadErrors); CI.getPreprocessor(), InFile, HadErrors);
} }
private: private:

View File

@ -178,10 +178,9 @@ public:
ModuleMapCheckerAction(ModuleMapChecker &Checker) : Checker(Checker) {} ModuleMapCheckerAction(ModuleMapChecker &Checker) : Checker(Checker) {}
protected: protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override { StringRef InFile) {
return llvm::make_unique<ModuleMapCheckerConsumer>(Checker, return new ModuleMapCheckerConsumer(Checker, CI.getPreprocessor());
CI.getPreprocessor());
} }
private: private:

View File

@ -120,10 +120,9 @@ public:
: Ignore(Ignore), CallbackCalls(CallbackCalls) {} : Ignore(Ignore), CallbackCalls(CallbackCalls) {}
protected: protected:
std::unique_ptr<clang::ASTConsumer> virtual clang::ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { StringRef InFile) {
return llvm::make_unique<PPTraceConsumer>(Ignore, CallbackCalls, return new PPTraceConsumer(Ignore, CallbackCalls, CI.getPreprocessor());
CI.getPreprocessor());
} }
private: private:

View File

@ -93,8 +93,8 @@ public:
}; };
struct ConsumerFactory { struct ConsumerFactory {
std::unique_ptr<ASTConsumer> newASTConsumer() { ASTConsumer *newASTConsumer() {
return llvm::make_unique<TimePassingASTConsumer>(&Called); return new TimePassingASTConsumer(&Called);
} }
bool Called; bool Called;
}; };