19 using namespace clang;
22 void IndexDataConsumer::_anchor() {}
46 std::shared_ptr<Preprocessor> PP;
50 IndexASTConsumer(std::shared_ptr<Preprocessor> PP,
IndexingContext &IndexCtx)
51 : PP(std::move(PP)), IndexCtx(IndexCtx) {}
54 void Initialize(
ASTContext &Context)
override {
68 void HandleTopLevelDeclInObjCContainer(
DeclGroupRef DG)
override {
72 void HandleTranslationUnit(
ASTContext &Ctx)
override {
76 class IndexActionBase {
78 std::shared_ptr<IndexDataConsumer> DataConsumer;
81 IndexActionBase(std::shared_ptr<IndexDataConsumer> dataConsumer,
83 : DataConsumer(std::move(dataConsumer)),
84 IndexCtx(Opts, *DataConsumer) {}
86 std::unique_ptr<IndexASTConsumer>
93 DataConsumer->finish();
99 IndexAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
101 : IndexActionBase(std::move(DataConsumer), Opts) {}
105 StringRef InFile)
override {
106 return createIndexASTConsumer(CI);
109 void EndSourceFileAction()
override {
116 bool IndexActionFailed =
false;
119 WrappingIndexAction(std::unique_ptr<FrontendAction> WrappedAction,
120 std::shared_ptr<IndexDataConsumer> DataConsumer,
123 IndexActionBase(std::move(DataConsumer), Opts) {}
127 StringRef InFile)
override;
128 void EndSourceFileAction()
override;
133 void WrappingIndexAction::EndSourceFileAction() {
136 if (!IndexActionFailed)
140 std::unique_ptr<ASTConsumer>
141 WrappingIndexAction::CreateASTConsumer(
CompilerInstance &CI, StringRef InFile) {
143 if (!OtherConsumer) {
144 IndexActionFailed =
true;
148 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
149 Consumers.push_back(std::move(OtherConsumer));
150 Consumers.push_back(createIndexASTConsumer(CI));
151 return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
154 std::unique_ptr<FrontendAction>
157 std::unique_ptr<FrontendAction> WrappedAction) {
159 return llvm::make_unique<WrappingIndexAction>(std::move(WrappedAction),
160 std::move(DataConsumer),
162 return llvm::make_unique<IndexAction>(std::move(DataConsumer), Opts);
176 std::shared_ptr<IndexDataConsumer> DataConsumer,
183 DataConsumer->finish();
187 std::shared_ptr<IndexDataConsumer> DataConsumer,
192 DataConsumer->initialize(Ctx);
193 for (
const Decl *D : Decls)
195 DataConsumer->finish();
200 std::shared_ptr<IndexDataConsumer> DataConsumer,
205 DataConsumer->initialize(Ctx);
210 DataConsumer->finish();
virtual void setPreprocessor(std::shared_ptr< Preprocessor > PP)
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations, FileID FID, unsigned Offset, ASTNodeInfo ASTNode)
Decl - This represents one declaration (or definition), e.g.
bool indexTopLevelDecl(const Decl *D)
void setASTContext(ASTContext &ctx)
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Utility class for loading a ASTContext from an AST file.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
std::shared_ptr< Preprocessor > getPreprocessorPtr()
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Defines the clang::Preprocessor interface.
virtual bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles, FileID FID, unsigned Offset)
bool indexDeclGroupRef(DeclGroupRef DG)
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
Information about a module that has been loaded by the ASTReader.
void indexTopLevelDecls(ASTContext &Ctx, ArrayRef< const Decl *> Decls, std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts)
void EndSourceFileAction() override
Callback at the end of processing a single input.
virtual void initialize(ASTContext &Ctx)
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Abstract base class to use for AST consumer-based frontend actions.
bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn)
Iterate over local declarations (locally parsed if this is a parsed source file or the loaded declara...
Describes a module import declaration, which makes the contents of the named module visible in the cu...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
Reads an AST files chain containing the contents of a translation unit.
A frontend action which simply wraps some other runtime-specified frontend action.
Encapsulates the data about a macro definition (e.g.
void indexASTUnit(ASTUnit &Unit, std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts)
std::shared_ptr< Preprocessor > getPreprocessorPtr() const
const ASTContext & getASTContext() const
IndexDataConsumer & getDataConsumer()
static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IndexCtx)
virtual bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI, SymbolRoleSet Roles, FileID FID, unsigned Offset)
std::unique_ptr< FrontendAction > createIndexingAction(std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts, std::unique_ptr< FrontendAction > WrappedAction)
static bool topLevelDeclVisitor(void *context, const Decl *D)
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts)