forked from OSchip/llvm-project
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:
parent
bbe75b99f0
commit
5bae2c87d5
|
@ -49,8 +49,7 @@ private:
|
|||
FactoryAdaptor(MatchFinder &Finder, Transform &Owner)
|
||||
: Finder(Finder), Owner(Owner) {}
|
||||
|
||||
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &,
|
||||
StringRef) {
|
||||
ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) {
|
||||
return Finder.newASTConsumer();
|
||||
}
|
||||
|
||||
|
|
|
@ -179,10 +179,10 @@ private:
|
|||
|
||||
class ClangTidyASTConsumer : public MultiplexConsumer {
|
||||
public:
|
||||
ClangTidyASTConsumer(std::vector<std::unique_ptr<ASTConsumer>> Consumers,
|
||||
ClangTidyASTConsumer(const SmallVectorImpl<ASTConsumer *> &Consumers,
|
||||
std::unique_ptr<ast_matchers::MatchFinder> Finder,
|
||||
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)) {}
|
||||
|
||||
private:
|
||||
|
@ -203,8 +203,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<clang::ASTConsumer>
|
||||
ClangTidyASTConsumerFactory::CreateASTConsumer(
|
||||
|
||||
clang::ASTConsumer *ClangTidyASTConsumerFactory::CreateASTConsumer(
|
||||
clang::CompilerInstance &Compiler, StringRef File) {
|
||||
// FIXME: Move this to a separate method, so that CreateASTConsumer doesn't
|
||||
// modify Compiler.
|
||||
|
@ -224,7 +224,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
|
|||
Check->registerPPCallbacks(Compiler);
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
|
||||
SmallVector<ASTConsumer *, 2> Consumers;
|
||||
if (!Checks.empty())
|
||||
Consumers.push_back(Finder->newASTConsumer());
|
||||
|
||||
|
@ -240,16 +240,15 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
|
|||
AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
|
||||
AnalyzerOptions->AnalyzeNestedBlocks = true;
|
||||
AnalyzerOptions->eagerlyAssumeBinOpBifurcation = true;
|
||||
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
|
||||
ento::CreateAnalysisConsumer(
|
||||
Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile,
|
||||
AnalyzerOptions, Compiler.getFrontendOpts().Plugins);
|
||||
ento::AnalysisASTConsumer *AnalysisConsumer = ento::CreateAnalysisConsumer(
|
||||
Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile,
|
||||
AnalyzerOptions, Compiler.getFrontendOpts().Plugins);
|
||||
AnalysisConsumer->AddDiagnosticConsumer(
|
||||
new AnalyzerDiagnosticConsumer(Context));
|
||||
Consumers.push_back(std::move(AnalysisConsumer));
|
||||
Consumers.push_back(AnalysisConsumer);
|
||||
}
|
||||
return llvm::make_unique<ClangTidyASTConsumer>(
|
||||
std::move(Consumers), std::move(Finder), std::move(Checks));
|
||||
return new ClangTidyASTConsumer(Consumers, std::move(Finder),
|
||||
std::move(Checks));
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
|
@ -340,8 +339,8 @@ ClangTidyStats runClangTidy(ClangTidyOptionsProvider *OptionsProvider,
|
|||
class Action : public ASTFrontendAction {
|
||||
public:
|
||||
Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
|
||||
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
|
||||
StringRef File) override {
|
||||
ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler,
|
||||
StringRef File) override {
|
||||
return Factory->CreateASTConsumer(Compiler, File);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ public:
|
|||
ClangTidyASTConsumerFactory(ClangTidyContext &Context);
|
||||
|
||||
/// \brief Returns an ASTConsumer that runs the specified clang-tidy checks.
|
||||
std::unique_ptr<clang::ASTConsumer>
|
||||
CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
|
||||
clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &Compiler,
|
||||
StringRef File);
|
||||
|
||||
/// \brief Get the list of enabled checks.
|
||||
std::vector<std::string> getCheckNames(ChecksFilter &Filter);
|
||||
|
|
|
@ -652,10 +652,10 @@ public:
|
|||
HadErrors(HadErrors) {}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<clang::ASTConsumer>
|
||||
CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
|
||||
return llvm::make_unique<CollectEntitiesConsumer>(
|
||||
Entities, PPTracker, CI.getPreprocessor(), InFile, HadErrors);
|
||||
virtual clang::ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
||||
StringRef InFile) {
|
||||
return new CollectEntitiesConsumer(Entities, PPTracker,
|
||||
CI.getPreprocessor(), InFile, HadErrors);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -178,10 +178,9 @@ public:
|
|||
ModuleMapCheckerAction(ModuleMapChecker &Checker) : Checker(Checker) {}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
|
||||
StringRef InFile) override {
|
||||
return llvm::make_unique<ModuleMapCheckerConsumer>(Checker,
|
||||
CI.getPreprocessor());
|
||||
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
||||
StringRef InFile) {
|
||||
return new ModuleMapCheckerConsumer(Checker, CI.getPreprocessor());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -120,10 +120,9 @@ public:
|
|||
: Ignore(Ignore), CallbackCalls(CallbackCalls) {}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<clang::ASTConsumer>
|
||||
CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
|
||||
return llvm::make_unique<PPTraceConsumer>(Ignore, CallbackCalls,
|
||||
CI.getPreprocessor());
|
||||
virtual clang::ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
||||
StringRef InFile) {
|
||||
return new PPTraceConsumer(Ignore, CallbackCalls, CI.getPreprocessor());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -93,8 +93,8 @@ public:
|
|||
};
|
||||
|
||||
struct ConsumerFactory {
|
||||
std::unique_ptr<ASTConsumer> newASTConsumer() {
|
||||
return llvm::make_unique<TimePassingASTConsumer>(&Called);
|
||||
ASTConsumer *newASTConsumer() {
|
||||
return new TimePassingASTConsumer(&Called);
|
||||
}
|
||||
bool Called;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue