10b57cec5SDimitry Andric //===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H 100b57cec5SDimitry Andric #define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "clang/Basic/IdentifierTable.h" 130b57cec5SDimitry Andric #include "clang/Basic/LLVM.h" 140b57cec5SDimitry Andric #include "clang/Index/IndexSymbol.h" 150b57cec5SDimitry Andric #include "clang/Index/IndexingAction.h" 160b57cec5SDimitry Andric #include "clang/Lex/MacroInfo.h" 170b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace clang { 200b57cec5SDimitry Andric class ASTContext; 210b57cec5SDimitry Andric class Decl; 220b57cec5SDimitry Andric class DeclGroupRef; 230b57cec5SDimitry Andric class ImportDecl; 240b57cec5SDimitry Andric class TagDecl; 250b57cec5SDimitry Andric class TypeSourceInfo; 260b57cec5SDimitry Andric class NamedDecl; 270b57cec5SDimitry Andric class ObjCMethodDecl; 280b57cec5SDimitry Andric class DeclContext; 290b57cec5SDimitry Andric class NestedNameSpecifierLoc; 300b57cec5SDimitry Andric class Stmt; 310b57cec5SDimitry Andric class Expr; 320b57cec5SDimitry Andric class TypeLoc; 330b57cec5SDimitry Andric class SourceLocation; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric namespace index { 360b57cec5SDimitry Andric class IndexDataConsumer; 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric class IndexingContext { 390b57cec5SDimitry Andric IndexingOptions IndexOpts; 400b57cec5SDimitry Andric IndexDataConsumer &DataConsumer; 410b57cec5SDimitry Andric ASTContext *Ctx = nullptr; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric public: 440b57cec5SDimitry Andric IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer) 450b57cec5SDimitry Andric : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {} 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric const IndexingOptions &getIndexOpts() const { return IndexOpts; } 480b57cec5SDimitry Andric IndexDataConsumer &getDataConsumer() { return DataConsumer; } 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric void setASTContext(ASTContext &ctx) { Ctx = &ctx; } 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric bool shouldIndex(const Decl *D); 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric const LangOptions &getLangOpts() const; 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric bool shouldSuppressRefs() const { 570b57cec5SDimitry Andric return false; 580b57cec5SDimitry Andric } 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric bool shouldIndexFunctionLocalSymbols() const; 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric bool shouldIndexImplicitInstantiation() const; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric bool shouldIndexParametersInDeclarations() const; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric bool shouldIndexTemplateParameters() const; 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric static bool isTemplateImplicitInstantiation(const Decl *D); 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(), 71bdd1243dSDimitry Andric ArrayRef<SymbolRelation> Relations = std::nullopt); 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric bool handleDecl(const Decl *D, SourceLocation Loc, 740b57cec5SDimitry Andric SymbolRoleSet Roles = SymbolRoleSet(), 75bdd1243dSDimitry Andric ArrayRef<SymbolRelation> Relations = std::nullopt, 760b57cec5SDimitry Andric const DeclContext *DC = nullptr); 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric bool handleReference(const NamedDecl *D, SourceLocation Loc, 79bdd1243dSDimitry Andric const NamedDecl *Parent, const DeclContext *DC, 800b57cec5SDimitry Andric SymbolRoleSet Roles = SymbolRoleSet(), 81bdd1243dSDimitry Andric ArrayRef<SymbolRelation> Relations = std::nullopt, 82*5f757f3fSDimitry Andric const Expr *RefE = nullptr); 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc, 850b57cec5SDimitry Andric const MacroInfo &MI); 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc, 880b57cec5SDimitry Andric const MacroInfo &MI); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc, 910b57cec5SDimitry Andric const MacroInfo &MD); 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric bool importedModule(const ImportDecl *ImportD); 940b57cec5SDimitry Andric 950b57cec5SDimitry Andric bool indexDecl(const Decl *D); 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric void indexTagDecl(const TagDecl *D, 98bdd1243dSDimitry Andric ArrayRef<SymbolRelation> Relations = std::nullopt); 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, 1010b57cec5SDimitry Andric const DeclContext *DC = nullptr, 1020b57cec5SDimitry Andric bool isBase = false, 1030b57cec5SDimitry Andric bool isIBType = false); 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, 1060b57cec5SDimitry Andric const DeclContext *DC = nullptr, 1070b57cec5SDimitry Andric bool isBase = false, 1080b57cec5SDimitry Andric bool isIBType = false); 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, 1110b57cec5SDimitry Andric const NamedDecl *Parent, 1120b57cec5SDimitry Andric const DeclContext *DC = nullptr); 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric bool indexDeclContext(const DeclContext *DC); 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric void indexBody(const Stmt *S, const NamedDecl *Parent, 1170b57cec5SDimitry Andric const DeclContext *DC = nullptr); 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric bool indexTopLevelDecl(const Decl *D); 1200b57cec5SDimitry Andric bool indexDeclGroupRef(DeclGroupRef DG); 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric private: 1230b57cec5SDimitry Andric bool shouldIgnoreIfImplicit(const Decl *D); 1240b57cec5SDimitry Andric 125fe6060f1SDimitry Andric bool shouldIndexMacroOccurrence(bool IsRef, SourceLocation Loc); 126fe6060f1SDimitry Andric 1270b57cec5SDimitry Andric bool handleDeclOccurrence(const Decl *D, SourceLocation Loc, 1280b57cec5SDimitry Andric bool IsRef, const Decl *Parent, 1290b57cec5SDimitry Andric SymbolRoleSet Roles, 1300b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations, 1310b57cec5SDimitry Andric const Expr *RefE, 1320b57cec5SDimitry Andric const Decl *RefD, 1330b57cec5SDimitry Andric const DeclContext *ContainerDC); 1340b57cec5SDimitry Andric }; 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andric } // end namespace index 1370b57cec5SDimitry Andric } // end namespace clang 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric #endif 140