clang-tools 23.0.0git
Representation.h
Go to the documentation of this file.
1///===-- Representation.h - ClangDoc Representation -------------*- 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// This file defines the internal representations of different declaration
10// types for the clang-doc tool.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H
15#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H
16
17#include "clang/AST/Type.h"
18#include "clang/Basic/Diagnostic.h"
19#include "clang/Basic/Specifiers.h"
20#include "clang/Tooling/Execution.h"
21#include "llvm/ADT/SmallString.h"
22#include "llvm/ADT/SmallVector.h"
23#include <array>
24#include <memory>
25#include <optional>
26#include <string>
27
28namespace clang {
29namespace doc {
30
31// An abstraction for owned pointers. Initially mapped to OwnedPtr,
32// to be eventually transitioned to bare pointers in an arena.
33template <typename T> using OwnedPtr = std::unique_ptr<T>;
34
35// An abstraction for vectors that are populated and read sequentially.
36// To be eventually transitioned to llvm::ArrayRef for arena storage.
37template <typename T> using OwningArray = std::vector<T>;
38
39// An abstraction for lists that are dynamically managed (inserted/removed).
40// To be eventually transitioned to llvm::simple_ilist.
41template <typename T> using OwningVec = std::vector<T>;
42
43// An abstraction for dynamic lists of owned pointers.
44// To be eventually transitioned to llvm::simple_ilist<T*> or similar.
45template <typename T> using OwningPtrVec = std::vector<OwnedPtr<T>>;
46
47// An abstraction for arrays of owned pointers.
48// To be eventually transitioned to arena-allocated arrays of bare pointers.
49template <typename T> using OwningPtrArray = std::vector<OwnedPtr<T>>;
50
51// A helper function to create an owned pointer, abstracting away the memory
52// allocation mechanism.
53template <typename T, typename... Args>
54OwnedPtr<T> allocatePtr(Args &&...args) {
55 return std::make_unique<T>(std::forward<Args>(args)...);
56}
57
58// A helper function to access the underlying pointer from an owned pointer,
59// abstracting away the pointer dereferencing mechanism.
60template <typename T> T *getPtr(const OwnedPtr<T> &O) { return O.get(); }
61
62// SHA1'd hash of a USR.
63using SymbolID = std::array<uint8_t, 20>;
64
65constexpr SymbolID GlobalNamespaceID = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
67
68struct BaseRecordInfo;
69struct EnumInfo;
70struct FunctionInfo;
71struct Info;
72struct TypedefInfo;
73struct ConceptInfo;
74struct VarInfo;
75
87
103
105
106CommentKind stringToCommentKind(llvm::StringRef KindStr);
107llvm::StringRef commentKindToString(CommentKind Kind);
108
109// A representation of a parsed comment.
111 CommentInfo() = default;
112 CommentInfo(CommentInfo &Other) = delete;
113 CommentInfo(CommentInfo &&Other) = default;
114 CommentInfo &operator=(CommentInfo &&Other) = default;
115
116 bool operator==(const CommentInfo &Other) const;
117
118 // This operator is used to sort a vector of CommentInfos.
119 // No specific order (attributes more important than others) is required. Any
120 // sort is enough, the order is only needed to call std::unique after sorting
121 // the vector.
122 bool operator<(const CommentInfo &Other) const;
123
125 Children; // List of child comments for this CommentInfo.
126 SmallString<8> Direction; // Parameter direction (for (T)ParamCommand).
127 SmallString<16> Name; // Name of the comment (for Verbatim and HTML).
128 SmallString<16> ParamName; // Parameter name (for (T)ParamCommand).
129 SmallString<16> CloseName; // Closing tag name (for VerbatimBlock).
130 SmallString<64> Text; // Text of the comment.
131 llvm::SmallVector<SmallString<16>, 4>
132 AttrKeys; // List of attribute keys (for HTML).
133 llvm::SmallVector<SmallString<16>, 4>
134 AttrValues; // List of attribute values for each key (for HTML).
135 llvm::SmallVector<SmallString<16>, 4>
136 Args; // List of arguments to commands (for InlineCommand).
137 CommentKind Kind = CommentKind::
138 CK_Unknown; // Kind of comment (FullComment, ParagraphComment,
139 // TextComment, InlineCommandComment, HTMLStartTagComment,
140 // HTMLEndTagComment, BlockCommandComment,
141 // ParamCommandComment, TParamCommandComment,
142 // VerbatimBlockComment, VerbatimBlockLineComment,
143 // VerbatimLineComment).
144 bool SelfClosing = false; // Indicates if tag is self-closing (for HTML).
145 bool Explicit = false; // Indicates if the direction of a param is explicit
146 // (for (T)ParamCommand).
147};
148
149struct Reference {
150 // This variant (that takes no qualified name parameter) uses the Name as the
151 // QualName (very useful in unit tests to reduce verbosity). This can't use an
152 // empty string to indicate the default because we need to accept the empty
153 // string as a valid input for the global namespace (it will have
154 // "GlobalNamespace" as the name, but an empty QualName).
155 Reference(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
157 : USR(USR), RefType(IT), Name(Name), QualName(Name) {}
158 Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName,
159 StringRef Path = StringRef())
160 : USR(USR), RefType(IT), Name(Name), QualName(QualName), Path(Path) {}
161 Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName,
162 StringRef Path, SmallString<16> DocumentationFileName)
165
166 bool operator==(const Reference &Other) const {
167 return std::tie(USR, Name, QualName, RefType) ==
168 std::tie(Other.USR, Other.Name, QualName, Other.RefType);
169 }
170
171 bool mergeable(const Reference &Other);
172 void merge(Reference &&I);
173 bool operator<(const Reference &Other) const { return Name < Other.Name; }
174
175 /// Returns the path for this Reference relative to CurrentPath.
176 llvm::SmallString<64> getRelativeFilePath(const StringRef &CurrentPath) const;
177
178 /// Returns the basename that should be used for this Reference.
179 llvm::SmallString<16> getFileBaseName() const;
180
181 SymbolID USR = SymbolID(); // Unique identifier for referenced decl
182
183 InfoType RefType = InfoType::IT_default; // Indicates the type of this
184 // Reference (namespace, record,
185 // function, enum, default).
186
187 // Name of type (possibly unresolved). Not including namespaces or template
188 // parameters (so for a std::vector<int> this would be "vector"). See also
189 // QualName.
190 SmallString<16> Name;
191
192 // Full qualified name of this type, including namespaces and template
193 // parameter (for example this could be "std::vector<int>"). Contrast to
194 // Name.
195 SmallString<16> QualName;
196
197 // Path of directory where the clang-doc generated file will be saved
198 // (possibly unresolved)
199 llvm::SmallString<128> Path;
200 SmallString<16> DocumentationFileName;
201};
202
203// A Context is a reference that holds a relative path from a certain Info's
204// location.
205struct Context : public Reference {
206 Context(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName,
207 StringRef Path, SmallString<16> DocumentationFileName)
209 explicit Context(const Info &I);
210 SmallString<128> RelativePath;
211};
212
213// Holds the children of a record or namespace.
215 // Namespaces and Records are references because they will be properly
216 // documented in their own info, while the entirety of Functions and Enums are
217 // included here because they should not have separate documentation from
218 // their scope.
219 //
220 // Namespaces are not syntactically valid as children of records, but making
221 // this general for all possible container types reduces code complexity.
229
230 void sort();
231};
232
233// A base struct for TypeInfos
234struct TypeInfo {
235 TypeInfo() = default;
236 TypeInfo(const Reference &R) : Type(R) {}
237
238 // Convenience constructor for when there is no symbol ID or info type
239 // (normally used for built-in types in tests).
240 TypeInfo(StringRef Name, StringRef Path = StringRef())
241 : Type(SymbolID(), Name, InfoType::IT_default, Name, Path) {}
242
243 bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }
244
245 Reference Type; // Referenced type in this info.
246
247 bool IsTemplate = false;
248 bool IsBuiltIn = false;
249};
250
251// Represents one template parameter.
252//
253// This is a very simple serialization of the text of the source code of the
254// template parameter. It is saved in a struct so there is a place to add the
255// name and default values in the future if needed.
257 TemplateParamInfo() = default;
258 explicit TemplateParamInfo(StringRef Contents) : Contents(Contents) {}
259
260 // The literal contents of the code for that specifies this template parameter
261 // for this declaration. Typical values will be "class T" and
262 // "typename T = int".
263 SmallString<16> Contents;
264};
265
267 // Indicates the declaration that this specializes.
269
270 // Template parameters applying to the specialized record/function.
272};
273
275 ConstraintInfo() = default;
276 ConstraintInfo(SymbolID USR, StringRef Name)
277 : ConceptRef(USR, Name, InfoType::IT_concept) {}
279
280 SmallString<16> ConstraintExpr;
281};
282
283// Records the template information for a struct or function that is a template
284// or an explicit template specialization.
286 // May be empty for non-partial specializations.
288
289 // Set when this is a specialization of another record/function.
290 std::optional<TemplateSpecializationInfo> Specialization;
292};
293
294// Info for field types.
295struct FieldTypeInfo : public TypeInfo {
296 FieldTypeInfo() = default;
297 FieldTypeInfo(const TypeInfo &TI, StringRef Name = StringRef(),
298 StringRef DefaultValue = StringRef())
300
301 bool operator==(const FieldTypeInfo &Other) const {
302 return std::tie(Type, Name, DefaultValue) ==
303 std::tie(Other.Type, Other.Name, Other.DefaultValue);
304 }
305
306 SmallString<16> Name; // Name associated with this info.
307
308 // When used for function parameters, contains the string representing the
309 // expression of the default value, if any.
310 SmallString<16> DefaultValue;
311};
312
313// Info for member types.
315 MemberTypeInfo() = default;
316 MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access,
317 bool IsStatic = false)
319
320 bool operator==(const MemberTypeInfo &Other) const {
321 return std::tie(Type, Name, Access, IsStatic, Description) ==
322 std::tie(Other.Type, Other.Name, Other.Access, Other.IsStatic,
323 Other.Description);
324 }
325
327
328 // Access level associated with this info (public, protected, private, none).
329 // AS_public is set as default because the bitcode writer requires the enum
330 // with value 0 to be used as the default.
331 // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
332 AccessSpecifier Access = AccessSpecifier::AS_public;
333 bool IsStatic = false;
334};
335
336struct Location {
341
342 bool operator==(const Location &Other) const {
343 return std::tie(StartLineNumber, EndLineNumber, Filename) ==
344 std::tie(Other.StartLineNumber, Other.EndLineNumber, Other.Filename);
345 }
346
347 bool operator!=(const Location &Other) const { return !(*this == Other); }
348
349 // This operator is used to sort a vector of Locations.
350 // No specific order (attributes more important than others) is required. Any
351 // sort is enough, the order is only needed to call std::unique after sorting
352 // the vector.
353 bool operator<(const Location &Other) const {
354 return std::tie(StartLineNumber, EndLineNumber, Filename) <
355 std::tie(Other.StartLineNumber, Other.EndLineNumber, Other.Filename);
356 }
357
358 SmallString<32> Filename;
361 bool IsFileInRootDir = false;
362};
363
364/// A base struct for Infos.
365struct Info {
367 StringRef Name = StringRef(), StringRef Path = StringRef())
368 : Path(Path), Name(Name), USR(USR), IT(IT) {}
369
370 Info(const Info &Other) = delete;
371 Info(Info &&Other) = default;
372 virtual ~Info() = default;
373
374 Info &operator=(Info &&Other) = default;
375
376 void mergeBase(Info &&I);
377 bool mergeable(const Info &Other);
378
379 llvm::SmallString<16> extractName() const;
380
381 /// Returns the file path for this Info relative to CurrentPath.
382 llvm::SmallString<64> getRelativeFilePath(const StringRef &CurrentPath) const;
383
384 /// Returns the basename that should be used for this Info.
385 llvm::SmallString<16> getFileBaseName() const;
386
387 // Path of directory where the clang-doc generated file will be saved.
388 llvm::SmallString<128> Path;
389
390 // Unqualified name of the decl.
391 SmallString<16> Name;
392
393 // The name used for the file that this info is documented in.
394 // In the JSON generator, infos are documented in files with mangled names.
395 // Thus, we keep track of the physical filename for linking purposes.
396 SmallString<16> DocumentationFileName;
397
398 // List of parent namespaces for this decl.
399 llvm::SmallVector<Reference, 4> Namespace;
400
401 // Unique identifier for the decl described by this Info.
403
404 // Currently only used for namespaces and records.
406
407 // InfoType of this particular Info.
409
410 // Comment description of this decl.
412
413 SmallVector<Context, 4> Contexts;
414};
415
416inline Context::Context(const Info &I)
417 : Reference(I.USR, I.Name, I.IT, I.Name, I.Path, I.DocumentationFileName) {}
418
419// Info for namespaces.
420struct NamespaceInfo : public Info {
421 NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
422 StringRef Path = StringRef());
423
424 void merge(NamespaceInfo &&I);
425
427};
428
429// Info for symbols.
430struct SymbolInfo : public Info {
432 StringRef Name = StringRef(), StringRef Path = StringRef())
433 : Info(IT, USR, Name, Path) {}
434
435 void merge(SymbolInfo &&I);
436
437 bool operator<(const SymbolInfo &Other) const {
438 // Sort by declaration location since we want the doc to be
439 // generated in the order of the source code.
440 // If the declaration location is the same, or not present
441 // we sort by defined location otherwise fallback to the extracted name
442 if (Loc.size() > 0 && Other.Loc.size() > 0 && Loc[0] != Other.Loc[0])
443 return Loc[0] < Other.Loc[0];
444
445 if (DefLoc && Other.DefLoc && *DefLoc != *Other.DefLoc)
446 return *DefLoc < *Other.DefLoc;
447
448 return extractName() < Other.extractName();
449 }
450
451 std::optional<Location> DefLoc; // Location where this decl is defined.
452 llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.
453 SmallString<16> MangledName;
454 bool IsStatic = false;
455};
456
461 const StringRef Name = StringRef())
462 : SymbolInfo(IT, USR, Name) {}
463 bool mergeable(const FriendInfo &Other);
464 void merge(FriendInfo &&Other);
465
467 std::optional<TemplateInfo> Template;
468 std::optional<TypeInfo> ReturnType;
469 std::optional<SmallVector<FieldTypeInfo, 4>> Params;
470 bool IsClass = false;
471};
472
481
482// TODO: Expand to allow for documenting templating and default args.
483// Info for functions.
484struct FunctionInfo : public SymbolInfo {
487
488 void merge(FunctionInfo &&I);
489
492 llvm::SmallVector<FieldTypeInfo, 4> Params;
493 SmallString<256> Prototype;
494
495 // When present, this function is a template or specialization.
496 std::optional<TemplateInfo> Template;
497
498 // Access level for this method (public, private, protected, none).
499 // AS_public is set as default because the bitcode writer requires the enum
500 // with value 0 to be used as the default.
501 // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
502 AccessSpecifier Access = AccessSpecifier::AS_public;
503
504 bool IsMethod = false;
505};
506
507// TODO: Expand to allow for documenting templating, inheritance access,
508// friend classes
509// Info for types.
510struct RecordInfo : public SymbolInfo {
511 RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
512 StringRef Path = StringRef());
513
514 void merge(RecordInfo &&I);
515
516 // Type of this record (struct, class, union, interface).
517 TagTypeKind TagType = TagTypeKind::Struct;
518
519 // Indicates if the record was declared using a typedef. Things like anonymous
520 // structs in a typedef:
521 // typedef struct { ... } foo_t;
522 // are converted into records with the typedef as the Name + this flag set.
523 bool IsTypeDef = false;
524
525 // When present, this record is a template or specialization.
526 std::optional<TemplateInfo> Template;
527
528 llvm::SmallVector<MemberTypeInfo, 4>
529 Members; // List of info about record members.
530 llvm::SmallVector<Reference, 4> Parents; // List of base/parent records
531 // (does not include virtual
532 // parents).
533 llvm::SmallVector<Reference, 4>
534 VirtualParents; // List of virtual base/parent records.
535
536 OwningVec<BaseRecordInfo> Bases; // List of base/parent records; this includes
537 // inherited methods and attributes
538
540
542};
543
544// Info for typedef and using statements.
545struct TypedefInfo : public SymbolInfo {
548
549 void merge(TypedefInfo &&I);
550
552
553 // Only type aliases can be templates.
554 std::optional<TemplateInfo> Template;
555
556 // Underlying type declaration
557 SmallString<16> TypeDeclaration;
558
559 // Indicates if this is a new C++ "using"-style typedef:
560 // using MyVector = std::vector<int>
561 // False means it's a C-style typedef:
562 // typedef std::vector<int> MyVector;
563 bool IsUsing = false;
564};
565
566struct BaseRecordInfo : public RecordInfo {
568 BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual,
569 AccessSpecifier Access, bool IsParent);
570
571 // Access level associated with this inherited info (public, protected,
572 // private).
573 AccessSpecifier Access = AccessSpecifier::AS_public;
574 // Indicates if base corresponds to a virtual inheritance
575 bool IsVirtual = false;
576 bool IsParent = false; // Indicates if this base is a direct parent
577};
578
579// Information for a single possible value of an enumeration.
581 explicit EnumValueInfo(StringRef Name = StringRef(),
582 StringRef Value = StringRef("0"),
583 StringRef ValueExpr = StringRef())
585
586 bool operator==(const EnumValueInfo &Other) const {
587 return std::tie(Name, Value, ValueExpr) ==
588 std::tie(Other.Name, Other.Value, Other.ValueExpr);
589 }
590
591 SmallString<16> Name;
592
593 // The computed value of the enumeration constant. This could be the result of
594 // evaluating the ValueExpr, or it could be automatically generated according
595 // to C rules.
596 SmallString<16> Value;
597
598 // Stores the user-supplied initialization expression for this enumeration
599 // constant. This will be empty for implicit enumeration values.
600 SmallString<16> ValueExpr;
601
602 /// Comment description of this field.
604};
605
606// TODO: Expand to allow for documenting templating.
607// Info for types.
608struct EnumInfo : public SymbolInfo {
611
612 void merge(EnumInfo &&I);
613
614 // Indicates whether this enum is scoped (e.g. enum class).
615 bool Scoped = false;
616
617 // Set to nonempty to the type when this is an explicitly typed enum. For
618 // enum Foo : short { ... };
619 // this will be "short".
620 std::optional<TypeInfo> BaseType;
621
622 llvm::SmallVector<EnumValueInfo, 4> Members; // List of enum members.
623};
624
635
636struct Index : public Reference {
637 Index() = default;
638 Index(StringRef Name) : Reference(SymbolID(), Name) {}
641 Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
642 : Reference(USR, Name, IT, Name, Path) {}
643 // This is used to look for a USR in a vector of Indexes using std::find
644 bool operator==(const SymbolID &Other) const { return USR == Other; }
645 bool operator<(const Index &Other) const;
646
647 std::optional<SmallString<16>> JumpToSection;
648 llvm::StringMap<Index> Children;
649
651 void sort();
652};
653
654// TODO: Add functionality to include separate markdown pages.
655
656// A standalone function to call to merge a vector of infos into one.
657// This assumes that all infos in the vector are of the same type, and will fail
658// if they are different.
659llvm::Expected<OwnedPtr<Info>> mergeInfos(OwningPtrArray<Info> &Values);
660
662 ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
663 bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot,
664 StringRef RepositoryUrl, StringRef RepositoryCodeLinePrefix,
665 StringRef Base, std::vector<std::string> UserStylesheets,
666 clang::DiagnosticsEngine &Diags, OutputFormatTy Format,
667 bool FTimeTrace = false);
668 tooling::ExecutionContext *ECtx;
669 std::string ProjectName; // Name of project clang-doc is documenting.
670 std::string OutDirectory; // Directory for outputting generated files.
671 std::string SourceRoot; // Directory where processed files are stored. Links
672 // to definition locations will only be generated if
673 // the file is in this dir.
674 // URL of repository that hosts code used for links to definition locations.
675 std::optional<std::string> RepositoryUrl;
676 // Prefix of line code for repository.
677 std::optional<std::string> RepositoryLinePrefix;
678 // Path of CSS stylesheets that will be copied to OutDirectory and used to
679 // style all HTML files.
680 std::vector<std::string> UserStylesheets;
681 // JavaScript files that will be imported in all HTML files.
682 std::vector<std::string> JsScripts;
683 // Base directory for remote repositories.
684 StringRef Base;
685 // Maps mustache template types to specific mustache template files.
686 // Ex. comment-template -> /path/to/comment-template.mustache
687 llvm::StringMap<std::string> MustacheTemplates;
688 // A pointer to a DiagnosticsEngine for error reporting.
689 clang::DiagnosticsEngine &Diags;
692 int Granularity; // Granularity of ftime trace
693 bool PublicOnly; // Indicates if only public declarations are documented.
694 bool FTimeTrace; // Indicates if ftime trace is turned on
695};
696
697} // namespace doc
698} // namespace clang
699
700#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H
static llvm::cl::opt< std::string > RepositoryCodeLinePrefix("repository-line-prefix", llvm::cl::desc("Prefix of line code for repository."), llvm::cl::cat(ClangDocCategory))
std::vector< T > OwningArray
std::vector< OwnedPtr< T > > OwningPtrVec
llvm::Expected< OwnedPtr< Info > > mergeInfos(OwningPtrArray< Info > &Values)
std::unique_ptr< T > OwnedPtr
T * getPtr(const OwnedPtr< T > &O)
CommentKind stringToCommentKind(llvm::StringRef KindStr)
std::vector< OwnedPtr< T > > OwningPtrArray
std::vector< T > OwningVec
constexpr SymbolID GlobalNamespaceID
OwnedPtr< T > allocatePtr(Args &&...args)
std::array< uint8_t, 20 > SymbolID
llvm::StringRef commentKindToString(CommentKind Kind)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::optional< std::string > RepositoryUrl
std::vector< std::string > UserStylesheets
ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName, bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot, StringRef RepositoryUrl, StringRef RepositoryCodeLinePrefix, StringRef Base, std::vector< std::string > UserStylesheets, clang::DiagnosticsEngine &Diags, OutputFormatTy Format, bool FTimeTrace=false)
llvm::StringMap< std::string > MustacheTemplates
std::vector< std::string > JsScripts
tooling::ExecutionContext * ECtx
clang::DiagnosticsEngine & Diags
std::optional< std::string > RepositoryLinePrefix
SmallString< 8 > Direction
CommentInfo(CommentInfo &Other)=delete
CommentInfo & operator=(CommentInfo &&Other)=default
bool operator<(const CommentInfo &Other) const
llvm::SmallVector< SmallString< 16 >, 4 > AttrValues
SmallString< 16 > CloseName
CommentInfo(CommentInfo &&Other)=default
bool operator==(const CommentInfo &Other) const
SmallString< 16 > Name
SmallString< 64 > Text
OwningPtrVec< CommentInfo > Children
llvm::SmallVector< SmallString< 16 >, 4 > AttrKeys
llvm::SmallVector< SmallString< 16 >, 4 > Args
SmallString< 16 > ParamName
void merge(ConceptInfo &&I)
SmallString< 16 > ConstraintExpression
SmallString< 16 > ConstraintExpr
ConstraintInfo(SymbolID USR, StringRef Name)
Context(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName, StringRef Path, SmallString< 16 > DocumentationFileName)
SmallString< 128 > RelativePath
llvm::SmallVector< EnumValueInfo, 4 > Members
void merge(EnumInfo &&I)
std::optional< TypeInfo > BaseType
OwningVec< CommentInfo > Description
Comment description of this field.
bool operator==(const EnumValueInfo &Other) const
SmallString< 16 > ValueExpr
EnumValueInfo(StringRef Name=StringRef(), StringRef Value=StringRef("0"), StringRef ValueExpr=StringRef())
FieldTypeInfo(const TypeInfo &TI, StringRef Name=StringRef(), StringRef DefaultValue=StringRef())
bool operator==(const FieldTypeInfo &Other) const
SmallString< 16 > DefaultValue
FriendInfo(const InfoType IT, const SymbolID &USR, const StringRef Name=StringRef())
std::optional< TypeInfo > ReturnType
void merge(FriendInfo &&Other)
std::optional< SmallVector< FieldTypeInfo, 4 > > Params
std::optional< TemplateInfo > Template
bool mergeable(const FriendInfo &Other)
FunctionInfo(SymbolID USR=SymbolID())
llvm::SmallVector< FieldTypeInfo, 4 > Params
void merge(FunctionInfo &&I)
std::optional< TemplateInfo > Template
SmallString< 256 > Prototype
OwningVec< const Index * > getSortedChildren() const
Index(StringRef Name, StringRef JumpToSection)
std::optional< SmallString< 16 > > JumpToSection
bool operator<(const Index &Other) const
bool operator==(const SymbolID &Other) const
Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
Index(StringRef Name)
llvm::StringMap< Index > Children
A base struct for Infos.
SmallString< 16 > DocumentationFileName
Info & operator=(Info &&Other)=default
Info(InfoType IT=InfoType::IT_default, SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
bool mergeable(const Info &Other)
OwningVec< CommentInfo > Description
SmallString< 16 > Name
llvm::SmallString< 16 > getFileBaseName() const
Returns the basename that should be used for this Info.
SmallVector< Context, 4 > Contexts
llvm::SmallString< 128 > Path
virtual ~Info()=default
void mergeBase(Info &&I)
llvm::SmallString< 16 > extractName() const
llvm::SmallString< 64 > getRelativeFilePath(const StringRef &CurrentPath) const
Returns the file path for this Info relative to CurrentPath.
Info(Info &&Other)=default
Info(const Info &Other)=delete
llvm::SmallVector< Reference, 4 > Namespace
bool operator==(const Location &Other) const
Location(int StartLineNumber=0, int EndLineNumber=0, StringRef Filename=StringRef(), bool IsFileInRootDir=false)
SmallString< 32 > Filename
bool operator<(const Location &Other) const
bool operator!=(const Location &Other) const
MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access, bool IsStatic=false)
bool operator==(const MemberTypeInfo &Other) const
OwningVec< CommentInfo > Description
NamespaceInfo(SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
void merge(NamespaceInfo &&I)
OwningVec< BaseRecordInfo > Bases
llvm::SmallVector< MemberTypeInfo, 4 > Members
RecordInfo(SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
std::optional< TemplateInfo > Template
llvm::SmallVector< Reference, 4 > VirtualParents
llvm::SmallVector< Reference, 4 > Parents
void merge(RecordInfo &&I)
OwningVec< FriendInfo > Friends
Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName, StringRef Path, SmallString< 16 > DocumentationFileName)
void merge(Reference &&I)
Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName, StringRef Path=StringRef())
Reference(SymbolID USR=SymbolID(), StringRef Name=StringRef(), InfoType IT=InfoType::IT_default)
bool mergeable(const Reference &Other)
SmallString< 16 > QualName
llvm::SmallString< 128 > Path
llvm::SmallString< 64 > getRelativeFilePath(const StringRef &CurrentPath) const
Returns the path for this Reference relative to CurrentPath.
llvm::SmallString< 16 > getFileBaseName() const
Returns the basename that should be used for this Reference.
SmallString< 16 > DocumentationFileName
SmallString< 16 > Name
bool operator<(const Reference &Other) const
bool operator==(const Reference &Other) const
OwningVec< FunctionInfo > Functions
OwningVec< TypedefInfo > Typedefs
OwningVec< EnumInfo > Enums
OwningVec< Reference > Records
OwningVec< Reference > Namespaces
OwningVec< ConceptInfo > Concepts
OwningVec< VarInfo > Variables
SymbolInfo(InfoType IT, SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
bool operator<(const SymbolInfo &Other) const
llvm::SmallVector< Location, 2 > Loc
std::optional< Location > DefLoc
SmallString< 16 > MangledName
void merge(SymbolInfo &&I)
OwningVec< TemplateParamInfo > Params
OwningVec< ConstraintInfo > Constraints
std::optional< TemplateSpecializationInfo > Specialization
TemplateParamInfo(StringRef Contents)
OwningVec< TemplateParamInfo > Params
TypeInfo(StringRef Name, StringRef Path=StringRef())
TypeInfo(const Reference &R)
bool operator==(const TypeInfo &Other) const
void merge(TypedefInfo &&I)
std::optional< TemplateInfo > Template
TypedefInfo(SymbolID USR=SymbolID())
SmallString< 16 > TypeDeclaration
VarInfo(SymbolID USR)
void merge(VarInfo &&I)