clang 22.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.
83
84typedef uint16_t SymbolPropertySet;
85/// Set of properties that provide additional info about a symbol.
87 Generic = 1 << 0,
90 UnitTest = 1 << 3,
91 IBAnnotated = 1 << 4,
93 GKInspectable = 1 << 6,
94 Local = 1 << 7,
95 /// Symbol is part of a protocol interface.
97};
98static const unsigned SymbolPropertyBitNum = 9;
99
100/// Set of roles that are attributed to symbol occurrences.
101///
102/// Low 9 bits of clang-c/include/Index.h CXSymbolRole mirrors this enum.
103enum class SymbolRole : uint32_t {
104 Declaration = 1 << 0,
105 Definition = 1 << 1,
106 Reference = 1 << 2,
107 Read = 1 << 3,
108 Write = 1 << 4,
109 Call = 1 << 5,
110 Dynamic = 1 << 6,
111 AddressOf = 1 << 7,
112 Implicit = 1 << 8,
113 // FIXME: this is not mirrored in CXSymbolRole.
114 // Note that macro occurrences aren't currently supported in libclang.
115 Undefinition = 1 << 9, // macro #undef
116
117 // Relation roles.
119 RelationBaseOf = 1 << 11,
128
129 // Symbol only references the name of the object as written. For example, a
130 // constructor references the class declaration using that role.
131 NameReference = 1 << 20,
132};
133static const unsigned SymbolRoleBitNum = 21;
134typedef unsigned SymbolRoleSet;
135
136/// Represents a relation to another symbol for a symbol occurrence.
144
151
153
155
156bool isFunctionLocalSymbol(const Decl *D);
157
159 llvm::function_ref<void(SymbolRole)> Fn);
161 llvm::function_ref<bool(SymbolRole)> Fn);
162void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
163
164/// \returns true if no name was printed, false otherwise.
165bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
166
170
172 llvm::function_ref<void(SymbolProperty)> Fn);
173void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS);
174
175} // namespace index
176} // namespace clang
177
178#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
Definition IndexSymbol.h:98
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:86
@ ProtocolInterface
Symbol is part of a protocol interface.
Definition IndexSymbol.h:96
uint16_t SymbolPropertySet
Definition IndexSymbol.h:84
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)