blob: 1ebf6f9ce67a73fa2f9556e76cbaf7e2b25ff763 [file] [log] [blame]
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +00001//===- 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
18namespace 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
34namespace index {
35 class IndexDataConsumer;
36
37class IndexingContext {
38 IndexingOptions IndexOpts;
39 IndexDataConsumer &DataConsumer;
40 ASTContext *Ctx = nullptr;
41
42public:
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
51 bool shouldSuppressRefs() const {
52 return false;
53 }
54
55 bool shouldIndexFunctionLocalSymbols() const;
56
57 bool shouldIndexImplicitTemplateInsts() const {
58 return false;
59 }
60
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000061 static bool isTemplateImplicitInstantiation(const Decl *D);
62
63 bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000064 ArrayRef<SymbolRelation> Relations = None);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000065
66 bool handleDecl(const Decl *D, SourceLocation Loc,
67 SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000068 ArrayRef<SymbolRelation> Relations = None,
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000069 const DeclContext *DC = nullptr);
70
71 bool handleReference(const NamedDecl *D, SourceLocation Loc,
72 const NamedDecl *Parent,
73 const DeclContext *DC,
Argyrios Kyrtzidis573624a2017-03-17 23:41:59 +000074 SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000075 ArrayRef<SymbolRelation> Relations = None,
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000076 const Expr *RefE = nullptr,
77 const Decl *RefD = nullptr);
78
79 bool importedModule(const ImportDecl *ImportD);
80
81 bool indexDecl(const Decl *D);
82
Alex Lorenzf6071c32017-04-20 10:43:22 +000083 void indexTagDecl(const TagDecl *D,
84 ArrayRef<SymbolRelation> Relations = None);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000085
86 void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
87 const DeclContext *DC = nullptr,
Argyrios Kyrtzidisde0f5082017-01-11 21:01:07 +000088 bool isBase = false,
89 bool isIBType = false);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000090
91 void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
92 const DeclContext *DC = nullptr,
Argyrios Kyrtzidisde0f5082017-01-11 21:01:07 +000093 bool isBase = false,
94 bool isIBType = false);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000095
96 void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
97 const NamedDecl *Parent,
98 const DeclContext *DC = nullptr);
99
100 bool indexDeclContext(const DeclContext *DC);
101
102 void indexBody(const Stmt *S, const NamedDecl *Parent,
103 const DeclContext *DC = nullptr);
104
105 bool indexTopLevelDecl(const Decl *D);
106 bool indexDeclGroupRef(DeclGroupRef DG);
107
108private:
109 bool shouldIgnoreIfImplicit(const Decl *D);
110
111 bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
112 bool IsRef, const Decl *Parent,
113 SymbolRoleSet Roles,
114 ArrayRef<SymbolRelation> Relations,
115 const Expr *RefE,
116 const Decl *RefD,
117 const DeclContext *ContainerDC);
118};
119
120} // end namespace index
121} // end namespace clang
122
123#endif