blob: 566651c83a75f957487b59397ea9d667ba618dfe [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
Argyrios Kyrtzidis6e5ca5b2017-04-21 05:42:46 +000051 bool shouldIndex(const Decl *D);
52
Alex Lorenza352ba02017-04-24 14:04:58 +000053 const LangOptions &getLangOpts() const;
54
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000055 bool shouldSuppressRefs() const {
56 return false;
57 }
58
59 bool shouldIndexFunctionLocalSymbols() const;
60
61 bool shouldIndexImplicitTemplateInsts() const {
62 return false;
63 }
64
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000065 static bool isTemplateImplicitInstantiation(const Decl *D);
66
67 bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000068 ArrayRef<SymbolRelation> Relations = None);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000069
70 bool handleDecl(const Decl *D, SourceLocation Loc,
71 SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000072 ArrayRef<SymbolRelation> Relations = None,
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000073 const DeclContext *DC = nullptr);
74
75 bool handleReference(const NamedDecl *D, SourceLocation Loc,
76 const NamedDecl *Parent,
77 const DeclContext *DC,
Argyrios Kyrtzidis573624a2017-03-17 23:41:59 +000078 SymbolRoleSet Roles = SymbolRoleSet(),
Argyrios Kyrtzidis29cd1a42016-02-13 05:17:15 +000079 ArrayRef<SymbolRelation> Relations = None,
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000080 const Expr *RefE = nullptr,
81 const Decl *RefD = nullptr);
82
83 bool importedModule(const ImportDecl *ImportD);
84
85 bool indexDecl(const Decl *D);
86
Alex Lorenzf6071c32017-04-20 10:43:22 +000087 void indexTagDecl(const TagDecl *D,
88 ArrayRef<SymbolRelation> Relations = None);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000089
90 void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
91 const DeclContext *DC = nullptr,
Argyrios Kyrtzidisde0f5082017-01-11 21:01:07 +000092 bool isBase = false,
93 bool isIBType = false);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000094
95 void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
96 const DeclContext *DC = nullptr,
Argyrios Kyrtzidisde0f5082017-01-11 21:01:07 +000097 bool isBase = false,
98 bool isIBType = false);
Argyrios Kyrtzidisf4fb85b2016-02-12 23:10:59 +000099
100 void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
101 const NamedDecl *Parent,
102 const DeclContext *DC = nullptr);
103
104 bool indexDeclContext(const DeclContext *DC);
105
106 void indexBody(const Stmt *S, const NamedDecl *Parent,
107 const DeclContext *DC = nullptr);
108
109 bool indexTopLevelDecl(const Decl *D);
110 bool indexDeclGroupRef(DeclGroupRef DG);
111
112private:
113 bool shouldIgnoreIfImplicit(const Decl *D);
114
115 bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
116 bool IsRef, const Decl *Parent,
117 SymbolRoleSet Roles,
118 ArrayRef<SymbolRelation> Relations,
119 const Expr *RefE,
120 const Decl *RefD,
121 const DeclContext *ContainerDC);
122};
123
124} // end namespace index
125} // end namespace clang
126
127#endif