summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/IndexingAction.cpp
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
commit00f5f29535963766d558ce0a62e518829cd04abc (patch)
treefc0fe3a93dbb9390d2064ba6eb3ddadb5f4e26dc /clang/lib/Index/IndexingAction.cpp
parent8b4fcb719777d9d1411d9af791baa0ef9c6f3bfc (diff)
downloadbcm5719-llvm-00f5f29535963766d558ce0a62e518829cd04abc.tar.gz
bcm5719-llvm-00f5f29535963766d558ce0a62e518829cd04abc.zip
[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 llvm-svn: 308016
Diffstat (limited to 'clang/lib/Index/IndexingAction.cpp')
-rw-r--r--clang/lib/Index/IndexingAction.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Index/IndexingAction.cpp b/clang/lib/Index/IndexingAction.cpp
index cac24d4b9c4..84d31200bab 100644
--- a/clang/lib/Index/IndexingAction.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud