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