Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 1 | //===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H |
| 11 | #define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H |
| 12 | |
Eric Liu | 8c97195 | 2018-07-09 08:44:05 +0000 | [diff] [blame] | 13 | #include "clang/Basic/IdentifierTable.h" |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 14 | #include "clang/Basic/LLVM.h" |
| 15 | #include "clang/Index/IndexSymbol.h" |
| 16 | #include "clang/Index/IndexingAction.h" |
Eric Liu | 8c97195 | 2018-07-09 08:44:05 +0000 | [diff] [blame] | 17 | #include "clang/Lex/MacroInfo.h" |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/ArrayRef.h" |
| 19 | |
| 20 | namespace clang { |
| 21 | class ASTContext; |
| 22 | class Decl; |
| 23 | class DeclGroupRef; |
| 24 | class ImportDecl; |
| 25 | class TagDecl; |
| 26 | class TypeSourceInfo; |
| 27 | class NamedDecl; |
| 28 | class ObjCMethodDecl; |
| 29 | class DeclContext; |
| 30 | class NestedNameSpecifierLoc; |
| 31 | class Stmt; |
| 32 | class Expr; |
| 33 | class TypeLoc; |
| 34 | class SourceLocation; |
| 35 | |
| 36 | namespace index { |
| 37 | class IndexDataConsumer; |
| 38 | |
| 39 | class IndexingContext { |
| 40 | IndexingOptions IndexOpts; |
| 41 | IndexDataConsumer &DataConsumer; |
| 42 | ASTContext *Ctx = nullptr; |
| 43 | |
| 44 | public: |
| 45 | IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer) |
| 46 | : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {} |
| 47 | |
| 48 | const IndexingOptions &getIndexOpts() const { return IndexOpts; } |
| 49 | IndexDataConsumer &getDataConsumer() { return DataConsumer; } |
| 50 | |
| 51 | void setASTContext(ASTContext &ctx) { Ctx = &ctx; } |
| 52 | |
Argyrios Kyrtzidis | 6e5ca5b | 2017-04-21 05:42:46 +0000 | [diff] [blame] | 53 | bool shouldIndex(const Decl *D); |
| 54 | |
Alex Lorenz | a352ba0 | 2017-04-24 14:04:58 +0000 | [diff] [blame] | 55 | const LangOptions &getLangOpts() const; |
| 56 | |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 57 | bool shouldSuppressRefs() const { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | bool shouldIndexFunctionLocalSymbols() const; |
| 62 | |
Fangrui Song | d50f36e | 2018-07-09 21:49:06 +0000 | [diff] [blame] | 63 | bool shouldIndexImplicitInstantiation() const; |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 64 | |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 65 | static bool isTemplateImplicitInstantiation(const Decl *D); |
| 66 | |
| 67 | bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 68 | ArrayRef<SymbolRelation> Relations = None); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 69 | |
| 70 | bool handleDecl(const Decl *D, SourceLocation Loc, |
| 71 | SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 72 | ArrayRef<SymbolRelation> Relations = None, |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 73 | const DeclContext *DC = nullptr); |
| 74 | |
| 75 | bool handleReference(const NamedDecl *D, SourceLocation Loc, |
| 76 | const NamedDecl *Parent, |
| 77 | const DeclContext *DC, |
Argyrios Kyrtzidis | 573624a | 2017-03-17 23:41:59 +0000 | [diff] [blame] | 78 | SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 79 | ArrayRef<SymbolRelation> Relations = None, |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 80 | const Expr *RefE = nullptr, |
| 81 | const Decl *RefD = nullptr); |
| 82 | |
Eric Liu | 8c97195 | 2018-07-09 08:44:05 +0000 | [diff] [blame] | 83 | void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc, |
| 84 | const MacroInfo &MI); |
| 85 | |
| 86 | void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc, |
| 87 | const MacroInfo &MI); |
| 88 | |
| 89 | void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc, |
| 90 | const MacroInfo &MD); |
| 91 | |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 92 | bool importedModule(const ImportDecl *ImportD); |
| 93 | |
| 94 | bool indexDecl(const Decl *D); |
| 95 | |
Alex Lorenz | f6071c3 | 2017-04-20 10:43:22 +0000 | [diff] [blame] | 96 | void indexTagDecl(const TagDecl *D, |
| 97 | ArrayRef<SymbolRelation> Relations = None); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 98 | |
| 99 | void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, |
| 100 | const DeclContext *DC = nullptr, |
Argyrios Kyrtzidis | de0f508 | 2017-01-11 21:01:07 +0000 | [diff] [blame] | 101 | bool isBase = false, |
| 102 | bool isIBType = false); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 103 | |
| 104 | void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, |
| 105 | const DeclContext *DC = nullptr, |
Argyrios Kyrtzidis | de0f508 | 2017-01-11 21:01:07 +0000 | [diff] [blame] | 106 | bool isBase = false, |
| 107 | bool isIBType = false); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 108 | |
| 109 | void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, |
| 110 | const NamedDecl *Parent, |
| 111 | const DeclContext *DC = nullptr); |
| 112 | |
| 113 | bool indexDeclContext(const DeclContext *DC); |
| 114 | |
| 115 | void indexBody(const Stmt *S, const NamedDecl *Parent, |
| 116 | const DeclContext *DC = nullptr); |
| 117 | |
| 118 | bool indexTopLevelDecl(const Decl *D); |
| 119 | bool indexDeclGroupRef(DeclGroupRef DG); |
| 120 | |
| 121 | private: |
| 122 | bool shouldIgnoreIfImplicit(const Decl *D); |
| 123 | |
| 124 | bool handleDeclOccurrence(const Decl *D, SourceLocation Loc, |
| 125 | bool IsRef, const Decl *Parent, |
| 126 | SymbolRoleSet Roles, |
| 127 | ArrayRef<SymbolRelation> Relations, |
| 128 | const Expr *RefE, |
| 129 | const Decl *RefD, |
| 130 | const DeclContext *ContainerDC); |
| 131 | }; |
| 132 | |
| 133 | } // end namespace index |
| 134 | } // end namespace clang |
| 135 | |
| 136 | #endif |