clang  3.9.0
IndexingContext.h
Go to the documentation of this file.
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"
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 
38  IndexingOptions IndexOpts;
39  IndexDataConsumer &DataConsumer;
40  ASTContext *Ctx = nullptr;
41 
42 public:
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 
56 
58  return false;
59  }
60 
61  static bool isFunctionLocalDecl(const Decl *D);
62  static bool isTemplateImplicitInstantiation(const Decl *D);
63 
64  bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
65  ArrayRef<SymbolRelation> Relations = None);
66 
67  bool handleDecl(const Decl *D, SourceLocation Loc,
68  SymbolRoleSet Roles = SymbolRoleSet(),
69  ArrayRef<SymbolRelation> Relations = None,
70  const DeclContext *DC = nullptr);
71 
72  bool handleReference(const NamedDecl *D, SourceLocation Loc,
73  const NamedDecl *Parent,
74  const DeclContext *DC,
75  SymbolRoleSet Roles,
76  ArrayRef<SymbolRelation> Relations = None,
77  const Expr *RefE = nullptr,
78  const Decl *RefD = nullptr);
79 
80  bool importedModule(const ImportDecl *ImportD);
81 
82  bool indexDecl(const Decl *D);
83 
84  void indexTagDecl(const TagDecl *D);
85 
86  void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
87  const DeclContext *DC = nullptr,
88  bool isBase = false);
89 
90  void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
91  const DeclContext *DC = nullptr,
92  bool isBase = false);
93 
95  const NamedDecl *Parent,
96  const DeclContext *DC = nullptr);
97 
98  bool indexDeclContext(const DeclContext *DC);
99 
100  void indexBody(const Stmt *S, const NamedDecl *Parent,
101  const DeclContext *DC = nullptr);
102 
103  bool indexTopLevelDecl(const Decl *D);
105 
106 private:
107  bool shouldIgnoreIfImplicit(const Decl *D);
108 
109  bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
110  bool IsRef, const Decl *Parent,
111  SymbolRoleSet Roles,
112  ArrayRef<SymbolRelation> Relations,
113  const Expr *RefE,
114  const Decl *RefD,
115  const DeclContext *ContainerDC);
116 };
117 
118 } // end namespace index
119 } // end namespace clang
120 
121 #endif
const IndexingOptions & getIndexOpts() const
void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false)
bool handleReference(const NamedDecl *D, SourceLocation Loc, const NamedDecl *Parent, const DeclContext *DC, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations=None, const Expr *RefE=nullptr, const Decl *RefD=nullptr)
bool indexTopLevelDecl(const Decl *D)
Definition: IndexDecl.cpp:439
A container of type source information.
Definition: Decl.h:62
void setASTContext(ASTContext &ctx)
IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer)
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:92
A C++ nested-name-specifier augmented with source location information.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool indexDecl(const Decl *D)
Definition: IndexDecl.cpp:414
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false)
unsigned SymbolRoleSet
Definition: IndexSymbol.h:93
friend class ASTContext
Definition: Type.h:4178
Expr - This represents one expression.
Definition: Expr.h:105
bool indexDeclContext(const DeclContext *DC)
Definition: IndexDecl.cpp:432
bool indexDeclGroupRef(DeclGroupRef DG)
Definition: IndexDecl.cpp:449
static bool isTemplateImplicitInstantiation(const Decl *D)
static bool isFunctionLocalDecl(const Decl *D)
Encodes a location in the source.
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2727
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3728
bool handleDecl(const Decl *D, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=None)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1135
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const NamedDecl *Parent, const DeclContext *DC=nullptr)
bool importedModule(const ImportDecl *ImportD)
bool shouldIndexFunctionLocalSymbols() const
IndexDataConsumer & getDataConsumer()
bool shouldIndexImplicitTemplateInsts() const
void indexTagDecl(const TagDecl *D)
void indexBody(const Stmt *S, const NamedDecl *Parent, const DeclContext *DC=nullptr)
Definition: IndexBody.cpp:351
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213