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 {
69 /// Set of properties that provide additional info about a symbol.
70 enum class SymbolProperty : uint8_t {
72 TemplatePartialSpecialization = 1 << 1,
73 TemplateSpecialization = 1 << 2,
76 IBOutletCollection = 1 << 5,
77 GKInspectable = 1 << 6,
79 static const unsigned SymbolPropertyBitNum = 7;
80 typedef unsigned SymbolPropertySet;
82 /// Set of roles that are attributed to symbol occurrences.
83 enum class SymbolRole : uint16_t {
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,
103 static const unsigned SymbolRoleBitNum = 16;
104 typedef unsigned SymbolRoleSet;
106 /// Represents a relation to another symbol for a symbol occurrence.
107 struct SymbolRelation {
109 const Decl *RelatedSymbol;
111 SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
112 : Roles(Roles), RelatedSymbol(Sym) {}
117 SymbolSubKind SubKind;
118 SymbolPropertySet Properties;
122 SymbolInfo getSymbolInfo(const Decl *D);
124 void applyForEachSymbolRole(SymbolRoleSet Roles,
125 llvm::function_ref<void(SymbolRole)> Fn);
126 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
128 /// \returns true if no name was printed, false otherwise.
129 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
131 StringRef getSymbolKindString(SymbolKind K);
132 StringRef getSymbolSubKindString(SymbolSubKind K);
133 StringRef getSymbolLanguageString(SymbolLanguage K);
135 void applyForEachSymbolProperty(SymbolPropertySet Props,
136 llvm::function_ref<void(SymbolProperty)> Fn);
137 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);