summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/IndexingAction.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2019-08-29 11:47:34 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2019-08-29 11:47:34 +0000
commit349ef2f2f9c2d3f0e363379868d3e8a75b19291b (patch)
tree8f91553f138f5a7f8c73e03fb17a3886aa427d38 /clang/lib/Index/IndexingAction.cpp
parent8d32053f113348a4ea94f59b7553733aff0ba651 (diff)
downloadbcm5719-llvm-349ef2f2f9c2d3f0e363379868d3e8a75b19291b.tar.gz
bcm5719-llvm-349ef2f2f9c2d3f0e363379868d3e8a75b19291b.zip
[Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored clients to use it instead of inventing their own solution
Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66879 llvm-svn: 370338
Diffstat (limited to 'clang/lib/Index/IndexingAction.cpp')
-rw-r--r--clang/lib/Index/IndexingAction.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Index/IndexingAction.cpp b/clang/lib/Index/IndexingAction.cpp
index e7079720140..6d6133e89d8 100644
--- a/clang/lib/Index/IndexingAction.cpp
+++ b/clang/lib/Index/IndexingAction.cpp
@@ -57,14 +57,17 @@ class IndexASTConsumer final : public ASTConsumer {
std::shared_ptr<IndexDataConsumer> DataConsumer;
std::shared_ptr<IndexingContext> IndexCtx;
std::shared_ptr<Preprocessor> PP;
+ std::function<bool(const Decl *)> ShouldSkipFunctionBody;
public:
IndexASTConsumer(std::shared_ptr<IndexDataConsumer> DataConsumer,
const IndexingOptions &Opts,
- std::shared_ptr<Preprocessor> PP)
+ std::shared_ptr<Preprocessor> PP,
+ std::function<bool(const Decl *)> ShouldSkipFunctionBody)
: DataConsumer(std::move(DataConsumer)),
IndexCtx(new IndexingContext(Opts, *this->DataConsumer)),
- PP(std::move(PP)) {
+ PP(std::move(PP)),
+ ShouldSkipFunctionBody(std::move(ShouldSkipFunctionBody)) {
assert(this->DataConsumer != nullptr);
assert(this->PP != nullptr);
}
@@ -92,6 +95,10 @@ protected:
void HandleTranslationUnit(ASTContext &Ctx) override {
DataConsumer->finish();
}
+
+ bool shouldSkipFunctionBody(Decl *D) override {
+ return ShouldSkipFunctionBody(D);
+ }
};
class IndexAction final : public ASTFrontendAction {
@@ -108,18 +115,20 @@ public:
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override {
- return std::make_unique<IndexASTConsumer>(DataConsumer, Opts,
- CI.getPreprocessorPtr());
+ return std::make_unique<IndexASTConsumer>(
+ DataConsumer, Opts, CI.getPreprocessorPtr(),
+ /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; });
}
};
} // 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<ASTConsumer> index::createIndexingASTConsumer(
+ std::shared_ptr<IndexDataConsumer> DataConsumer,
+ const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP,
+ std::function<bool(const Decl *)> ShouldSkipFunctionBody) {
+ return std::make_unique<IndexASTConsumer>(DataConsumer, Opts, PP,
+ ShouldSkipFunctionBody);
}
std::unique_ptr<FrontendAction>
OpenPOWER on IntegriCloud