]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h
Merge llvm, clang, lld and lldb trunk r291476.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / 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
56 enum class SymbolLanguage {
57   C,
58   ObjC,
59   CXX,
60 };
61
62 /// Language specific sub-kinds.
63 enum class SymbolSubKind {
64   None,
65   CXXCopyConstructor,
66   CXXMoveConstructor,
67 };
68
69 /// Set of properties that provide additional info about a symbol.
70 enum class SymbolProperty : uint8_t {
71   Generic                       = 1 << 0,
72   TemplatePartialSpecialization = 1 << 1,
73   TemplateSpecialization        = 1 << 2,
74   UnitTest                      = 1 << 3,
75   IBAnnotated                   = 1 << 4,
76   IBOutletCollection            = 1 << 5,
77   GKInspectable                 = 1 << 6,
78 };
79 static const unsigned SymbolPropertyBitNum = 7;
80 typedef unsigned SymbolPropertySet;
81
82 /// Set of roles that are attributed to symbol occurrences.
83 enum class SymbolRole : uint16_t {
84   Declaration = 1 << 0,
85   Definition  = 1 << 1,
86   Reference   = 1 << 2,
87   Read        = 1 << 3,
88   Write       = 1 << 4,
89   Call        = 1 << 5,
90   Dynamic     = 1 << 6,
91   AddressOf   = 1 << 7,
92   Implicit    = 1 << 8,
93
94   // Relation roles.
95   RelationChildOf     = 1 << 9,
96   RelationBaseOf      = 1 << 10,
97   RelationOverrideOf  = 1 << 11,
98   RelationReceivedBy  = 1 << 12,
99   RelationCalledBy    = 1 << 13,
100   RelationExtendedBy  = 1 << 14,
101   RelationAccessorOf  = 1 << 15,
102 };
103 static const unsigned SymbolRoleBitNum = 16;
104 typedef unsigned SymbolRoleSet;
105
106 /// Represents a relation to another symbol for a symbol occurrence.
107 struct SymbolRelation {
108   SymbolRoleSet Roles;
109   const Decl *RelatedSymbol;
110
111   SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
112     : Roles(Roles), RelatedSymbol(Sym) {}
113 };
114
115 struct SymbolInfo {
116   SymbolKind Kind;
117   SymbolSubKind SubKind;
118   SymbolPropertySet Properties;
119   SymbolLanguage Lang;
120 };
121
122 SymbolInfo getSymbolInfo(const Decl *D);
123
124 void applyForEachSymbolRole(SymbolRoleSet Roles,
125                             llvm::function_ref<void(SymbolRole)> Fn);
126 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
127
128 /// \returns true if no name was printed, false otherwise.
129 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
130
131 StringRef getSymbolKindString(SymbolKind K);
132 StringRef getSymbolSubKindString(SymbolSubKind K);
133 StringRef getSymbolLanguageString(SymbolLanguage K);
134
135 void applyForEachSymbolProperty(SymbolPropertySet Props,
136                             llvm::function_ref<void(SymbolProperty)> Fn);
137 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
138
139 } // namespace index
140 } // namespace clang
141
142 #endif