Index: cfe/trunk/include/clang/Index/IndexingAction.h =================================================================== --- cfe/trunk/include/clang/Index/IndexingAction.h +++ cfe/trunk/include/clang/Index/IndexingAction.h @@ -11,11 +11,14 @@ #define LLVM_CLANG_INDEX_INDEXINGACTION_H #include "clang/Basic/LLVM.h" +#include "llvm/ADT/ArrayRef.h" #include namespace clang { + class ASTContext; class ASTReader; class ASTUnit; + class Decl; class FrontendAction; namespace serialization { @@ -47,8 +50,11 @@ std::shared_ptr DataConsumer, IndexingOptions Opts); -void indexModuleFile(serialization::ModuleFile &Mod, - ASTReader &Reader, +void indexTopLevelDecls(ASTContext &Ctx, ArrayRef Decls, + std::shared_ptr DataConsumer, + IndexingOptions Opts); + +void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, std::shared_ptr DataConsumer, IndexingOptions Opts); Index: cfe/trunk/lib/Index/IndexingAction.cpp =================================================================== --- cfe/trunk/lib/Index/IndexingAction.cpp +++ cfe/trunk/lib/Index/IndexingAction.cpp @@ -177,6 +177,18 @@ DataConsumer->finish(); } +void index::indexTopLevelDecls(ASTContext &Ctx, ArrayRef Decls, + std::shared_ptr 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 DataConsumer,