File indexing completed on 2026-05-10 08:36:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_INDEX_INDEXSYMBOL_H
0010 #define LLVM_CLANG_INDEX_INDEXSYMBOL_H
0011
0012 #include "clang/Basic/LLVM.h"
0013 #include "clang/Lex/MacroInfo.h"
0014 #include "llvm/ADT/STLExtras.h"
0015 #include "llvm/Support/DataTypes.h"
0016
0017 namespace clang {
0018 class Decl;
0019 class LangOptions;
0020
0021 namespace index {
0022
0023 enum class SymbolKind : uint8_t {
0024 Unknown,
0025
0026 Module,
0027 Namespace,
0028 NamespaceAlias,
0029 Macro,
0030
0031 Enum,
0032 Struct,
0033 Class,
0034 Protocol,
0035 Extension,
0036 Union,
0037 TypeAlias,
0038
0039 Function,
0040 Variable,
0041 Field,
0042 EnumConstant,
0043
0044 InstanceMethod,
0045 ClassMethod,
0046 StaticMethod,
0047 InstanceProperty,
0048 ClassProperty,
0049 StaticProperty,
0050
0051 Constructor,
0052 Destructor,
0053 ConversionFunction,
0054
0055 Parameter,
0056 Using,
0057 TemplateTypeParm,
0058 TemplateTemplateParm,
0059 NonTypeTemplateParm,
0060
0061 Concept,
0062 };
0063
0064 enum class SymbolLanguage : uint8_t {
0065 C,
0066 ObjC,
0067 CXX,
0068 Swift,
0069 };
0070
0071
0072 enum class SymbolSubKind : uint8_t {
0073 None,
0074 CXXCopyConstructor,
0075 CXXMoveConstructor,
0076 AccessorGetter,
0077 AccessorSetter,
0078 UsingTypename,
0079 UsingValue,
0080 UsingEnum,
0081 };
0082
0083 typedef uint16_t SymbolPropertySet;
0084
0085 enum class SymbolProperty : SymbolPropertySet {
0086 Generic = 1 << 0,
0087 TemplatePartialSpecialization = 1 << 1,
0088 TemplateSpecialization = 1 << 2,
0089 UnitTest = 1 << 3,
0090 IBAnnotated = 1 << 4,
0091 IBOutletCollection = 1 << 5,
0092 GKInspectable = 1 << 6,
0093 Local = 1 << 7,
0094
0095 ProtocolInterface = 1 << 8,
0096 };
0097 static const unsigned SymbolPropertyBitNum = 9;
0098
0099
0100
0101
0102 enum class SymbolRole : uint32_t {
0103 Declaration = 1 << 0,
0104 Definition = 1 << 1,
0105 Reference = 1 << 2,
0106 Read = 1 << 3,
0107 Write = 1 << 4,
0108 Call = 1 << 5,
0109 Dynamic = 1 << 6,
0110 AddressOf = 1 << 7,
0111 Implicit = 1 << 8,
0112
0113
0114 Undefinition = 1 << 9,
0115
0116
0117 RelationChildOf = 1 << 10,
0118 RelationBaseOf = 1 << 11,
0119 RelationOverrideOf = 1 << 12,
0120 RelationReceivedBy = 1 << 13,
0121 RelationCalledBy = 1 << 14,
0122 RelationExtendedBy = 1 << 15,
0123 RelationAccessorOf = 1 << 16,
0124 RelationContainedBy = 1 << 17,
0125 RelationIBTypeOf = 1 << 18,
0126 RelationSpecializationOf = 1 << 19,
0127
0128
0129
0130 NameReference = 1 << 20,
0131 };
0132 static const unsigned SymbolRoleBitNum = 21;
0133 typedef unsigned SymbolRoleSet;
0134
0135
0136 struct SymbolRelation {
0137 SymbolRoleSet Roles;
0138 const Decl *RelatedSymbol;
0139
0140 SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)
0141 : Roles(Roles), RelatedSymbol(Sym) {}
0142 };
0143
0144 struct SymbolInfo {
0145 SymbolKind Kind;
0146 SymbolSubKind SubKind;
0147 SymbolLanguage Lang;
0148 SymbolPropertySet Properties;
0149 };
0150
0151 SymbolInfo getSymbolInfo(const Decl *D);
0152
0153 SymbolInfo getSymbolInfoForMacro(const MacroInfo &MI);
0154
0155 bool isFunctionLocalSymbol(const Decl *D);
0156
0157 void applyForEachSymbolRole(SymbolRoleSet Roles,
0158 llvm::function_ref<void(SymbolRole)> Fn);
0159 bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
0160 llvm::function_ref<bool(SymbolRole)> Fn);
0161 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
0162
0163
0164 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
0165
0166 StringRef getSymbolKindString(SymbolKind K);
0167 StringRef getSymbolSubKindString(SymbolSubKind K);
0168 StringRef getSymbolLanguageString(SymbolLanguage K);
0169
0170 void applyForEachSymbolProperty(SymbolPropertySet Props,
0171 llvm::function_ref<void(SymbolProperty)> Fn);
0172 void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
0173
0174 }
0175 }
0176
0177 #endif