clang 23.0.0git
IndexSymbol.h
Go to the documentation of this file.
1//===- IndexSymbol.h - Types and functions for indexing symbols -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_INDEX_INDEXSYMBOL_H
10#define LLVM_CLANG_INDEX_INDEXSYMBOL_H
11
12#include "clang/Basic/LLVM.h"
13#include "clang/Lex/MacroInfo.h"
14#include "llvm/ADT/STLExtras.h"
15#include "llvm/Support/DataTypes.h"
16
17namespace clang {
18 class Decl;
19 class LangOptions;
20
21namespace index {
22
64
65enum class SymbolLanguage : uint8_t {
70};
71
72/// Language specific sub-kinds.
85
86typedef uint16_t SymbolPropertySet;
87/// Set of properties that provide additional info about a symbol.
89 Generic = 1 << 0,
92 UnitTest = 1 << 3,
93 IBAnnotated = 1 << 4,
95 GKInspectable = 1 << 6,
96 Local = 1 << 7,
97 /// Symbol is part of a protocol interface.
99};
100static const unsigned SymbolPropertyBitNum = 9;
101
102/// Set of roles that are attributed to symbol occurrences.
103///
104/// Low 9 bits of clang-c/include/Index.h CXSymbolRole mirrors this enum.
105enum class SymbolRole : uint32_t {
106 Declaration = 1 << 0,
107 Definition = 1 << 1,
108 Reference = 1 << 2,
109 Read = 1 << 3,
110 Write = 1 << 4,
111 Call = 1 << 5,
112 Dynamic = 1 << 6,
113 AddressOf = 1 << 7,
114 Implicit = 1 << 8,
115 // FIXME: this is not mirrored in CXSymbolRole.
116 // Note that macro occurrences aren't currently supported in libclang.
117 Undefinition = 1 << 9, // macro #undef
118
119 // Relation roles.
121 RelationBaseOf = 1 << 11,
130
131 // Symbol only references the name of the object as written. For example, a
132 // constructor references the class declaration using that role.
133 NameReference = 1 << 20,
134};
135static const unsigned SymbolRoleBitNum = 21;
136typedef unsigned SymbolRoleSet;
137
138/// Represents a relation to another symbol for a symbol occurrence.
146
153
155
157
158bool isFunctionLocalSymbol(const Decl *D);
159
161 llvm::function_ref<void(SymbolRole)> Fn);
163 llvm::function_ref<bool(SymbolRole)> Fn);
164void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
165
166/// \returns true if no name was printed, false otherwise.
167bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
168
172
174 llvm::function_ref<void(SymbolProperty)> Fn);
175void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
176
177} // namespace index
178} // namespace clang
179
180#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::MacroInfo and clang::MacroDirective classes.
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Encapsulates the data about a macro definition (e.g.
Definition MacroInfo.h:39
void applyForEachSymbolProperty(SymbolPropertySet Props, llvm::function_ref< void(SymbolProperty)> Fn)
SymbolRole
Set of roles that are attributed to symbol occurrences.
StringRef getSymbolSubKindString(SymbolSubKind K)
static const unsigned SymbolPropertyBitNum
void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS)
SymbolInfo getSymbolInfo(const Decl *D)
StringRef getSymbolKindString(SymbolKind K)
bool isFunctionLocalSymbol(const Decl *D)
void applyForEachSymbolRole(SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS)
SymbolInfo getSymbolInfoForMacro(const MacroInfo &MI)
bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS)
static const unsigned SymbolRoleBitNum
unsigned SymbolRoleSet
bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
SymbolProperty
Set of properties that provide additional info about a symbol.
Definition IndexSymbol.h:88
@ ProtocolInterface
Symbol is part of a protocol interface.
Definition IndexSymbol.h:98
uint16_t SymbolPropertySet
Definition IndexSymbol.h:86
StringRef getSymbolLanguageString(SymbolLanguage K)
SymbolSubKind
Language specific sub-kinds.
Definition IndexSymbol.h:73
The JSON file list parser is used to communicate input to InstallAPI.
SymbolPropertySet Properties
SymbolRelation(SymbolRoleSet Roles, const Decl *Sym)