clang  3.9.0
IndexSymbol.h
Go to the documentation of this file.
1 //===--- IndexSymbol.h - Types and functions for indexing symbols ---------===//
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_INDEX_INDEXSYMBOL_H
11 #define LLVM_CLANG_INDEX_INDEXSYMBOL_H
12 
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/Support/DataTypes.h"
16 
17 namespace clang {
18  class Decl;
19  class LangOptions;
20 
21 namespace index {
22 
23 enum class SymbolKind : uint8_t {
24  Unknown,
25 
26  Module,
27  Namespace,
29  Macro,
30 
31  Enum,
32  Struct,
33  Class,
34  Protocol,
35  Extension,
36  Union,
37  TypeAlias,
38 
39  Function,
40  Variable,
41  Field,
43 
50 
52  Destructor,
54 };
55 
56 enum class SymbolLanguage {
57  C,
58  ObjC,
59  CXX,
60 };
61 
62 enum class SymbolSubKind : uint8_t {
63  Generic = 1 << 0,
65  TemplateSpecialization = 1 << 2,
66  UnitTest = 1 << 3,
67  IBAnnotated = 1 << 4,
68  IBOutletCollection = 1 << 5,
69 };
70 static const unsigned SymbolSubKindBitNum = 6;
71 typedef unsigned SymbolSubKindSet;
72 
73 /// Set of roles that are attributed to symbol occurrences.
74 enum class SymbolRole : uint16_t {
75  Declaration = 1 << 0,
76  Definition = 1 << 1,
77  Reference = 1 << 2,
78  Read = 1 << 3,
79  Write = 1 << 4,
80  Call = 1 << 5,
81  Dynamic = 1 << 6,
82  AddressOf = 1 << 7,
83  Implicit = 1 << 8,
84 
85  // Relation roles.
86  RelationChildOf = 1 << 9,
87  RelationBaseOf = 1 << 10,
88  RelationOverrideOf = 1 << 11,
89  RelationReceivedBy = 1 << 12,
90  RelationCalledBy = 1 << 13,
91 };
92 static const unsigned SymbolRoleBitNum = 14;
93 typedef unsigned SymbolRoleSet;
94 
95 /// Represents a relation to another symbol for a symbol occurrence.
99 
101  : Roles(Roles), RelatedSymbol(Sym) {}
102 };
103 
104 struct SymbolInfo {
108 };
109 
110 SymbolInfo getSymbolInfo(const Decl *D);
111 
113  llvm::function_ref<void(SymbolRole)> Fn);
114 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
115 
116 /// \returns true if no name was printed, false otherwise.
117 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
118 
119 StringRef getSymbolKindString(SymbolKind K);
121 
123  llvm::function_ref<void(SymbolSubKind)> Fn);
124 void printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS);
125 
126 } // namespace index
127 } // namespace clang
128 
129 #endif
StringRef getSymbolLanguageString(SymbolLanguage K)
Represents a relation to another symbol for a symbol occurrence.
Definition: IndexSymbol.h:96
bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS)
SymbolRole
Set of roles that are attributed to symbol occurrences.
Definition: IndexSymbol.h:74
StringRef getSymbolKindString(SymbolKind K)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
static const unsigned SymbolRoleBitNum
Definition: IndexSymbol.h:92
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
unsigned SymbolRoleSet
Definition: IndexSymbol.h:93
void printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS)
void applyForEachSymbolRole(SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
unsigned SymbolSubKindSet
Definition: IndexSymbol.h:71
SymbolSubKindSet SubKinds
Definition: IndexSymbol.h:106
SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
Definition: IndexSymbol.h:100
void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS)
SymbolInfo getSymbolInfo(const Decl *D)
Definition: IndexSymbol.cpp:52
void applyForEachSymbolSubKind(SymbolSubKindSet SubKinds, llvm::function_ref< void(SymbolSubKind)> Fn)
static const unsigned SymbolSubKindBitNum
Definition: IndexSymbol.h:70