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