clang-tools 23.0.0git
YAMLGenerator.cpp
Go to the documentation of this file.
1//===-- YAMLGenerator.cpp - ClangDoc YAML -----------------------*- 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// Implementation of the YAML generator, converting decl info into YAML output.
9//===----------------------------------------------------------------------===//
10
11#include "Generators.h"
12#include "Representation.h"
13#include "llvm/ADT/STLExtras.h"
14#include "llvm/Support/YAMLTraits.h"
15#include "llvm/Support/raw_ostream.h"
16#include <optional>
17
18using namespace clang::doc;
19
20// These define YAML traits for decoding the listed values within a vector.
21LLVM_YAML_IS_SEQUENCE_VECTOR(FieldTypeInfo)
22LLVM_YAML_IS_SEQUENCE_VECTOR(MemberTypeInfo)
23LLVM_YAML_IS_SEQUENCE_VECTOR(Reference)
24LLVM_YAML_IS_SEQUENCE_VECTOR(Location)
25LLVM_YAML_IS_SEQUENCE_VECTOR(CommentInfo)
26LLVM_YAML_IS_SEQUENCE_VECTOR(FunctionInfo)
27LLVM_YAML_IS_SEQUENCE_VECTOR(EnumInfo)
28LLVM_YAML_IS_SEQUENCE_VECTOR(EnumValueInfo)
29LLVM_YAML_IS_SEQUENCE_VECTOR(TemplateParamInfo)
30LLVM_YAML_IS_SEQUENCE_VECTOR(TypedefInfo)
31LLVM_YAML_IS_SEQUENCE_VECTOR(BaseRecordInfo)
32
33namespace llvm {
34
35template <typename T>
36static bool operator==(const llvm::simple_ilist<T> &LHS,
37 const llvm::simple_ilist<T> &RHS) {
38 auto LIt = LHS.begin(), LEnd = LHS.end();
39 auto RIt = RHS.begin(), REnd = RHS.end();
40 for (; LIt != LEnd && RIt != REnd; ++LIt, ++RIt) {
41 if (!(*LIt == *RIt))
42 return false;
43 }
44 return LIt == LEnd && RIt == REnd;
45}
46
47template <typename T>
48static bool operator!=(const llvm::simple_ilist<T> &LHS,
49 const llvm::simple_ilist<T> &RHS) {
50 return !(LHS == RHS);
51}
52
53namespace yaml {
54
55// Provide SequenceTraits for ArrayRef<T*> since YAMLTraits only provides it for
56// MutableArrayRef
57template <typename T> struct SequenceTraits<ArrayRef<T *>> {
58 static size_t size(IO &io, ArrayRef<T *> &seq) { return seq.size(); }
59 static T *&element(IO &io, ArrayRef<T *> &seq, size_t index) {
60 // ArrayRef is not mutable, but YAML output only reads the value.
61 return const_cast<T *&>(seq[index]);
62 }
63};
64
65template <typename T> struct SequenceTraits<llvm::simple_ilist<T>> {
66 static size_t size(IO &io, llvm::simple_ilist<T> &seq) { return seq.size(); }
67 static T &element(IO &io, llvm::simple_ilist<T> &seq, size_t index) {
68 return *std::next(seq.begin(), index);
69 }
70};
71
72template <typename T> struct SequenceTraits<clang::doc::DocList<T>> {
73 static size_t size(IO &io, clang::doc::DocList<T> &seq) { return seq.size(); }
74 static T &element(IO &io, clang::doc::DocList<T> &seq, size_t index) {
75 return *(std::next(seq.begin(), index));
76 }
77};
78
79// Map pointers to the value mappings as clang-doc only does output
80// serialization.
81template <typename T> struct PointerMappingTraits {
82 static void mapping(IO &IO, T *&Val) {
83 if (Val)
84 MappingTraits<T>::mapping(IO, *Val);
85 }
86};
87
88template <>
89struct MappingTraits<clang::doc::Reference *>
90 : PointerMappingTraits<clang::doc::Reference> {};
91template <>
92struct MappingTraits<clang::doc::CommentInfo *>
93 : PointerMappingTraits<clang::doc::CommentInfo> {};
94template <>
95struct MappingTraits<clang::doc::FunctionInfo *>
96 : PointerMappingTraits<clang::doc::FunctionInfo> {};
97template <>
98struct MappingTraits<clang::doc::EnumInfo *>
99 : PointerMappingTraits<clang::doc::EnumInfo> {};
100template <>
101struct MappingTraits<clang::doc::TemplateParamInfo *>
102 : PointerMappingTraits<clang::doc::TemplateParamInfo> {};
103
104template <typename T> struct SequenceTraits<ArrayRef<T>> {
105 static size_t size(IO &io, llvm::ArrayRef<T> &seq) { return seq.size(); }
106 static T &element(IO &io, llvm::ArrayRef<T> &seq, size_t index) {
107 return const_cast<T &>(seq[index]);
108 }
109};
110
111// Enumerations to YAML output.
112
113template <> struct ScalarEnumerationTraits<clang::AccessSpecifier> {
114 static void enumeration(IO &IO, clang::AccessSpecifier &Value) {
115 IO.enumCase(Value, "Public", clang::AccessSpecifier::AS_public);
116 IO.enumCase(Value, "Protected", clang::AccessSpecifier::AS_protected);
117 IO.enumCase(Value, "Private", clang::AccessSpecifier::AS_private);
118 IO.enumCase(Value, "None", clang::AccessSpecifier::AS_none);
119 }
120};
121
122template <> struct ScalarEnumerationTraits<clang::TagTypeKind> {
123 static void enumeration(IO &IO, clang::TagTypeKind &Value) {
124 IO.enumCase(Value, "Struct", clang::TagTypeKind::Struct);
125 IO.enumCase(Value, "Interface", clang::TagTypeKind::Interface);
126 IO.enumCase(Value, "Union", clang::TagTypeKind::Union);
127 IO.enumCase(Value, "Class", clang::TagTypeKind::Class);
128 IO.enumCase(Value, "Enum", clang::TagTypeKind::Enum);
129 }
130};
131
132template <> struct ScalarEnumerationTraits<InfoType> {
133 static void enumeration(IO &IO, InfoType &Value) {
134 IO.enumCase(Value, "Namespace", InfoType::IT_namespace);
135 IO.enumCase(Value, "Record", InfoType::IT_record);
136 IO.enumCase(Value, "Function", InfoType::IT_function);
137 IO.enumCase(Value, "Enum", InfoType::IT_enum);
138 IO.enumCase(Value, "Default", InfoType::IT_default);
139 }
140};
141
142template <> struct ScalarEnumerationTraits<clang::doc::CommentKind> {
143 static void enumeration(IO &IO, clang::doc::CommentKind &Value) {
144 IO.enumCase(Value, "FullComment", clang::doc::CommentKind::CK_FullComment);
145 IO.enumCase(Value, "ParagraphComment",
147 IO.enumCase(Value, "TextComment", clang::doc::CommentKind::CK_TextComment);
148 IO.enumCase(Value, "InlineCommandComment",
150 IO.enumCase(Value, "HTMLStartTagComment",
152 IO.enumCase(Value, "HTMLEndTagComment",
154 IO.enumCase(Value, "BlockCommandComment",
156 IO.enumCase(Value, "ParamCommandComment",
158 IO.enumCase(Value, "TParamCommandComment",
160 IO.enumCase(Value, "VerbatimBlockComment",
162 IO.enumCase(Value, "VerbatimBlockLineComment",
164 IO.enumCase(Value, "VerbatimLineComment",
166 IO.enumCase(Value, "Unknown", clang::doc::CommentKind::CK_Unknown);
167 }
168};
169
170// Scalars to YAML output.
171
172template <> struct ScalarTraits<SymbolID> {
173
174 static void output(const SymbolID &S, void *, llvm::raw_ostream &OS) {
175 OS << toHex(toStringRef(S));
176 }
177
178 static StringRef input(StringRef Scalar, void *, SymbolID &Value) {
179 if (Scalar.size() != 40)
180 return "Error: Incorrect scalar size for USR.";
181 Value = stringToSymbol(Scalar);
182 return StringRef();
183 }
184
185 static SymbolID stringToSymbol(llvm::StringRef Value) {
186 SymbolID USR;
187 std::string HexString = fromHex(Value);
188 llvm::copy(HexString, USR.begin());
189 return SymbolID(USR);
190 }
191
192 static QuotingType mustQuote(StringRef) { return QuotingType::Single; }
193};
194
195/// A wrapper for StringRef to force YAML traits to single-quote the string.
197 StringRef Ref;
198 QuotedString() = default;
199 explicit QuotedString(StringRef R) : Ref(R) {}
200 explicit operator StringRef() const { return Ref; }
201 bool operator==(const QuotedString &Other) const { return Ref == Other.Ref; }
202};
203
204template <> struct ScalarTraits<QuotedString> {
205 static void output(const QuotedString &S, void *, llvm::raw_ostream &OS) {
206 OS << S.Ref;
207 }
208 static StringRef input(StringRef Scalar, void *, QuotedString &Value) {
209 Value.Ref = Scalar;
210 return StringRef();
211 }
212 static QuotingType mustQuote(StringRef) { return QuotingType::Single; }
213};
214} // end namespace yaml
215} // end namespace llvm
216
217LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::QuotedString)
218
219namespace llvm {
220namespace yaml {
221
222// Helper functions to map infos to YAML.
223
224static void typeInfoMapping(IO &IO, TypeInfo &I) {
225 IO.mapOptional("Type", I.Type, Reference());
226}
227
228static void fieldTypeInfoMapping(IO &IO, FieldTypeInfo &I) {
229 typeInfoMapping(IO, I);
230
231 QuotedString QName(I.Name);
232 IO.mapOptional("Name", QName, QuotedString(StringRef()));
233 if (!IO.outputting())
234 I.Name = QName.Ref;
235
236 QuotedString QDefault(I.DefaultValue);
237 IO.mapOptional("DefaultValue", QDefault, QuotedString(StringRef()));
238 if (!IO.outputting())
239 I.DefaultValue = QDefault.Ref;
240}
241
242static void infoMapping(IO &IO, Info &I) {
243 IO.mapRequired("USR", I.USR);
244
245 QuotedString QName(I.Name);
246 IO.mapOptional("Name", QName, QuotedString(StringRef()));
247 if (!IO.outputting())
248 I.Name = QName.Ref;
249
250 QuotedString QPath(I.Path);
251 IO.mapOptional("Path", QPath, QuotedString(StringRef()));
252 if (!IO.outputting())
253 I.Path = QPath.Ref;
254
255 IO.mapOptional("Namespace", I.Namespace, llvm::SmallVector<Reference, 4>());
256 IO.mapOptional("Description", I.Description);
257}
258
259static void symbolInfoMapping(IO &IO, SymbolInfo &I) {
260 infoMapping(IO, I);
261 IO.mapOptional("DefLocation", I.DefLoc, std::optional<Location>());
262 IO.mapOptional("Location", I.Loc);
263}
264
265static void recordInfoMapping(IO &IO, RecordInfo &I) {
266 symbolInfoMapping(IO, I);
267 IO.mapOptional("TagType", I.TagType);
268 IO.mapOptional("IsTypeDef", I.IsTypeDef, false);
269 IO.mapOptional("Members", I.Members);
270 IO.mapOptional("Bases", I.Bases);
271 IO.mapOptional("Parents", I.Parents, SmallVector<Reference, 4>());
272 IO.mapOptional("VirtualParents", I.VirtualParents,
273 llvm::SmallVector<Reference, 4>());
274 IO.mapOptional("ChildRecords", I.Children.Records);
275 IO.mapOptional("ChildFunctions", I.Children.Functions);
276 IO.mapOptional("ChildEnums", I.Children.Enums);
277 IO.mapOptional("ChildTypedefs", I.Children.Typedefs);
278 IO.mapOptional("Template", I.Template);
279}
280
281static void commentInfoMapping(IO &IO, CommentInfo &I) {
282 IO.mapOptional("Kind", I.Kind, CommentKind::CK_Unknown);
283
284 QuotedString QText(I.Text);
285 IO.mapOptional("Text", QText, QuotedString(StringRef()));
286 if (!IO.outputting())
287 I.Text = QText.Ref;
288
289 QuotedString QName(I.Name);
290 IO.mapOptional("Name", QName, QuotedString(StringRef()));
291 if (!IO.outputting())
292 I.Name = QName.Ref;
293
294 QuotedString QDirection(I.Direction);
295 IO.mapOptional("Direction", QDirection, QuotedString(StringRef()));
296 if (!IO.outputting())
297 I.Direction = QDirection.Ref;
298
299 QuotedString QParamName(I.ParamName);
300 IO.mapOptional("ParamName", QParamName, QuotedString(StringRef()));
301 if (!IO.outputting())
302 I.ParamName = QParamName.Ref;
303
304 QuotedString QCloseName(I.CloseName);
305 IO.mapOptional("CloseName", QCloseName, QuotedString(StringRef()));
306 if (!IO.outputting())
307 I.CloseName = QCloseName.Ref;
308
309 IO.mapOptional("SelfClosing", I.SelfClosing, false);
310 IO.mapOptional("Explicit", I.Explicit, false);
311
312 std::vector<QuotedString> QArgs;
313 if (IO.outputting()) {
314 for (auto &S : I.Args)
315 QArgs.push_back(QuotedString(S));
316 }
317 IO.mapOptional("Args", QArgs, std::vector<QuotedString>());
318
319 std::vector<QuotedString> QAttrKeys;
320 if (IO.outputting()) {
321 for (auto &S : I.AttrKeys)
322 QAttrKeys.push_back(QuotedString(S));
323 }
324 IO.mapOptional("AttrKeys", QAttrKeys, std::vector<QuotedString>());
325
326 std::vector<QuotedString> QAttrValues;
327 if (IO.outputting()) {
328 for (auto &S : I.AttrValues)
329 QAttrValues.push_back(QuotedString(S));
330 }
331 IO.mapOptional("AttrValues", QAttrValues, std::vector<QuotedString>());
332
333 IO.mapOptional("Children", I.Children);
334}
335
336// Template specialization to YAML traits for Infos.
337
338template <> struct MappingTraits<Location> {
339 static void mapping(IO &IO, Location &Loc) {
340 IO.mapOptional("LineNumber", Loc.StartLineNumber, 0);
341
342 QuotedString QFilename(Loc.Filename);
343 IO.mapOptional("Filename", QFilename, QuotedString(StringRef()));
344 if (!IO.outputting())
345 Loc.Filename = QFilename.Ref;
346 }
347};
348
349template <> struct MappingTraits<Reference> {
350 static void mapping(IO &IO, Reference &Ref) {
351 IO.mapOptional("Type", Ref.RefType, InfoType::IT_default);
352
353 QuotedString QName(Ref.Name);
354 IO.mapOptional("Name", QName, QuotedString(StringRef()));
355 if (!IO.outputting())
356 Ref.Name = QName.Ref;
357
358 QuotedString QQualName(Ref.QualName);
359 IO.mapOptional("QualName", QQualName, QuotedString(StringRef()));
360 if (!IO.outputting())
361 Ref.QualName = QQualName.Ref;
362
363 IO.mapOptional("USR", Ref.USR, SymbolID());
364
365 QuotedString QPath(Ref.Path);
366 IO.mapOptional("Path", QPath, QuotedString(StringRef()));
367 if (!IO.outputting())
368 Ref.Path = QPath.Ref;
369 }
370};
371
372template <> struct MappingTraits<TypeInfo> {
373 static void mapping(IO &IO, TypeInfo &I) { typeInfoMapping(IO, I); }
374};
375
376template <> struct MappingTraits<FieldTypeInfo> {
377 static void mapping(IO &IO, FieldTypeInfo &I) {
378 typeInfoMapping(IO, I);
379
380 QuotedString QName(I.Name);
381 IO.mapOptional("Name", QName, QuotedString(StringRef()));
382 if (!IO.outputting())
383 I.Name = QName.Ref;
384
385 QuotedString QDefault(I.DefaultValue);
386 IO.mapOptional("DefaultValue", QDefault, QuotedString(StringRef()));
387 if (!IO.outputting())
388 I.DefaultValue = QDefault.Ref;
389 }
390};
391
392template <> struct MappingTraits<MemberTypeInfo> {
393 static void mapping(IO &IO, MemberTypeInfo &I) {
395 // clang::AccessSpecifier::AS_none is used as the default here because it's
396 // the AS that shouldn't be part of the output. Even though AS_public is the
397 // default in the struct, it should be displayed in the YAML output.
398 IO.mapOptional("Access", I.Access, clang::AccessSpecifier::AS_none);
399 IO.mapOptional("Description", I.Description);
400 }
401};
402
403template <> struct MappingTraits<NamespaceInfo> {
404 static void mapping(IO &IO, NamespaceInfo &I) {
405 infoMapping(IO, I);
406 std::vector<Reference> TempNamespaces;
407 for (const auto &N : I.Children.Namespaces)
408 TempNamespaces.push_back(N);
409 IO.mapOptional("ChildNamespaces", TempNamespaces, std::vector<Reference>());
410 IO.mapOptional("ChildRecords", I.Children.Records);
411 IO.mapOptional("ChildFunctions", I.Children.Functions);
412 IO.mapOptional("ChildEnums", I.Children.Enums);
413 IO.mapOptional("ChildTypedefs", I.Children.Typedefs);
414 }
415};
416
417template <> struct MappingTraits<RecordInfo> {
418 static void mapping(IO &IO, RecordInfo &I) { recordInfoMapping(IO, I); }
419};
420
421template <> struct MappingTraits<BaseRecordInfo> {
422 static void mapping(IO &IO, BaseRecordInfo &I) {
423 recordInfoMapping(IO, I);
424 IO.mapOptional("IsVirtual", I.IsVirtual, false);
425 // clang::AccessSpecifier::AS_none is used as the default here because it's
426 // the AS that shouldn't be part of the output. Even though AS_public is the
427 // default in the struct, it should be displayed in the YAML output.
428 IO.mapOptional("Access", I.Access, clang::AccessSpecifier::AS_none);
429 IO.mapOptional("IsParent", I.IsParent, false);
430 }
431};
432
433template <> struct MappingTraits<EnumValueInfo> {
434 static void mapping(IO &IO, EnumValueInfo &I) {
435 QuotedString QName(I.Name);
436 IO.mapOptional("Name", QName, QuotedString(StringRef()));
437 if (!IO.outputting())
438 I.Name = QName.Ref;
439
440 QuotedString QValue(I.Value);
441 IO.mapOptional("Value", QValue, QuotedString(StringRef()));
442 if (!IO.outputting())
443 I.Value = QValue.Ref;
444
445 QuotedString QExpr(I.ValueExpr);
446 IO.mapOptional("Expr", QExpr, QuotedString(StringRef()));
447 if (!IO.outputting())
448 I.ValueExpr = QExpr.Ref;
449 }
450};
451
452template <> struct MappingTraits<EnumInfo> {
453 static void mapping(IO &IO, EnumInfo &I) {
454 symbolInfoMapping(IO, I);
455 IO.mapOptional("Scoped", I.Scoped, false);
456 IO.mapOptional("BaseType", I.BaseType);
457 IO.mapOptional("Members", I.Members);
458 }
459};
460
461template <> struct MappingTraits<TypedefInfo> {
462 static void mapping(IO &IO, TypedefInfo &I) {
463 symbolInfoMapping(IO, I);
464 IO.mapOptional("Underlying", I.Underlying.Type);
465 IO.mapOptional("IsUsing", I.IsUsing, false);
466 }
467};
468
469template <> struct MappingTraits<FunctionInfo> {
470 static void mapping(IO &IO, FunctionInfo &I) {
471 symbolInfoMapping(IO, I);
472 IO.mapOptional("IsMethod", I.IsMethod, false);
473 IO.mapOptional("Parent", I.Parent, Reference());
474 IO.mapOptional("Params", I.Params);
475 IO.mapOptional("ReturnType", I.ReturnType);
476 // clang::AccessSpecifier::AS_none is used as the default here because it's
477 // the AS that shouldn't be part of the output. Even though AS_public is the
478 // default in the struct, it should be displayed in the YAML output.
479 IO.mapOptional("Access", I.Access, clang::AccessSpecifier::AS_none);
480 IO.mapOptional("Template", I.Template);
481 }
482};
483
484template <> struct MappingTraits<TemplateParamInfo> {
485 static void mapping(IO &IO, TemplateParamInfo &I) {
486 QuotedString QContents(I.Contents);
487 IO.mapOptional("Contents", QContents, QuotedString(StringRef()));
488 if (!IO.outputting())
489 I.Contents = QContents.Ref;
490 }
491};
492
493template <> struct MappingTraits<TemplateSpecializationInfo> {
494 static void mapping(IO &IO, TemplateSpecializationInfo &I) {
495 IO.mapOptional("SpecializationOf", I.SpecializationOf);
496 IO.mapOptional("Params", I.Params);
497 }
498};
499
500template <> struct MappingTraits<TemplateInfo> {
501 static void mapping(IO &IO, TemplateInfo &I) {
502 IO.mapOptional("Params", I.Params);
503 IO.mapOptional("Specialization", I.Specialization,
504 std::optional<TemplateSpecializationInfo>());
505 }
506};
507
508template <> struct MappingTraits<CommentInfo> {
509 static void mapping(IO &IO, CommentInfo &I) { commentInfoMapping(IO, I); }
510};
511
512} // end namespace yaml
513} // end namespace llvm
514
515namespace clang {
516namespace doc {
517
518/// Generator for YAML documentation.
519class YAMLGenerator : public Generator {
520public:
521 static const char *Format;
522
523 llvm::Error generateDocumentation(StringRef RootDir,
524 llvm::StringMap<doc::Info *> Infos,
525 const ClangDocContext &CDCtx,
526 std::string DirName) override;
527 llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
528 const ClangDocContext &CDCtx) override;
529};
530
531const char *YAMLGenerator::Format = "yaml";
532
534 StringRef RootDir, llvm::StringMap<doc::Info *> Infos,
535 const ClangDocContext &CDCtx, std::string DirName) {
536 for (const auto &Group : Infos) {
537 doc::Info *Info = Group.getValue();
538
539 // Output file names according to the USR except the global namesapce.
540 // Anonymous namespaces are taken care of in serialization, so here we can
541 // safely assume an unnamed namespace is the global one.
542 llvm::SmallString<128> Path;
543 llvm::sys::path::native(RootDir, Path);
544 if (Info->IT == InfoType::IT_namespace && Info->Name.empty()) {
545 llvm::sys::path::append(Path, "index.yaml");
546 } else {
547 llvm::sys::path::append(Path, Group.getKey() + ".yaml");
548 }
549
550 std::error_code FileErr;
551 llvm::raw_fd_ostream InfoOS(Path, FileErr, llvm::sys::fs::OF_Text);
552 if (FileErr) {
553 return llvm::createStringError(FileErr, "Error opening file '%s'",
554 Path.c_str());
555 }
556
557 if (llvm::Error Err = generateDocForInfo(Info, InfoOS, CDCtx)) {
558 return Err;
559 }
560 }
561
562 return llvm::Error::success();
563}
564
565llvm::Error YAMLGenerator::generateDocForInfo(Info *I, llvm::raw_ostream &OS,
566 const ClangDocContext &CDCtx) {
567 llvm::yaml::Output InfoYAML(OS);
568 switch (I->IT) {
570 InfoYAML << *static_cast<clang::doc::NamespaceInfo *>(I);
571 break;
573 InfoYAML << *static_cast<clang::doc::RecordInfo *>(I);
574 break;
576 InfoYAML << *static_cast<clang::doc::EnumInfo *>(I);
577 break;
579 InfoYAML << *static_cast<clang::doc::FunctionInfo *>(I);
580 break;
582 InfoYAML << *static_cast<clang::doc::TypedefInfo *>(I);
583 break;
587 break;
589 return llvm::createStringError(llvm::inconvertibleErrorCode(),
590 "unexpected InfoType");
591 }
592 return llvm::Error::success();
593}
594
595static GeneratorRegistry::Add<YAMLGenerator> YAML(YAMLGenerator::Format,
596 "Generator for YAML output.");
597
598// This anchor is used to force the linker to link in the generated object file
599// and thus register the generator.
601
602} // namespace doc
603} // namespace clang
Generator for YAML documentation.
llvm::Error generateDocumentation(StringRef RootDir, llvm::StringMap< doc::Info * > Infos, const ClangDocContext &CDCtx, std::string DirName) override
static const char * Format
llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS, const ClangDocContext &CDCtx) override
llvm::simple_ilist< InfoNode< T > > DocList
static GeneratorRegistry::Add< YAMLGenerator > YAML(YAMLGenerator::Format, "Generator for YAML output.")
volatile int YAMLGeneratorAnchorSource
std::array< uint8_t, 20 > SymbolID
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static void infoMapping(IO &IO, Info &I)
static void commentInfoMapping(IO &IO, CommentInfo &I)
static void fieldTypeInfoMapping(IO &IO, FieldTypeInfo &I)
static void symbolInfoMapping(IO &IO, SymbolInfo &I)
static void typeInfoMapping(IO &IO, TypeInfo &I)
static void recordInfoMapping(IO &IO, RecordInfo &I)
Some operations such as code completion produce a set of candidates.
Definition Generators.h:152
static bool operator!=(const llvm::simple_ilist< T > &LHS, const llvm::simple_ilist< T > &RHS)
static bool operator==(const llvm::simple_ilist< T > &LHS, const llvm::simple_ilist< T > &RHS)
Represents a symbol occurrence in the source file.
Definition Ref.h:88
ArrayRef< StringRef > Args
ArrayRef< CommentInfo > Children
ArrayRef< StringRef > AttrKeys
ArrayRef< StringRef > AttrValues
llvm::ArrayRef< EnumValueInfo > Members
std::optional< TypeInfo > BaseType
llvm::ArrayRef< FieldTypeInfo > Params
std::optional< TemplateInfo > Template
A base struct for Infos.
DocList< CommentInfo > Description
llvm::ArrayRef< Reference > Namespace
DocList< CommentInfo > Description
llvm::ArrayRef< BaseRecordInfo > Bases
llvm::ArrayRef< Reference > VirtualParents
std::optional< TemplateInfo > Template
llvm::ArrayRef< Reference > Parents
llvm::ArrayRef< MemberTypeInfo > Members
DocList< Reference > Records
DocList< EnumInfo > Enums
DocList< FunctionInfo > Functions
DocList< Reference > Namespaces
DocList< TypedefInfo > Typedefs
DocList< Location > Loc
std::optional< Location > DefLoc
llvm::ArrayRef< TemplateParamInfo > Params
std::optional< TemplateSpecializationInfo > Specialization
llvm::ArrayRef< TemplateParamInfo > Params
static void mapping(IO &IO, BaseRecordInfo &I)
static void mapping(IO &IO, CommentInfo &I)
static void mapping(IO &IO, EnumInfo &I)
static void mapping(IO &IO, EnumValueInfo &I)
static void mapping(IO &IO, FieldTypeInfo &I)
static void mapping(IO &IO, FunctionInfo &I)
static void mapping(IO &IO, Location &Loc)
static void mapping(IO &IO, MemberTypeInfo &I)
static void mapping(IO &IO, NamespaceInfo &I)
static void mapping(IO &IO, RecordInfo &I)
static void mapping(IO &IO, Reference &Ref)
static void mapping(IO &IO, TemplateInfo &I)
static void mapping(IO &IO, TemplateParamInfo &I)
static void mapping(IO &IO, TemplateSpecializationInfo &I)
static void mapping(IO &IO, TypeInfo &I)
static void mapping(IO &IO, TypedefInfo &I)
static void mapping(IO &IO, T *&Val)
A wrapper for StringRef to force YAML traits to single-quote the string.
bool operator==(const QuotedString &Other) const
static void enumeration(IO &IO, InfoType &Value)
static void enumeration(IO &IO, clang::AccessSpecifier &Value)
static void enumeration(IO &IO, clang::TagTypeKind &Value)
static void enumeration(IO &IO, clang::doc::CommentKind &Value)
static StringRef input(StringRef Scalar, void *, QuotedString &Value)
static QuotingType mustQuote(StringRef)
static void output(const QuotedString &S, void *, llvm::raw_ostream &OS)
static SymbolID stringToSymbol(llvm::StringRef Value)
static StringRef input(StringRef Scalar, void *, SymbolID &Value)
static void output(const SymbolID &S, void *, llvm::raw_ostream &OS)
static QuotingType mustQuote(StringRef)
static T & element(IO &io, llvm::ArrayRef< T > &seq, size_t index)
static size_t size(IO &io, llvm::ArrayRef< T > &seq)
static size_t size(IO &io, ArrayRef< T * > &seq)
static T *& element(IO &io, ArrayRef< T * > &seq, size_t index)
static T & element(IO &io, clang::doc::DocList< T > &seq, size_t index)
static size_t size(IO &io, clang::doc::DocList< T > &seq)
static T & element(IO &io, llvm::simple_ilist< T > &seq, size_t index)
static size_t size(IO &io, llvm::simple_ilist< T > &seq)