clang-tools 10.0.0

YAMLSerialization.cpp
Go to the documentation of this file.
1 //===-- YAMLSerialization.cpp ------------------------------------*- 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 // A YAML index file is a sequence of tagged entries.
10 // Each entry either encodes a Symbol or the list of references to a symbol
11 // (a "ref bundle").
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "Index.h"
16 #include "Relation.h"
17 #include "Serialization.h"
18 #include "SymbolLocation.h"
19 #include "SymbolOrigin.h"
20 #include "Trace.h"
21 #include "dex/Dex.h"
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Support/Allocator.h"
26 #include "llvm/Support/Errc.h"
27 #include "llvm/Support/MemoryBuffer.h"
28 #include "llvm/Support/StringSaver.h"
29 #include "llvm/Support/YAMLTraits.h"
30 #include "llvm/Support/raw_ostream.h"
31 #include <cstdint>
32
33 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::clangd::Symbol::IncludeHeaderWithReferences)
34 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::clangd::Ref)
35
36 namespace {
37 using RefBundle =
38 std::pair<clang::clangd::SymbolID, std::vector<clang::clangd::Ref>>;
39 // This is a pale imitation of std::variant<Symbol, RefBundle, Relation>
40 struct VariantEntry {
41 llvm::Optional<clang::clangd::Symbol> Symbol;
42 llvm::Optional<RefBundle> Refs;
43 llvm::Optional<clang::clangd::Relation> Relation;
44 };
45 // A class helps YAML to serialize the 32-bit encoded position (Line&Column),
46 // as YAMLIO can't directly map bitfields.
47 struct YPosition {
48 uint32_t Line;
49 uint32_t Column;
50 };
51
52 } // namespace
53 namespace llvm {
54 namespace yaml {
55
56 using clang::clangd::Ref;
57 using clang::clangd::RefKind;
58 using clang::clangd::Relation;
59 using clang::clangd::RelationKind;
60 using clang::clangd::Symbol;
61 using clang::clangd::SymbolID;
62 using clang::clangd::SymbolLocation;
63 using clang::clangd::SymbolOrigin;
64 using clang::index::SymbolInfo;
65 using clang::index::SymbolKind;
66 using clang::index::SymbolLanguage;
67 using clang::index::SymbolRole;
68
69 // Helper to (de)serialize the SymbolID. We serialize it as a hex string.
70 struct NormalizedSymbolID {
71 NormalizedSymbolID(IO &) {}
72 NormalizedSymbolID(IO &, const SymbolID &ID) {
73 llvm::raw_string_ostream OS(HexString);
74 OS << ID;
75 }
76
77 SymbolID denormalize(IO &I) {
78 auto ID = SymbolID::fromStr(HexString);
79 if (!ID) {
80 I.setError(llvm::toString(ID.takeError()));
81 return SymbolID();
82 }
83 return *ID;
84 }
85
86 std::string HexString;
87 };
88
89 struct NormalizedSymbolFlag {
90 NormalizedSymbolFlag(IO &) {}
91 NormalizedSymbolFlag(IO &, Symbol::SymbolFlag F) {
92 Flag = static_cast<uint8_t>(F);
93 }
94
95 Symbol::SymbolFlag denormalize(IO &) {
96 return static_cast<Symbol::SymbolFlag>(Flag);
97 }
98
99 uint8_t Flag = 0;
100 };
101
102 struct NormalizedSymbolOrigin {
103 NormalizedSymbolOrigin(IO &) {}
104 NormalizedSymbolOrigin(IO &, SymbolOrigin O) {
105 Origin = static_cast<uint8_t>(O);
106 }
107
108 SymbolOrigin denormalize(IO &) { return static_cast<SymbolOrigin>(Origin); }
109
110 uint8_t Origin = 0;
111 };
112
113 template <> struct MappingTraits<YPosition> {
114 static void mapping(IO &IO, YPosition &Value) {
115 IO.mapRequired("Line", Value.Line);
116 IO.mapRequired("Column", Value.Column);
117 }
118 };
119
120 struct NormalizedPosition {
121 using Position = clang::clangd::SymbolLocation::Position;
122 NormalizedPosition(IO &) {}
123 NormalizedPosition(IO &, const Position &Pos) {
124 P.Line = Pos.line();
125 P.Column = Pos.column();
126 }
127
128 Position denormalize(IO &) {
129 Position Pos;
130 Pos.setLine(P.Line);
131 Pos.setColumn(P.Column);
132 return Pos;
133 }
134 YPosition P;
135 };
136
137 struct NormalizedFileURI {
138 NormalizedFileURI(IO &) {}
139 NormalizedFileURI(IO &, const char *FileURI) { URI = FileURI; }
140
141 const char *denormalize(IO &IO) {
142 assert(IO.getContext() &&
143 "Expecting an UniqueStringSaver to allocate data");
144 return static_cast<llvm::UniqueStringSaver *>(IO.getContext())
145 ->save(URI)
146 .data();
147 }
148
149 std::string URI;
150 };
151
152 template <> struct MappingTraits<SymbolLocation> {
153 static void mapping(IO &IO, SymbolLocation &Value) {
154 MappingNormalization<NormalizedFileURI, const char *> NFile(IO,
155 Value.FileURI);
156 IO.mapRequired("FileURI", NFile->URI);
157 MappingNormalization<NormalizedPosition, SymbolLocation::Position> NStart(
158 IO, Value.Start);
159 IO.mapRequired("Start", NStart->P);
160 MappingNormalization<NormalizedPosition, SymbolLocation::Position> NEnd(
161 IO, Value.End);
162 IO.mapRequired("End", NEnd->P);
163 }
164 };
165
166 template <> struct MappingTraits<SymbolInfo> {
167 static void mapping(IO &io, SymbolInfo &SymInfo) {
168 // FIXME: expose other fields?
169 io.mapRequired("Kind", SymInfo.Kind);
170 io.mapRequired("Lang", SymInfo.Lang);
171 }
172 };
173
174 template <>
175 struct MappingTraits<clang::clangd::Symbol::IncludeHeaderWithReferences> {
176 static void mapping(IO &io,
177 clang::clangd::Symbol::IncludeHeaderWithReferences &Inc) {
178 io.mapRequired("Header", Inc.IncludeHeader);
179 io.mapRequired("References", Inc.References);
180 }
181 };
182
183 template <> struct MappingTraits<Symbol> {
184 static void mapping(IO &IO, Symbol &Sym) {
185 MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO, Sym.ID);
186 MappingNormalization<NormalizedSymbolFlag, Symbol::SymbolFlag> NSymbolFlag(
187 IO, Sym.Flags);
188 MappingNormalization<NormalizedSymbolOrigin, SymbolOrigin> NSymbolOrigin(
189 IO, Sym.Origin);
190 IO.mapRequired("ID", NSymbolID->HexString);
191 IO.mapRequired("Name", Sym.Name);
192 IO.mapRequired("Scope", Sym.Scope);
193 IO.mapRequired("SymInfo", Sym.SymInfo);
194 IO.mapOptional("CanonicalDeclaration", Sym.CanonicalDeclaration,
195 SymbolLocation());
196 IO.mapOptional("Definition", Sym.Definition, SymbolLocation());
197 IO.mapOptional("References", Sym.References, 0u);
198 IO.mapOptional("Origin", NSymbolOrigin->Origin);
199 IO.mapOptional("Flags", NSymbolFlag->Flag);
200 IO.mapOptional("Signature", Sym.Signature);
201 IO.mapOptional("TemplateSpecializationArgs",
202 Sym.TemplateSpecializationArgs);
203 IO.mapOptional("CompletionSnippetSuffix", Sym.CompletionSnippetSuffix);
204 IO.mapOptional("Documentation", Sym.Documentation);
205 IO.mapOptional("ReturnType", Sym.ReturnType);
206 IO.mapOptional("Type", Sym.Type);
207 IO.mapOptional("IncludeHeaders", Sym.IncludeHeaders);
208 }
209 };
210
211 template <> struct ScalarEnumerationTraits<SymbolLanguage> {
212 static void enumeration(IO &IO, SymbolLanguage &Value) {
213 IO.enumCase(Value, "C", SymbolLanguage::C);
214 IO.enumCase(Value, "Cpp", SymbolLanguage::CXX);
215 IO.enumCase(Value, "ObjC", SymbolLanguage::ObjC);
216 IO.enumCase(Value, "Swift", SymbolLanguage::Swift);
217 }
218 };
219
220 template <> struct ScalarEnumerationTraits<SymbolKind> {
221 static void enumeration(IO &IO, SymbolKind &Value) {
222 #define DEFINE_ENUM(name) IO.enumCase(Value, #name, SymbolKind::name)
223
224 DEFINE_ENUM(Unknown);
225 DEFINE_ENUM(Function);
226 DEFINE_ENUM(Module);
227 DEFINE_ENUM(Namespace);
228 DEFINE_ENUM(NamespaceAlias);
229 DEFINE_ENUM(Macro);
230 DEFINE_ENUM(Enum);
231 DEFINE_ENUM(Struct);
232 DEFINE_ENUM(Class);
233 DEFINE_ENUM(Protocol);
234 DEFINE_ENUM(Extension);
235 DEFINE_ENUM(Union);
236 DEFINE_ENUM(TypeAlias);
237 DEFINE_ENUM(Function);
238 DEFINE_ENUM(Variable);
239 DEFINE_ENUM(Field);
240 DEFINE_ENUM(EnumConstant);
241 DEFINE_ENUM(InstanceMethod);
242 DEFINE_ENUM(ClassMethod);
243 DEFINE_ENUM(StaticMethod);
244 DEFINE_ENUM(InstanceProperty);
245 DEFINE_ENUM(ClassProperty);
246 DEFINE_ENUM(StaticProperty);
247 DEFINE_ENUM(Constructor);
248 DEFINE_ENUM(Destructor);
249 DEFINE_ENUM(ConversionFunction);
250 DEFINE_ENUM(Parameter);
251 DEFINE_ENUM(Using);
252
253 #undef DEFINE_ENUM
254 }
255 };
256
257 template <> struct MappingTraits<RefBundle> {
258 static void mapping(IO &IO, RefBundle &Refs) {
259 MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO,
260 Refs.first);
261 IO.mapRequired("ID", NSymbolID->HexString);
262 IO.mapRequired("References", Refs.second);
263 }
264 };
265
266 struct NormalizedRefKind {
267 NormalizedRefKind(IO &) {}
268 NormalizedRefKind(IO &, RefKind O) { Kind = static_cast<uint8_t>(O); }
269
270 RefKind denormalize(IO &) { return static_cast<RefKind>(Kind); }
271
272 uint8_t Kind = 0;
273 };
274
275 template <> struct MappingTraits<Ref> {
276 static void mapping(IO &IO, Ref &R) {
277 MappingNormalization<NormalizedRefKind, RefKind> NKind(IO, R.Kind);
278 IO.mapRequired("Kind", NKind->Kind);
279 IO.mapRequired("Location", R.Location);
280 }
281 };
282
283 struct NormalizedSymbolRole {
284 NormalizedSymbolRole(IO &) {}
285 NormalizedSymbolRole(IO &IO, RelationKind R) {
286 Kind = static_cast<uint8_t>(R);
287 }
288
289 RelationKind denormalize(IO &IO) { return static_cast<RelationKind>(Kind); }
290
291 uint8_t Kind = 0;
292 };
293
294 template <> struct MappingTraits<SymbolID> {
295 static void mapping(IO &IO, SymbolID &ID) {
296 MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO, ID);
297 IO.mapRequired("ID", NSymbolID->HexString);
298 }
299 };
300
301 template <> struct MappingTraits<Relation> {
302 static void mapping(IO &IO, Relation &Relation) {
303 MappingNormalization<NormalizedSymbolRole, RelationKind> NRole(
304 IO, Relation.Predicate);
305 IO.mapRequired("Subject", Relation.Subject);
306 IO.mapRequired("Predicate", NRole->Kind);
307 IO.mapRequired("Object", Relation.Object);
308 }
309 };
310
311 template <> struct MappingTraits<VariantEntry> {
312 static void mapping(IO &IO, VariantEntry &Variant) {
313 if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) {
314 if (!IO.outputting())
315 Variant.Symbol.emplace();
316 MappingTraits<Symbol>::mapping(IO, *Variant.Symbol);
317 } else if (IO.mapTag("!Refs", Variant.Refs.hasValue())) {
318 if (!IO.outputting())
319 Variant.Refs.emplace();
320 MappingTraits<RefBundle>::mapping(IO, *Variant.Refs);
321 } else if (IO.mapTag("!Relations", Variant.Relation.hasValue())) {
322 if (!IO.outputting())
323 Variant.Relation.emplace();
324 MappingTraits<Relation>::mapping(IO, *Variant.Relation);
325 }
326 }
327 };
328
329 } // namespace yaml
330 } // namespace llvm
331
332 namespace clang {
333 namespace clangd {
334
335 void writeYAML(const IndexFileOut &O, llvm::raw_ostream &OS) {
336 llvm::yaml::Output Yout(OS);
337 for (const auto &Sym : *O.Symbols) {
338 VariantEntry Entry;
339 Entry.Symbol = Sym;
340 Yout << Entry;
341 }
342 if (O.Refs)
343 for (auto &Sym : *O.Refs) {
344 VariantEntry Entry;
345 Entry.Refs = Sym;
346 Yout << Entry;
347 }
348 if (O.Relations)
349 for (auto &R : *O.Relations) {
350 VariantEntry Entry;
351 Entry.Relation = R;
352 Yout << Entry;
353 }
354 }
355
356 llvm::Expected<IndexFileIn> readYAML(llvm::StringRef Data) {
357 SymbolSlab::Builder Symbols;
358 RefSlab::Builder Refs;
359 RelationSlab::Builder Relations;
360 llvm::BumpPtrAllocator
361 Arena; // store the underlying data of Position::FileURI.
362 llvm::UniqueStringSaver Strings(Arena);
363 llvm::yaml::Input Yin(Data, &Strings);
364 while (Yin.setCurrentDocument()) {
365 llvm::yaml::EmptyContext Ctx;
366 VariantEntry Variant;
367 yamlize(Yin, Variant, true, Ctx);
368 if (Yin.error())
369 return llvm::errorCodeToError(Yin.error());
370
371 if (Variant.Symbol)
372 Symbols.insert(*Variant.Symbol);
373 if (Variant.Refs)
374 for (const auto &Ref : Variant.Refs->second)
375 Refs.insert(Variant.Refs->first, Ref);
376 if (Variant.Relation)
377 Relations.insert(*Variant.Relation);
378 Yin.nextDocument();
379 }
380
381 IndexFileIn Result;
382 Result.Symbols.emplace(std::move(Symbols).build());
383 Result.Refs.emplace(std::move(Refs).build());
384 Result.Relations.emplace(std::move(Relations).build());
385 return std::move(Result);
386 }
387
388 std::string toYAML(const Symbol &S) {
389 std::string Buf;
390 {
391 llvm::raw_string_ostream OS(Buf);
392 llvm::yaml::Output Yout(OS);
393 Symbol Sym = S; // copy: Yout<< requires mutability.
394 Yout << Sym;
395 }
396 return Buf;
397 }
398
399 std::string toYAML(const std::pair<SymbolID, llvm::ArrayRef<Ref>> &Data) {
400 RefBundle Refs = {Data.first, Data.second};
401 std::string Buf;
402 {
403 llvm::raw_string_ostream OS(Buf);
404 llvm::yaml::Output Yout(OS);
405 Yout << Refs;
406 }
407 return Buf;
408 }
409
410 std::string toYAML(const Relation &R) {
411 std::string Buf;
412 {
413 llvm::raw_string_ostream OS(Buf);
414 llvm::yaml::Output Yout(OS);
415 Relation Rel = R; // copy: Yout<< requires mutability.
416 Yout << Rel;
417 }
418 return Buf;
419 }
420
421 } // namespace clangd
422 } // namespace clang
clang::clangd::readYAML
llvm::Expected< IndexFileIn > readYAML(llvm::StringRef)
Definition: YAMLSerialization.cpp:356
clang::clangd::Relation::Object
SymbolID Object
Definition: Relation.h:32
clang::clangd::IndexFileIn::Symbols
llvm::Optional< SymbolSlab > Symbols
Definition: Serialization.h:43
llvm::yaml::NormalizedPosition::NormalizedPosition
NormalizedPosition(IO &)
Definition: YAMLSerialization.cpp:122
llvm::yaml::NormalizedSymbolFlag::denormalize
Symbol::SymbolFlag denormalize(IO &)
Definition: YAMLSerialization.cpp:95
Trace.h
llvm
Some operations such as code completion produce a set of candidates.
Definition: YAMLGenerator.cpp:28
clang::clangd::Relation
Represents a relation between two symbols.
Definition: Relation.h:29
clang::clangd::SymbolLocation::Position::setColumn
void setColumn(uint32_t Column)
Definition: SymbolLocation.cpp:24
clang::clangd::IndexFileOut::Refs
const RefSlab * Refs
Definition: Serialization.h:57
clang::clangd::SymbolLocation
Definition: SymbolLocation.h:19
llvm::yaml::MappingTraits< SymbolInfo >::mapping
static void mapping(IO &io, SymbolInfo &SymInfo)
Definition: YAMLSerialization.cpp:167
clang::clangd::SymbolLocation::Position::column
uint32_t column() const
Definition: SymbolLocation.h:37
Dex.h
This defines Dex - a symbol index implementation based on query iterators over symbol tokens...
llvm::yaml::MappingTraits< clang::clangd::Symbol::IncludeHeaderWithReferences >::mapping
static void mapping(IO &io, clang::clangd::Symbol::IncludeHeaderWithReferences &Inc)
Definition: YAMLSerialization.cpp:176
Index.h
clang::clangd::RelationKind
RelationKind
Definition: Relation.h:22
clang::clangd::Symbol::IncludeHeaderWithReferences::References
unsigned References
The number of translation units that reference this symbol and include this header.
Definition: Symbol.h:104
clang::clangd::writeYAML
void writeYAML(const IndexFileOut &, llvm::raw_ostream &)
Definition: YAMLSerialization.cpp:335
SymbolKind
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
Definition: SymbolInfo.cpp:21
clang::clangd::SymbolLocation::Position::setLine
void setLine(uint32_t Line)
Definition: SymbolLocation.cpp:17
llvm::yaml::NormalizedSymbolOrigin::NormalizedSymbolOrigin
NormalizedSymbolOrigin(IO &)
Definition: YAMLSerialization.cpp:103
llvm::yaml::NormalizedFileURI::denormalize
const char * denormalize(IO &IO)
Definition: YAMLSerialization.cpp:141
clang::clangd::Ref
Represents a symbol occurrence in the source file.
Definition: Ref.h:52
llvm::yaml::NormalizedSymbolID
Definition: YAMLSerialization.cpp:70
clang::clangd::SymbolSlab::Builder::insert
void insert(const Symbol &S)
Adds a symbol, overwriting any existing one with the same ID.
Definition: Symbol.cpp:50
clang::tidy::cppcoreguidelines::toString
static llvm::StringRef toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K)
Definition: SpecialMemberFunctionsCheck.cpp:58
Column
int Column
Definition: PreprocessorTracker.cpp:527
llvm::yaml::ScalarEnumerationTraits< SymbolKind >::enumeration
static void enumeration(IO &IO, SymbolKind &Value)
Definition: YAMLSerialization.cpp:221
clang::clangd::Symbol::Scope
llvm::StringRef Scope
The containing namespace. e.g. "" (global), "ns::" (top-level namespace).
Definition: Symbol.h:44
clang::clangd::Symbol::SymbolFlag
SymbolFlag
Definition: Symbol.h:113
clang::clangd::IndexFileIn::Relations
llvm::Optional< RelationSlab > Relations
Definition: Serialization.h:45
Serialization.h
llvm::yaml::MappingTraits< Ref >::mapping
static void mapping(IO &IO, Ref &R)
Definition: YAMLSerialization.cpp:276
clang::clangd::IndexFileOut::Symbols
const SymbolSlab * Symbols
Definition: Serialization.h:56
clang::clangd::Symbol::References
unsigned References
The number of translation units that reference this symbol from their main file.
Definition: Symbol.h:59
clang::clangd::SymbolSlab::Builder
SymbolSlab::Builder is a mutable container that can &#39;freeze&#39; to SymbolSlab.
Definition: Symbol.h:199
clang::clangd::Symbol::IncludeHeaderWithReferences
Definition: Symbol.h:87
clang::clangd::Symbol::ID
SymbolID ID
The ID of the symbol.
Definition: Symbol.h:38
llvm::yaml::MappingTraits< Symbol >::mapping
static void mapping(IO &IO, Symbol &Sym)
Definition: YAMLSerialization.cpp:184
clang::clangd::Symbol::SymInfo
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
Definition: Symbol.h:40
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:57
llvm::yaml::MappingTraits< SymbolID >::mapping
static void mapping(IO &IO, SymbolID &ID)
Definition: YAMLSerialization.cpp:295
clang::clangd::Unknown
Definition: FuzzyMatch.h:56
Arena
llvm::BumpPtrAllocator Arena
Definition: Serialization.cpp:194
clang::clangd::Relation::Predicate
RelationKind Predicate
Definition: Relation.h:31
clang::clangd::Symbol::Definition
SymbolLocation Definition
The location of the symbol&#39;s definition, if one was found.
Definition: Symbol.h:47
llvm::yaml::NormalizedSymbolRole::NormalizedSymbolRole
NormalizedSymbolRole(IO &)
Definition: YAMLSerialization.cpp:284
Ctx
Context Ctx
Definition: TUScheduler.cpp:237
clang::clangd::IndexFileIn
Definition: Serialization.h:42
SymbolInfo
clang::find_all_symbols::SymbolInfo SymbolInfo
Definition: FindAllSymbolsMain.cpp:38
llvm::yaml::NormalizedSymbolFlag::NormalizedSymbolFlag
NormalizedSymbolFlag(IO &, Symbol::SymbolFlag F)
Definition: YAMLSerialization.cpp:91
clang::clangd::Symbol::IncludeHeaders
llvm::SmallVector< IncludeHeaderWithReferences, 1 > IncludeHeaders
One Symbol can potentially be included via different headers.
Definition: Symbol.h:111
clang::clangd::Symbol::Flags
SymbolFlag Flags
Definition: Symbol.h:128
llvm::yaml::NormalizedSymbolID::HexString
std::string HexString
Definition: YAMLSerialization.cpp:86
clang::clangd::Symbol::Signature
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list...
Definition: Symbol.h:65
clang::clangd::SymbolLocation::Position
Definition: SymbolLocation.h:32
llvm::yaml::NormalizedFileURI
Definition: YAMLSerialization.cpp:137
clang::clangd::Ref::Location
SymbolLocation Location
The source location where the symbol is named.
Definition: Ref.h:54
llvm::yaml::ScalarEnumerationTraits< SymbolLanguage >::enumeration
static void enumeration(IO &IO, SymbolLanguage &Value)
Definition: YAMLSerialization.cpp:212
clang::clangd::Symbol::Documentation
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
Definition: Symbol.h:76
Relation.h
llvm::yaml::NormalizedRefKind
Definition: YAMLSerialization.cpp:266
llvm::yaml::NormalizedPosition::P
YPosition P
Definition: YAMLSerialization.cpp:134
clang::clangd::Symbol::CanonicalDeclaration
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
Definition: Symbol.h:56
clang::clangd::RelationSlab::Builder::insert
void insert(const Relation &R)
Adds a relation to the slab.
Definition: Relation.h:73
clang::clangd::RefKind
RefKind
Describes the kind of a cross-reference.
Definition: Ref.h:28
Symbols
SymbolSlab Symbols
Definition: SymbolCollectorTests.cpp:295
Pos
Position Pos
Definition: SourceCode.cpp:772
clang::clangd::toYAML
std::string toYAML(const std::pair< SymbolID, llvm::ArrayRef< Ref >> &Data)
Definition: YAMLSerialization.cpp:399
llvm::yaml::NormalizedSymbolFlag::NormalizedSymbolFlag
NormalizedSymbolFlag(IO &)
Definition: YAMLSerialization.cpp:90
llvm::yaml::NormalizedRefKind::NormalizedRefKind
NormalizedRefKind(IO &)
Definition: YAMLSerialization.cpp:267
llvm::yaml::NormalizedSymbolOrigin
Definition: YAMLSerialization.cpp:102
clang::clangd::RelationSlab::Builder
RelationSlab::Builder is a mutable container that can &#39;freeze&#39; to RelationSlab.
Definition: Relation.h:70
clang::clangd::RefSlab::Builder
RefSlab::Builder is a mutable container that can &#39;freeze&#39; to RefSlab.
Definition: Ref.h:93
llvm::yaml::MappingTraits< SymbolLocation >::mapping
static void mapping(IO &IO, SymbolLocation &Value)
Definition: YAMLSerialization.cpp:153
yaml
Definition: ClangDocMain.cpp:92
clang::clangd::SymbolLocation::End
Position End
Definition: SymbolLocation.h:53
Strings
std::vector< llvm::StringRef > Strings
Definition: Serialization.cpp:195
llvm::yaml::NormalizedFileURI::NormalizedFileURI
NormalizedFileURI(IO &)
Definition: YAMLSerialization.cpp:138
llvm::yaml::NormalizedPosition::NormalizedPosition
NormalizedPosition(IO &, const Position &Pos)
Definition: YAMLSerialization.cpp:123
clang::clangd::IndexFileOut::Relations
const RelationSlab * Relations
Definition: Serialization.h:58
clang::clangd::IndexFileIn::Refs
llvm::Optional< RefSlab > Refs
Definition: Serialization.h:44
llvm::yaml::NormalizedPosition::denormalize
Position denormalize(IO &)
Definition: YAMLSerialization.cpp:128
clang::clangd::Symbol::IncludeHeaderWithReferences::IncludeHeader
llvm::StringRef IncludeHeader
This can be either a URI of the header to be #include&#39;d for this symbol, or a literal header quoted w...
Definition: Symbol.h:101
clang::clangd::Symbol
The class presents a C++ symbol, e.g.
Definition: Symbol.h:36
clang::clangd::SymbolLocation::Start
Position Start
The symbol range, using half-open range [Start, End).
Definition: SymbolLocation.h:52
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
llvm::yaml::NormalizedFileURI::URI
std::string URI
Definition: YAMLSerialization.cpp:149
Line
int Line
Definition: PreprocessorTracker.cpp:526
clang::clangd::Symbol::Name
llvm::StringRef Name
The unqualified name of the symbol, e.g. "bar" (for ns::bar).
Definition: Symbol.h:42
llvm::yaml::MappingTraits< RefBundle >::mapping
static void mapping(IO &IO, RefBundle &Refs)
Definition: YAMLSerialization.cpp:258
llvm::yaml::NormalizedRefKind::denormalize
RefKind denormalize(IO &)
Definition: YAMLSerialization.cpp:270
llvm::yaml::NormalizedSymbolID::NormalizedSymbolID
NormalizedSymbolID(IO &, const SymbolID &ID)
Definition: YAMLSerialization.cpp:72
llvm::yaml::NormalizedSymbolOrigin::NormalizedSymbolOrigin
NormalizedSymbolOrigin(IO &, SymbolOrigin O)
Definition: YAMLSerialization.cpp:104
SymbolOrigin.h
llvm::yaml::MappingTraits< VariantEntry >::mapping
static void mapping(IO &IO, VariantEntry &Variant)
Definition: YAMLSerialization.cpp:312
clang::clangd::RefSlab::Builder::insert
void insert(const SymbolID &ID, const Ref &S)
Adds a ref to the slab. Deep copy: Strings will be owned by the slab.
Definition: Ref.cpp:35
llvm::yaml::NormalizedSymbolRole::denormalize
RelationKind denormalize(IO &IO)
Definition: YAMLSerialization.cpp:289
clang::clangd::SymbolLocation::Position::line
uint32_t line() const
Definition: SymbolLocation.h:35
llvm::yaml::NormalizedSymbolID::NormalizedSymbolID
NormalizedSymbolID(IO &)
Definition: YAMLSerialization.cpp:71
clang::clangd::IndexFileOut
Definition: Serialization.h:55
clang::clangd::Symbol::CompletionSnippetSuffix
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
Definition: Symbol.h:74
DEFINE_ENUM
#define DEFINE_ENUM(name)
Refs
RefSlab Refs
Definition: SymbolCollectorTests.cpp:296
llvm::yaml::NormalizedSymbolRole
Definition: YAMLSerialization.cpp:283
llvm::yaml::MappingTraits< YPosition >::mapping
static void mapping(IO &IO, YPosition &Value)
Definition: YAMLSerialization.cpp:114
clang::clangd::Relation::Subject
SymbolID Subject
Definition: Relation.h:30
clang::clangd::Symbol::Type
llvm::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
Definition: Symbol.h:85
clang::clangd::Symbol::Origin
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.
Definition: Symbol.h:61
llvm::yaml::NormalizedPosition
Definition: YAMLSerialization.cpp:120
llvm::yaml::NormalizedFileURI::NormalizedFileURI
NormalizedFileURI(IO &, const char *FileURI)
Definition: YAMLSerialization.cpp:139
llvm::yaml::NormalizedSymbolRole::NormalizedSymbolRole
NormalizedSymbolRole(IO &IO, RelationKind R)
Definition: YAMLSerialization.cpp:285
clang::clangd::SymbolOrigin
SymbolOrigin
Definition: SymbolOrigin.h:21
clang::clangd::Symbol::TemplateSpecializationArgs
llvm::StringRef TemplateSpecializationArgs
Argument list in human-readable format, will be displayed to help disambiguate between different spec...
Definition: Symbol.h:69
clang::clangd::SymbolLocation::FileURI
const char * FileURI
Definition: SymbolLocation.h:63
clang::clangd::Symbol::ReturnType
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
Definition: Symbol.h:80
clang::doc::SymbolID
std::array< uint8_t, 20 > SymbolID
Definition: Representation.h:30
llvm::yaml::NormalizedSymbolID::denormalize
SymbolID denormalize(IO &I)
Definition: YAMLSerialization.cpp:77
llvm::yaml::MappingTraits< Relation >::mapping
static void mapping(IO &IO, Relation &Relation)
Definition: YAMLSerialization.cpp:302
Entry
Definition: Modularize.cpp:429
clang::clangd::Ref::Kind
RefKind Kind
Definition: Ref.h:55
llvm::yaml::NormalizedSymbolOrigin::denormalize
SymbolOrigin denormalize(IO &)
Definition: YAMLSerialization.cpp:108
llvm::yaml::NormalizedRefKind::NormalizedRefKind
NormalizedRefKind(IO &, RefKind O)
Definition: YAMLSerialization.cpp:268
llvm::yaml::NormalizedSymbolFlag
Definition: YAMLSerialization.cpp:89
SymbolLocation.h
clang::clangd::SymbolID
Definition: SymbolID.h:31