summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2017-07-14 10:47:45 +0000
committerIlya Biryukov <ibiryukov@google.com>2017-07-14 10:47:45 +0000
commit1c7fd213d5fa86593c18a45fa00a67a53dd36b5b (patch)
tree2bdbfdae6d0a714d9ff9e26166b9e94fe20fd37c /lib
parentf0526fce681321909e4f3c1e6345fe7c184d1fb8 (diff)
[index] Added a method indexTopLevelDecls to run indexing on a list of Decls.
Summary: We need it in clangd for refactoring that replaces ASTUnit with manual AST management. Reviewers: akyrtzi, benlangmuir, arphaman, klimek Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D35405 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Index/IndexingAction.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Index/IndexingAction.cpp b/lib/Index/IndexingAction.cpp
index cac24d4b9c..84d31200ba 100644
--- a/lib/Index/IndexingAction.cpp
+++ b/lib/Index/IndexingAction.cpp
@@ -177,6 +177,18 @@ void index::indexASTUnit(ASTUnit &Unit,
DataConsumer->finish();
}
+void index::indexTopLevelDecls(ASTContext &Ctx, ArrayRef<const Decl *> Decls,
+ std::shared_ptr<IndexDataConsumer> DataConsumer,
+ IndexingOptions Opts) {
+ IndexingContext IndexCtx(Opts, *DataConsumer);
+ IndexCtx.setASTContext(Ctx);
+
+ DataConsumer->initialize(Ctx);
+ for (const Decl *D : Decls)
+ IndexCtx.indexTopLevelDecl(D);
+ DataConsumer->finish();
+}
+
void index::indexModuleFile(serialization::ModuleFile &Mod,
ASTReader &Reader,
std::shared_ptr<IndexDataConsumer> DataConsumer,