]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Index/IndexSymbol.h
Vendor import of clang trunk r300422:
[FreeBSD/FreeBSD.git] / include / clang / Index / IndexSymbol.h
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,
28   NamespaceAlias,
29   Macro,
30
31   Enum,
32   Struct,
33   Class,
34   Protocol,
35   Extension,
36   Union,
37   TypeAlias,
38
39   Function,
40   Variable,
41   Field,
42   EnumConstant,
43
44   InstanceMethod,
45   ClassMethod,
46   StaticMethod,
47   InstanceProperty,
48   ClassProperty,
49   StaticProperty,
50
51   Constructor,
52   Destructor,
53   ConversionFunction,
54
55   Parameter,
56 };
57
58 enum class SymbolLanguage {
59   C,
60   ObjC,
61   CXX,
62 };
63
64 /// Language specific sub-kinds.
65 enum class SymbolSubKind {
66   None,
67   CXXCopyConstructor,
68   CXXMoveConstructor,
69   AccessorGetter,
70   AccessorSetter,
71 };
72
73 /// Set of properties that provide additional info about a symbol.
74 enum class SymbolProperty : uint8_t {
75   Generic                       = 1 << 0,
76   TemplatePartialSpecialization = 1 << 1,
77   TemplateSpecialization        = 1 << 2,
78   UnitTest                      = 1 << 3,
79   IBAnnotated                   = 1 << 4,
80   IBOutletCollection            = 1 << 5,
81   GKInspectable                 = 1 << 6,
82   Local                         = 1 << 7,
83 };
84 static const unsigned SymbolPropertyBitNum = 8;
85 typedef unsigned SymbolPropertySet;
86
87 /// Set of roles that are attributed to symbol occurrences.
88 enum class SymbolRole : uint32_t {
89   Declaration = 1 << 0,
90   Definition  = 1 << 1,
91   Reference   = 1 << 2,
92   Read        = 1 << 3,
93   Write       = 1 << 4,
94   Call        = 1 << 5,
95   Dynamic     = 1 << 6,
96   AddressOf   = 1 << 7,
97   Implicit    = 1 << 8,
98
99   // Relation roles.
100   RelationChildOf     = 1 << 9,
101   RelationBaseOf      = 1 << 10,
102   RelationOverrideOf  = 1 << 11,
103   RelationReceivedBy  = 1 << 12,
104   RelationCalledBy    = 1 << 13,
105   RelationExtendedBy  = 1 << 14,
106   RelationAccessorOf  = 1 << 15,
107   RelationContainedBy = 1 << 16,
108   RelationIBTypeOf    = 1 << 17,
109 };
110 static const unsigned SymbolRoleBitNum = 18;
111 typedef unsigned SymbolRoleSet;
112
113 /// Represents a relation to another symbol for a symbol occurrence.
114 struct SymbolRelation {
115   SymbolRoleSet Roles;
116   const Decl *RelatedSymbol;
117
118   SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
119     : Roles(Roles), RelatedSymbol(Sym) {}
120 };
121
122 struct SymbolInfo {
123   SymbolKind Kind;
124   SymbolSubKind SubKind;
125   SymbolPropertySet Properties;
126   SymbolLanguage Lang;
127 };
128
129 SymbolInfo getSymbolInfo(const Decl *D);
130
131 bool isFunctionLocalSymbol(const Decl *D);
132
133 void applyForEachSymbolRole(SymbolRoleSet Roles,
134                             llvm::function_ref<void(SymbolRole)> Fn);
135 bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
136                             llvm::function_ref<bool(SymbolRole)> Fn);
137 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
138
139 /// \returns true if no name was printed, false otherwise.
140 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
141
142 StringRef getSymbolKindString(SymbolKind K);
143 StringRef getSymbolSubKindString(SymbolSubKind K);
144 StringRef getSymbolLanguageString(SymbolLanguage K);
145
146 void applyForEachSymbolProperty(SymbolPropertySet Props,
147                             llvm::function_ref<void(SymbolProperty)> Fn);
148 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
149
150 } // namespace index
151 } // namespace clang
152
153 #endif