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