]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Index/IndexingContext.h
Merge clang trunk r300422 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Index / IndexingContext.h
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
51   bool shouldSuppressRefs() const {
52     return false;
53   }
54
55   bool shouldIndexFunctionLocalSymbols() const;
56
57   bool shouldIndexImplicitTemplateInsts() const {
58     return false;
59   }
60
61   static bool isTemplateImplicitInstantiation(const Decl *D);
62
63   bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
64                   ArrayRef<SymbolRelation> Relations = None);
65
66   bool handleDecl(const Decl *D, SourceLocation Loc,
67                   SymbolRoleSet Roles = SymbolRoleSet(),
68                   ArrayRef<SymbolRelation> Relations = None,
69                   const DeclContext *DC = nullptr);
70
71   bool handleReference(const NamedDecl *D, SourceLocation Loc,
72                        const NamedDecl *Parent,
73                        const DeclContext *DC,
74                        SymbolRoleSet Roles = SymbolRoleSet(),
75                        ArrayRef<SymbolRelation> Relations = None,
76                        const Expr *RefE = nullptr,
77                        const Decl *RefD = nullptr);
78
79   bool importedModule(const ImportDecl *ImportD);
80
81   bool indexDecl(const Decl *D);
82
83   void indexTagDecl(const TagDecl *D);
84
85   void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
86                            const DeclContext *DC = nullptr,
87                            bool isBase = false,
88                            bool isIBType = false);
89
90   void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
91                     const DeclContext *DC = nullptr,
92                     bool isBase = false,
93                     bool isIBType = false);
94
95   void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
96                                    const NamedDecl *Parent,
97                                    const DeclContext *DC = nullptr);
98
99   bool indexDeclContext(const DeclContext *DC);
100
101   void indexBody(const Stmt *S, const NamedDecl *Parent,
102                  const DeclContext *DC = nullptr);
103
104   bool indexTopLevelDecl(const Decl *D);
105   bool indexDeclGroupRef(DeclGroupRef DG);
106
107 private:
108   bool shouldIgnoreIfImplicit(const Decl *D);
109
110   bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
111                             bool IsRef, const Decl *Parent,
112                             SymbolRoleSet Roles,
113                             ArrayRef<SymbolRelation> Relations,
114                             const Expr *RefE,
115                             const Decl *RefD,
116                             const DeclContext *ContainerDC);
117 };
118
119 } // end namespace index
120 } // end namespace clang
121
122 #endif