1 //===--- IndexSymbol.h - Types and functions for indexing symbols ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_INDEX_INDEXSYMBOL_H
11 #define LLVM_CLANG_INDEX_INDEXSYMBOL_H
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/Support/DataTypes.h"
23 enum class SymbolKind : uint8_t {
56 enum class SymbolLanguage {
62 /// Language specific sub-kinds.
63 enum class SymbolSubKind {
71 /// Set of properties that provide additional info about a symbol.
72 enum class SymbolProperty : uint8_t {
74 TemplatePartialSpecialization = 1 << 1,
75 TemplateSpecialization = 1 << 2,
78 IBOutletCollection = 1 << 5,
79 GKInspectable = 1 << 6,
81 static const unsigned SymbolPropertyBitNum = 7;
82 typedef unsigned SymbolPropertySet;
84 /// Set of roles that are attributed to symbol occurrences.
85 enum class SymbolRole : uint32_t {
97 RelationChildOf = 1 << 9,
98 RelationBaseOf = 1 << 10,
99 RelationOverrideOf = 1 << 11,
100 RelationReceivedBy = 1 << 12,
101 RelationCalledBy = 1 << 13,
102 RelationExtendedBy = 1 << 14,
103 RelationAccessorOf = 1 << 15,
104 RelationContainedBy = 1 << 16,
105 RelationIBTypeOf = 1 << 17,
107 static const unsigned SymbolRoleBitNum = 18;
108 typedef unsigned SymbolRoleSet;
110 /// Represents a relation to another symbol for a symbol occurrence.
111 struct SymbolRelation {
113 const Decl *RelatedSymbol;
115 SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
116 : Roles(Roles), RelatedSymbol(Sym) {}
121 SymbolSubKind SubKind;
122 SymbolPropertySet Properties;
126 SymbolInfo getSymbolInfo(const Decl *D);
128 void applyForEachSymbolRole(SymbolRoleSet Roles,
129 llvm::function_ref<void(SymbolRole)> Fn);
130 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
132 /// \returns true if no name was printed, false otherwise.
133 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
135 StringRef getSymbolKindString(SymbolKind K);
136 StringRef getSymbolSubKindString(SymbolSubKind K);
137 StringRef getSymbolLanguageString(SymbolLanguage K);
139 void applyForEachSymbolProperty(SymbolPropertySet Props,
140 llvm::function_ref<void(SymbolProperty)> Fn);
141 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);