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