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 enum class SymbolSubKind : uint8_t {
64 TemplatePartialSpecialization = 1 << 1,
65 TemplateSpecialization = 1 << 2,
68 IBOutletCollection = 1 << 5,
70 static const unsigned SymbolSubKindBitNum = 6;
71 typedef unsigned SymbolSubKindSet;
73 /// Set of roles that are attributed to symbol occurrences.
74 enum class SymbolRole : uint16_t {
86 RelationChildOf = 1 << 9,
87 RelationBaseOf = 1 << 10,
88 RelationOverrideOf = 1 << 11,
89 RelationReceivedBy = 1 << 12,
90 RelationCalledBy = 1 << 13,
92 static const unsigned SymbolRoleBitNum = 14;
93 typedef unsigned SymbolRoleSet;
95 /// Represents a relation to another symbol for a symbol occurrence.
96 struct SymbolRelation {
98 const Decl *RelatedSymbol;
100 SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
101 : Roles(Roles), RelatedSymbol(Sym) {}
106 SymbolSubKindSet SubKinds;
110 SymbolInfo getSymbolInfo(const Decl *D);
112 void applyForEachSymbolRole(SymbolRoleSet Roles,
113 llvm::function_ref<void(SymbolRole)> Fn);
114 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
116 /// \returns true if no name was printed, false otherwise.
117 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
119 StringRef getSymbolKindString(SymbolKind K);
120 StringRef getSymbolLanguageString(SymbolLanguage K);
122 void applyForEachSymbolSubKind(SymbolSubKindSet SubKinds,
123 llvm::function_ref<void(SymbolSubKind)> Fn);
124 void printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS);