clang  7.0.0svn
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  Parameter,
56  Using,
57 };
58 
59 enum class SymbolLanguage : uint8_t {
60  C,
61  ObjC,
62  CXX,
63  Swift,
64 };
65 
66 /// Language specific sub-kinds.
67 enum class SymbolSubKind : uint8_t {
68  None,
74  UsingValue,
75 };
76 
77 typedef uint8_t SymbolPropertySet;
78 /// Set of properties that provide additional info about a symbol.
79 enum class SymbolProperty : SymbolPropertySet {
80  Generic = 1 << 0,
82  TemplateSpecialization = 1 << 2,
83  UnitTest = 1 << 3,
84  IBAnnotated = 1 << 4,
85  IBOutletCollection = 1 << 5,
86  GKInspectable = 1 << 6,
87  Local = 1 << 7,
88 };
89 static const unsigned SymbolPropertyBitNum = 8;
90 
91 /// Set of roles that are attributed to symbol occurrences.
92 ///
93 /// Low 9 bits of clang-c/include/Index.h CXSymbolRole mirrors this enum.
94 enum class SymbolRole : uint32_t {
95  Declaration = 1 << 0,
96  Definition = 1 << 1,
97  Reference = 1 << 2,
98  Read = 1 << 3,
99  Write = 1 << 4,
100  Call = 1 << 5,
101  Dynamic = 1 << 6,
102  AddressOf = 1 << 7,
103  Implicit = 1 << 8,
104 
105  // Relation roles.
106  RelationChildOf = 1 << 9,
107  RelationBaseOf = 1 << 10,
108  RelationOverrideOf = 1 << 11,
109  RelationReceivedBy = 1 << 12,
110  RelationCalledBy = 1 << 13,
111  RelationExtendedBy = 1 << 14,
112  RelationAccessorOf = 1 << 15,
113  RelationContainedBy = 1 << 16,
114  RelationIBTypeOf = 1 << 17,
115  RelationSpecializationOf = 1 << 18,
116 };
117 static const unsigned SymbolRoleBitNum = 19;
118 typedef unsigned SymbolRoleSet;
119 
120 /// Represents a relation to another symbol for a symbol occurrence.
122  SymbolRoleSet Roles;
124 
125  SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
126  : Roles(Roles), RelatedSymbol(Sym) {}
127 };
128 
129 struct SymbolInfo {
133  SymbolPropertySet Properties;
134 };
135 
136 SymbolInfo getSymbolInfo(const Decl *D);
137 
138 bool isFunctionLocalSymbol(const Decl *D);
139 
140 void applyForEachSymbolRole(SymbolRoleSet Roles,
141  llvm::function_ref<void(SymbolRole)> Fn);
142 bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
143  llvm::function_ref<bool(SymbolRole)> Fn);
144 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
145 
146 /// \returns true if no name was printed, false otherwise.
147 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
148 
149 StringRef getSymbolKindString(SymbolKind K);
152 
153 void applyForEachSymbolProperty(SymbolPropertySet Props,
154  llvm::function_ref<void(SymbolProperty)> Fn);
155 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
156 
157 } // namespace index
158 } // namespace clang
159 
160 #endif
StringRef getSymbolLanguageString(SymbolLanguage K)
Represents a relation to another symbol for a symbol occurrence.
Definition: IndexSymbol.h:121
bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS)
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
SymbolSubKind
Language specific sub-kinds.
Definition: IndexSymbol.h:67
void applyForEachSymbolProperty(SymbolPropertySet Props, llvm::function_ref< void(SymbolProperty)> Fn)
SymbolRole
Set of roles that are attributed to symbol occurrences.
Definition: IndexSymbol.h:94
bool isFunctionLocalSymbol(const Decl *D)
Definition: IndexSymbol.cpp:52
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:50
static const unsigned SymbolRoleBitNum
Definition: IndexSymbol.h:117
StringRef getSymbolSubKindString(SymbolSubKind K)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
unsigned SymbolRoleSet
Definition: IndexSymbol.h:118
void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS)
uint8_t SymbolPropertySet
Definition: IndexSymbol.h:77
static const unsigned SymbolPropertyBitNum
Definition: IndexSymbol.h:89
void applyForEachSymbolRole(SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
Dataflow Directional Tag Classes.
SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
Definition: IndexSymbol.h:125
SymbolProperty
Set of properties that provide additional info about a symbol.
Definition: IndexSymbol.h:79
void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS)
SymbolInfo getSymbolInfo(const Decl *D)
Definition: IndexSymbol.cpp:87
SymbolPropertySet Properties
Definition: IndexSymbol.h:133