1*0b57cec5SDimitry Andric //===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H 10*0b57cec5SDimitry Andric #define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric #include "clang/Basic/IdentifierTable.h" 13*0b57cec5SDimitry Andric #include "clang/Basic/LLVM.h" 14*0b57cec5SDimitry Andric #include "clang/Index/IndexSymbol.h" 15*0b57cec5SDimitry Andric #include "clang/Index/IndexingAction.h" 16*0b57cec5SDimitry Andric #include "clang/Lex/MacroInfo.h" 17*0b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h" 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric namespace clang { 20*0b57cec5SDimitry Andric class ASTContext; 21*0b57cec5SDimitry Andric class Decl; 22*0b57cec5SDimitry Andric class DeclGroupRef; 23*0b57cec5SDimitry Andric class ImportDecl; 24*0b57cec5SDimitry Andric class TagDecl; 25*0b57cec5SDimitry Andric class TypeSourceInfo; 26*0b57cec5SDimitry Andric class NamedDecl; 27*0b57cec5SDimitry Andric class ObjCMethodDecl; 28*0b57cec5SDimitry Andric class DeclContext; 29*0b57cec5SDimitry Andric class NestedNameSpecifierLoc; 30*0b57cec5SDimitry Andric class Stmt; 31*0b57cec5SDimitry Andric class Expr; 32*0b57cec5SDimitry Andric class TypeLoc; 33*0b57cec5SDimitry Andric class SourceLocation; 34*0b57cec5SDimitry Andric 35*0b57cec5SDimitry Andric namespace index { 36*0b57cec5SDimitry Andric class IndexDataConsumer; 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andric class IndexingContext { 39*0b57cec5SDimitry Andric IndexingOptions IndexOpts; 40*0b57cec5SDimitry Andric IndexDataConsumer &DataConsumer; 41*0b57cec5SDimitry Andric ASTContext *Ctx = nullptr; 42*0b57cec5SDimitry Andric 43*0b57cec5SDimitry Andric public: 44*0b57cec5SDimitry Andric IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer) 45*0b57cec5SDimitry Andric : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {} 46*0b57cec5SDimitry Andric 47*0b57cec5SDimitry Andric const IndexingOptions &getIndexOpts() const { return IndexOpts; } 48*0b57cec5SDimitry Andric IndexDataConsumer &getDataConsumer() { return DataConsumer; } 49*0b57cec5SDimitry Andric 50*0b57cec5SDimitry Andric void setASTContext(ASTContext &ctx) { Ctx = &ctx; } 51*0b57cec5SDimitry Andric 52*0b57cec5SDimitry Andric bool shouldIndex(const Decl *D); 53*0b57cec5SDimitry Andric 54*0b57cec5SDimitry Andric const LangOptions &getLangOpts() const; 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andric bool shouldSuppressRefs() const { 57*0b57cec5SDimitry Andric return false; 58*0b57cec5SDimitry Andric } 59*0b57cec5SDimitry Andric 60*0b57cec5SDimitry Andric bool shouldIndexFunctionLocalSymbols() const; 61*0b57cec5SDimitry Andric 62*0b57cec5SDimitry Andric bool shouldIndexImplicitInstantiation() const; 63*0b57cec5SDimitry Andric 64*0b57cec5SDimitry Andric bool shouldIndexParametersInDeclarations() const; 65*0b57cec5SDimitry Andric 66*0b57cec5SDimitry Andric bool shouldIndexTemplateParameters() const; 67*0b57cec5SDimitry Andric 68*0b57cec5SDimitry Andric static bool isTemplateImplicitInstantiation(const Decl *D); 69*0b57cec5SDimitry Andric 70*0b57cec5SDimitry Andric bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(), 71*0b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations = None); 72*0b57cec5SDimitry Andric 73*0b57cec5SDimitry Andric bool handleDecl(const Decl *D, SourceLocation Loc, 74*0b57cec5SDimitry Andric SymbolRoleSet Roles = SymbolRoleSet(), 75*0b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations = None, 76*0b57cec5SDimitry Andric const DeclContext *DC = nullptr); 77*0b57cec5SDimitry Andric 78*0b57cec5SDimitry Andric bool handleReference(const NamedDecl *D, SourceLocation Loc, 79*0b57cec5SDimitry Andric const NamedDecl *Parent, 80*0b57cec5SDimitry Andric const DeclContext *DC, 81*0b57cec5SDimitry Andric SymbolRoleSet Roles = SymbolRoleSet(), 82*0b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations = None, 83*0b57cec5SDimitry Andric const Expr *RefE = nullptr, 84*0b57cec5SDimitry Andric const Decl *RefD = nullptr); 85*0b57cec5SDimitry Andric 86*0b57cec5SDimitry Andric void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc, 87*0b57cec5SDimitry Andric const MacroInfo &MI); 88*0b57cec5SDimitry Andric 89*0b57cec5SDimitry Andric void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc, 90*0b57cec5SDimitry Andric const MacroInfo &MI); 91*0b57cec5SDimitry Andric 92*0b57cec5SDimitry Andric void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc, 93*0b57cec5SDimitry Andric const MacroInfo &MD); 94*0b57cec5SDimitry Andric 95*0b57cec5SDimitry Andric bool importedModule(const ImportDecl *ImportD); 96*0b57cec5SDimitry Andric 97*0b57cec5SDimitry Andric bool indexDecl(const Decl *D); 98*0b57cec5SDimitry Andric 99*0b57cec5SDimitry Andric void indexTagDecl(const TagDecl *D, 100*0b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations = None); 101*0b57cec5SDimitry Andric 102*0b57cec5SDimitry Andric void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, 103*0b57cec5SDimitry Andric const DeclContext *DC = nullptr, 104*0b57cec5SDimitry Andric bool isBase = false, 105*0b57cec5SDimitry Andric bool isIBType = false); 106*0b57cec5SDimitry Andric 107*0b57cec5SDimitry Andric void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, 108*0b57cec5SDimitry Andric const DeclContext *DC = nullptr, 109*0b57cec5SDimitry Andric bool isBase = false, 110*0b57cec5SDimitry Andric bool isIBType = false); 111*0b57cec5SDimitry Andric 112*0b57cec5SDimitry Andric void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, 113*0b57cec5SDimitry Andric const NamedDecl *Parent, 114*0b57cec5SDimitry Andric const DeclContext *DC = nullptr); 115*0b57cec5SDimitry Andric 116*0b57cec5SDimitry Andric bool indexDeclContext(const DeclContext *DC); 117*0b57cec5SDimitry Andric 118*0b57cec5SDimitry Andric void indexBody(const Stmt *S, const NamedDecl *Parent, 119*0b57cec5SDimitry Andric const DeclContext *DC = nullptr); 120*0b57cec5SDimitry Andric 121*0b57cec5SDimitry Andric bool indexTopLevelDecl(const Decl *D); 122*0b57cec5SDimitry Andric bool indexDeclGroupRef(DeclGroupRef DG); 123*0b57cec5SDimitry Andric 124*0b57cec5SDimitry Andric private: 125*0b57cec5SDimitry Andric bool shouldIgnoreIfImplicit(const Decl *D); 126*0b57cec5SDimitry Andric 127*0b57cec5SDimitry Andric bool handleDeclOccurrence(const Decl *D, SourceLocation Loc, 128*0b57cec5SDimitry Andric bool IsRef, const Decl *Parent, 129*0b57cec5SDimitry Andric SymbolRoleSet Roles, 130*0b57cec5SDimitry Andric ArrayRef<SymbolRelation> Relations, 131*0b57cec5SDimitry Andric const Expr *RefE, 132*0b57cec5SDimitry Andric const Decl *RefD, 133*0b57cec5SDimitry Andric const DeclContext *ContainerDC); 134*0b57cec5SDimitry Andric }; 135*0b57cec5SDimitry Andric 136*0b57cec5SDimitry Andric } // end namespace index 137*0b57cec5SDimitry Andric } // end namespace clang 138*0b57cec5SDimitry Andric 139*0b57cec5SDimitry Andric #endif 140