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 | |
| 13 | #include "clang/Basic/LLVM.h" |
| 14 | #include "clang/Index/IndexSymbol.h" |
| 15 | #include "clang/Index/IndexingAction.h" |
| 16 | #include "llvm/ADT/ArrayRef.h" |
| 17 | |
| 18 | namespace clang { |
| 19 | class ASTContext; |
| 20 | class Decl; |
| 21 | class DeclGroupRef; |
| 22 | class ImportDecl; |
| 23 | class TagDecl; |
| 24 | class TypeSourceInfo; |
| 25 | class NamedDecl; |
| 26 | class ObjCMethodDecl; |
| 27 | class DeclContext; |
| 28 | class NestedNameSpecifierLoc; |
| 29 | class Stmt; |
| 30 | class Expr; |
| 31 | class TypeLoc; |
| 32 | class SourceLocation; |
| 33 | |
| 34 | namespace index { |
| 35 | class IndexDataConsumer; |
| 36 | |
| 37 | class IndexingContext { |
| 38 | IndexingOptions IndexOpts; |
| 39 | IndexDataConsumer &DataConsumer; |
| 40 | ASTContext *Ctx = nullptr; |
| 41 | |
| 42 | public: |
| 43 | IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer) |
| 44 | : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {} |
| 45 | |
| 46 | const IndexingOptions &getIndexOpts() const { return IndexOpts; } |
| 47 | IndexDataConsumer &getDataConsumer() { return DataConsumer; } |
| 48 | |
| 49 | void setASTContext(ASTContext &ctx) { Ctx = &ctx; } |
| 50 | |
Argyrios Kyrtzidis | 6e5ca5b | 2017-04-21 05:42:46 +0000 | [diff] [blame^] | 51 | bool shouldIndex(const Decl *D); |
| 52 | |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 53 | bool shouldSuppressRefs() const { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | bool shouldIndexFunctionLocalSymbols() const; |
| 58 | |
| 59 | bool shouldIndexImplicitTemplateInsts() const { |
| 60 | return false; |
| 61 | } |
| 62 | |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 63 | static bool isTemplateImplicitInstantiation(const Decl *D); |
| 64 | |
| 65 | bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 66 | ArrayRef<SymbolRelation> Relations = None); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 67 | |
| 68 | bool handleDecl(const Decl *D, SourceLocation Loc, |
| 69 | SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 70 | ArrayRef<SymbolRelation> Relations = None, |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 71 | const DeclContext *DC = nullptr); |
| 72 | |
| 73 | bool handleReference(const NamedDecl *D, SourceLocation Loc, |
| 74 | const NamedDecl *Parent, |
| 75 | const DeclContext *DC, |
Argyrios Kyrtzidis | 573624a | 2017-03-17 23:41:59 +0000 | [diff] [blame] | 76 | SymbolRoleSet Roles = SymbolRoleSet(), |
Argyrios Kyrtzidis | 29cd1a4 | 2016-02-13 05:17:15 +0000 | [diff] [blame] | 77 | ArrayRef<SymbolRelation> Relations = None, |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 78 | const Expr *RefE = nullptr, |
| 79 | const Decl *RefD = nullptr); |
| 80 | |
| 81 | bool importedModule(const ImportDecl *ImportD); |
| 82 | |
| 83 | bool indexDecl(const Decl *D); |
| 84 | |
Alex Lorenz | f6071c3 | 2017-04-20 10:43:22 +0000 | [diff] [blame] | 85 | void indexTagDecl(const TagDecl *D, |
| 86 | ArrayRef<SymbolRelation> Relations = None); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 87 | |
| 88 | void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, |
| 89 | const DeclContext *DC = nullptr, |
Argyrios Kyrtzidis | de0f508 | 2017-01-11 21:01:07 +0000 | [diff] [blame] | 90 | bool isBase = false, |
| 91 | bool isIBType = false); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 92 | |
| 93 | void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, |
| 94 | const DeclContext *DC = nullptr, |
Argyrios Kyrtzidis | de0f508 | 2017-01-11 21:01:07 +0000 | [diff] [blame] | 95 | bool isBase = false, |
| 96 | bool isIBType = false); |
Argyrios Kyrtzidis | f4fb85b | 2016-02-12 23:10:59 +0000 | [diff] [blame] | 97 | |
| 98 | void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, |
| 99 | const NamedDecl *Parent, |
| 100 | const DeclContext *DC = nullptr); |
| 101 | |
| 102 | bool indexDeclContext(const DeclContext *DC); |
| 103 | |
| 104 | void indexBody(const Stmt *S, const NamedDecl *Parent, |
| 105 | const DeclContext *DC = nullptr); |
| 106 | |
| 107 | bool indexTopLevelDecl(const Decl *D); |
| 108 | bool indexDeclGroupRef(DeclGroupRef DG); |
| 109 | |
| 110 | private: |
| 111 | bool shouldIgnoreIfImplicit(const Decl *D); |
| 112 | |
| 113 | bool handleDeclOccurrence(const Decl *D, SourceLocation Loc, |
| 114 | bool IsRef, const Decl *Parent, |
| 115 | SymbolRoleSet Roles, |
| 116 | ArrayRef<SymbolRelation> Relations, |
| 117 | const Expr *RefE, |
| 118 | const Decl *RefD, |
| 119 | const DeclContext *ContainerDC); |
| 120 | }; |
| 121 | |
| 122 | } // end namespace index |
| 123 | } // end namespace clang |
| 124 | |
| 125 | #endif |