diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2019-08-29 11:43:05 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2019-08-29 11:43:05 +0000 |
commit | 8d32053f113348a4ea94f59b7553733aff0ba651 (patch) | |
tree | 048aca47c8535312298c8f7a2388cc091dbcc7a7 /clang/lib/Index/IndexingAction.cpp | |
parent | 9cc92c1547c4c6d85efb4c87d4850115a0d6ef6a (diff) | |
download | bcm5719-llvm-8d32053f113348a4ea94f59b7553733aff0ba651.tar.gz bcm5719-llvm-8d32053f113348a4ea94f59b7553733aff0ba651.zip |
[Index] Stopped wrapping FrontendActions in libIndex and its users
Exposed a new function, createIndexingASTConsumer, that creates an
ASTConsumer. ASTConsumers compose well.
Removed wrapping functionality from createIndexingAction.
llvm-svn: 370337
Diffstat (limited to 'clang/lib/Index/IndexingAction.cpp')
-rw-r--r-- | clang/lib/Index/IndexingAction.cpp | 62 |
1 files changed, 14 insertions, 48 deletions
diff --git a/clang/lib/Index/IndexingAction.cpp b/clang/lib/Index/IndexingAction.cpp index 8605a2cfa14..e7079720140 100644 --- a/clang/lib/Index/IndexingAction.cpp +++ b/clang/lib/Index/IndexingAction.cpp @@ -94,72 +94,38 @@ protected: } }; -class IndexActionBase { -protected: +class IndexAction final : public ASTFrontendAction { std::shared_ptr<IndexDataConsumer> DataConsumer; IndexingOptions Opts; - IndexActionBase(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts) - : DataConsumer(std::move(DataConsumer)), Opts(Opts) { - assert(this->DataConsumer != nullptr); - } - - std::unique_ptr<IndexASTConsumer> - createIndexASTConsumer(CompilerInstance &CI) { - return std::make_unique<IndexASTConsumer>(DataConsumer, Opts, - CI.getPreprocessorPtr()); - } -}; - -class IndexAction final : public ASTFrontendAction, IndexActionBase { public: IndexAction(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts) - : IndexActionBase(std::move(DataConsumer), Opts) {} - -protected: - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override { - return createIndexASTConsumer(CI); + const IndexingOptions &Opts) + : DataConsumer(std::move(DataConsumer)), Opts(Opts) { + assert(this->DataConsumer != nullptr); } -}; - -class WrappingIndexAction final : public WrapperFrontendAction, - IndexActionBase { -public: - WrappingIndexAction(std::unique_ptr<FrontendAction> WrappedAction, - std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts) - : WrapperFrontendAction(std::move(WrappedAction)), - IndexActionBase(std::move(DataConsumer), Opts) {} protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { - auto OtherConsumer = WrapperFrontendAction::CreateASTConsumer(CI, InFile); - if (!OtherConsumer) { - return nullptr; - } - - std::vector<std::unique_ptr<ASTConsumer>> Consumers; - Consumers.push_back(std::move(OtherConsumer)); - Consumers.push_back(createIndexASTConsumer(CI)); - return std::make_unique<MultiplexConsumer>(std::move(Consumers)); + return std::make_unique<IndexASTConsumer>(DataConsumer, Opts, + CI.getPreprocessorPtr()); } }; } // anonymous namespace +std::unique_ptr<ASTConsumer> +index::createIndexingASTConsumer(std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts, + std::shared_ptr<Preprocessor> PP) { + return std::make_unique<IndexASTConsumer>(DataConsumer, Opts, PP); +} + std::unique_ptr<FrontendAction> index::createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts, - std::unique_ptr<FrontendAction> WrappedAction) { + const IndexingOptions &Opts) { assert(DataConsumer != nullptr); - - if (WrappedAction) - return std::make_unique<WrappingIndexAction>(std::move(WrappedAction), - std::move(DataConsumer), Opts); return std::make_unique<IndexAction>(std::move(DataConsumer), Opts); } |