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 {
58 enum class SymbolLanguage {
64 /// Language specific sub-kinds.
65 enum class SymbolSubKind {
73 /// Set of properties that provide additional info about a symbol.
74 enum class SymbolProperty : uint8_t {
76 TemplatePartialSpecialization = 1 << 1,
77 TemplateSpecialization = 1 << 2,
80 IBOutletCollection = 1 << 5,
81 GKInspectable = 1 << 6,
84 static const unsigned SymbolPropertyBitNum = 8;
85 typedef unsigned SymbolPropertySet;
87 /// Set of roles that are attributed to symbol occurrences.
88 enum class SymbolRole : uint32_t {
100 RelationChildOf = 1 << 9,
101 RelationBaseOf = 1 << 10,
102 RelationOverrideOf = 1 << 11,
103 RelationReceivedBy = 1 << 12,
104 RelationCalledBy = 1 << 13,
105 RelationExtendedBy = 1 << 14,
106 RelationAccessorOf = 1 << 15,
107 RelationContainedBy = 1 << 16,
108 RelationIBTypeOf = 1 << 17,
110 static const unsigned SymbolRoleBitNum = 18;
111 typedef unsigned SymbolRoleSet;
113 /// Represents a relation to another symbol for a symbol occurrence.
114 struct SymbolRelation {
116 const Decl *RelatedSymbol;
118 SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
119 : Roles(Roles), RelatedSymbol(Sym) {}
124 SymbolSubKind SubKind;
125 SymbolPropertySet Properties;
129 SymbolInfo getSymbolInfo(const Decl *D);
131 bool isFunctionLocalSymbol(const Decl *D);
133 void applyForEachSymbolRole(SymbolRoleSet Roles,
134 llvm::function_ref<void(SymbolRole)> Fn);
135 bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
136 llvm::function_ref<bool(SymbolRole)> Fn);
137 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
139 /// \returns true if no name was printed, false otherwise.
140 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
142 StringRef getSymbolKindString(SymbolKind K);
143 StringRef getSymbolSubKindString(SymbolSubKind K);
144 StringRef getSymbolLanguageString(SymbolLanguage K);
146 void applyForEachSymbolProperty(SymbolPropertySet Props,
147 llvm::function_ref<void(SymbolProperty)> Fn);
148 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);