clang-tools 22.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/Specifiers.h"
19#include "clang/Tooling/StandaloneExecution.h"
20#include "llvm/ADT/APSInt.h"
21#include "llvm/ADT/SmallVector.h"
22#include "llvm/ADT/StringExtras.h"
23#include <array>
24#include <optional>
25#include <string>
26
27namespace clang {
28namespace doc {
29
30// SHA1'd hash of a USR.
31using SymbolID = std::array<uint8_t, 20>;
32
33struct BaseRecordInfo;
34struct EnumInfo;
35struct FunctionInfo;
36struct Info;
37struct TypedefInfo;
38struct ConceptInfo;
39struct VarInfo;
40
52
68
69CommentKind stringToCommentKind(llvm::StringRef KindStr);
70llvm::StringRef commentKindToString(CommentKind Kind);
71
72// A representation of a parsed comment.
74 CommentInfo() = default;
75 CommentInfo(CommentInfo &Other) = delete;
76 CommentInfo(CommentInfo &&Other) = default;
77 CommentInfo &operator=(CommentInfo &&Other) = default;
78
79 bool operator==(const CommentInfo &Other) const;
80
81 // This operator is used to sort a vector of CommentInfos.
82 // No specific order (attributes more important than others) is required. Any
83 // sort is enough, the order is only needed to call std::unique after sorting
84 // the vector.
85 bool operator<(const CommentInfo &Other) const;
86
87 CommentKind Kind = CommentKind::
88 CK_Unknown; // Kind of comment (FullComment, ParagraphComment,
89 // TextComment, InlineCommandComment, HTMLStartTagComment,
90 // HTMLEndTagComment, BlockCommandComment,
91 // ParamCommandComment, TParamCommandComment,
92 // VerbatimBlockComment, VerbatimBlockLineComment,
93 // VerbatimLineComment).
94 SmallString<64> Text; // Text of the comment.
95 SmallString<16> Name; // Name of the comment (for Verbatim and HTML).
96 SmallString<8> Direction; // Parameter direction (for (T)ParamCommand).
97 SmallString<16> ParamName; // Parameter name (for (T)ParamCommand).
98 SmallString<16> CloseName; // Closing tag name (for VerbatimBlock).
99 bool SelfClosing = false; // Indicates if tag is self-closing (for HTML).
100 bool Explicit = false; // Indicates if the direction of a param is explicit
101 // (for (T)ParamCommand).
102 llvm::SmallVector<SmallString<16>, 4>
103 AttrKeys; // List of attribute keys (for HTML).
104 llvm::SmallVector<SmallString<16>, 4>
105 AttrValues; // List of attribute values for each key (for HTML).
106 llvm::SmallVector<SmallString<16>, 4>
107 Args; // List of arguments to commands (for InlineCommand).
108 std::vector<std::unique_ptr<CommentInfo>>
109 Children; // List of child comments for this CommentInfo.
110};
111
112struct Reference {
113 // This variant (that takes no qualified name parameter) uses the Name as the
114 // QualName (very useful in unit tests to reduce verbosity). This can't use an
115 // empty string to indicate the default because we need to accept the empty
116 // string as a valid input for the global namespace (it will have
117 // "GlobalNamespace" as the name, but an empty QualName).
118 Reference(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
120 : USR(USR), Name(Name), QualName(Name), RefType(IT) {}
121 Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName,
122 StringRef Path = StringRef())
123 : USR(USR), Name(Name), QualName(QualName), RefType(IT), Path(Path) {}
124 Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef QualName,
125 StringRef Path, SmallString<16> DocumentationFileName)
128
129 bool operator==(const Reference &Other) const {
130 return std::tie(USR, Name, QualName, RefType) ==
131 std::tie(Other.USR, Other.Name, QualName, Other.RefType);
132 }
133
134 bool mergeable(const Reference &Other);
135 void merge(Reference &&I);
136 bool operator<(const Reference &Other) const { return Name < Other.Name; }
137
138 /// Returns the path for this Reference relative to CurrentPath.
139 llvm::SmallString<64> getRelativeFilePath(const StringRef &CurrentPath) const;
140
141 /// Returns the basename that should be used for this Reference.
142 llvm::SmallString<16> getFileBaseName() const;
143
144 SymbolID USR = SymbolID(); // Unique identifier for referenced decl
145
146 // Name of type (possibly unresolved). Not including namespaces or template
147 // parameters (so for a std::vector<int> this would be "vector"). See also
148 // QualName.
149 SmallString<16> Name;
150
151 // Full qualified name of this type, including namespaces and template
152 // parameter (for example this could be "std::vector<int>"). Contrast to
153 // Name.
154 SmallString<16> QualName;
155
156 InfoType RefType = InfoType::IT_default; // Indicates the type of this
157 // Reference (namespace, record,
158 // function, enum, default).
159 // Path of directory where the clang-doc generated file will be saved
160 // (possibly unresolved)
161 llvm::SmallString<128> Path;
162 SmallString<16> DocumentationFileName;
163};
164
165// Holds the children of a record or namespace.
167 // Namespaces and Records are references because they will be properly
168 // documented in their own info, while the entirety of Functions and Enums are
169 // included here because they should not have separate documentation from
170 // their scope.
171 //
172 // Namespaces are not syntactically valid as children of records, but making
173 // this general for all possible container types reduces code complexity.
174 std::vector<Reference> Namespaces;
175 std::vector<Reference> Records;
176 std::vector<FunctionInfo> Functions;
177 std::vector<EnumInfo> Enums;
178 std::vector<TypedefInfo> Typedefs;
179 std::vector<ConceptInfo> Concepts;
180 std::vector<VarInfo> Variables;
181
182 void sort();
183};
184
185// A base struct for TypeInfos
186struct TypeInfo {
187 TypeInfo() = default;
188 TypeInfo(const Reference &R) : Type(R) {}
189
190 // Convenience constructor for when there is no symbol ID or info type
191 // (normally used for built-in types in tests).
192 TypeInfo(StringRef Name, StringRef Path = StringRef())
193 : Type(SymbolID(), Name, InfoType::IT_default, Name, Path) {}
194
195 bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }
196
197 Reference Type; // Referenced type in this info.
198
199 bool IsTemplate = false;
200 bool IsBuiltIn = false;
201};
202
203// Represents one template parameter.
204//
205// This is a very simple serialization of the text of the source code of the
206// template parameter. It is saved in a struct so there is a place to add the
207// name and default values in the future if needed.
209 TemplateParamInfo() = default;
210 explicit TemplateParamInfo(StringRef Contents) : Contents(Contents) {}
211
212 // The literal contents of the code for that specifies this template parameter
213 // for this declaration. Typical values will be "class T" and
214 // "typename T = int".
215 SmallString<16> Contents;
216};
217
219 // Indicates the declaration that this specializes.
221
222 // Template parameters applying to the specialized record/function.
223 std::vector<TemplateParamInfo> Params;
224};
225
227 ConstraintInfo() = default;
228 ConstraintInfo(SymbolID USR, StringRef Name)
229 : ConceptRef(USR, Name, InfoType::IT_concept) {}
231
232 SmallString<16> ConstraintExpr;
233};
234
235// Records the template information for a struct or function that is a template
236// or an explicit template specialization.
238 // May be empty for non-partial specializations.
239 std::vector<TemplateParamInfo> Params;
240
241 // Set when this is a specialization of another record/function.
242 std::optional<TemplateSpecializationInfo> Specialization;
243 std::vector<ConstraintInfo> Constraints;
244};
245
246// Info for field types.
247struct FieldTypeInfo : public TypeInfo {
248 FieldTypeInfo() = default;
249 FieldTypeInfo(const TypeInfo &TI, StringRef Name = StringRef(),
250 StringRef DefaultValue = StringRef())
252
253 bool operator==(const FieldTypeInfo &Other) const {
254 return std::tie(Type, Name, DefaultValue) ==
255 std::tie(Other.Type, Other.Name, Other.DefaultValue);
256 }
257
258 SmallString<16> Name; // Name associated with this info.
259
260 // When used for function parameters, contains the string representing the
261 // expression of the default value, if any.
262 SmallString<16> DefaultValue;
263};
264
265// Info for member types.
267 MemberTypeInfo() = default;
268 MemberTypeInfo(const TypeInfo &TI, StringRef Name, AccessSpecifier Access,
269 bool IsStatic = false)
271
272 bool operator==(const MemberTypeInfo &Other) const {
273 return std::tie(Type, Name, Access, IsStatic, Description) ==
274 std::tie(Other.Type, Other.Name, Other.Access, Other.IsStatic,
275 Other.Description);
276 }
277
278 // Access level associated with this info (public, protected, private, none).
279 // AS_public is set as default because the bitcode writer requires the enum
280 // with value 0 to be used as the default.
281 // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
282 AccessSpecifier Access = AccessSpecifier::AS_public;
283
284 std::vector<CommentInfo> Description; // Comment description of this field.
285 bool IsStatic = false;
286};
287
288struct Location {
293
294 bool operator==(const Location &Other) const {
295 return std::tie(StartLineNumber, EndLineNumber, Filename) ==
296 std::tie(Other.StartLineNumber, Other.EndLineNumber, Other.Filename);
297 }
298
299 bool operator!=(const Location &Other) const { return !(*this == Other); }
300
301 // This operator is used to sort a vector of Locations.
302 // No specific order (attributes more important than others) is required. Any
303 // sort is enough, the order is only needed to call std::unique after sorting
304 // the vector.
305 bool operator<(const Location &Other) const {
306 return std::tie(StartLineNumber, EndLineNumber, Filename) <
307 std::tie(Other.StartLineNumber, Other.EndLineNumber, Other.Filename);
308 }
309
310 int StartLineNumber = 0; // Line number of this Location.
312 SmallString<32> Filename; // File for this Location.
313 bool IsFileInRootDir = false; // Indicates if file is inside root directory
314};
315
316/// A base struct for Infos.
317struct Info {
319 StringRef Name = StringRef(), StringRef Path = StringRef())
320 : USR(USR), IT(IT), Name(Name), Path(Path) {}
321
322 Info(const Info &Other) = delete;
323 Info(Info &&Other) = default;
324
325 virtual ~Info() = default;
326
327 Info &operator=(Info &&Other) = default;
328
330 SymbolID(); // Unique identifier for the decl described by this Info.
331 InfoType IT = InfoType::IT_default; // InfoType of this particular Info.
332 SmallString<16> Name; // Unqualified name of the decl.
333 llvm::SmallVector<Reference, 4>
334 Namespace; // List of parent namespaces for this decl.
335 std::vector<CommentInfo> Description; // Comment description of this decl.
336 llvm::SmallString<128> Path; // Path of directory where the clang-doc
337 // generated file will be saved
338
339 // The name used for the file that this info is documented in.
340 // In the JSON generator, infos are documented in files with mangled names.
341 // Thus, we keep track of the physical filename for linking purposes.
342 SmallString<16> DocumentationFileName;
343
344 void mergeBase(Info &&I);
345 bool mergeable(const Info &Other);
346
347 llvm::SmallString<16> extractName() const;
348
349 /// Returns the file path for this Info relative to CurrentPath.
350 llvm::SmallString<64> getRelativeFilePath(const StringRef &CurrentPath) const;
351
352 /// Returns the basename that should be used for this Info.
353 llvm::SmallString<16> getFileBaseName() const;
354};
355
356// Info for namespaces.
357struct NamespaceInfo : public Info {
358 NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
359 StringRef Path = StringRef());
360
361 void merge(NamespaceInfo &&I);
362
364};
365
366// Info for symbols.
367struct SymbolInfo : public Info {
369 StringRef Name = StringRef(), StringRef Path = StringRef())
370 : Info(IT, USR, Name, Path) {}
371
372 void merge(SymbolInfo &&I);
373
374 bool operator<(const SymbolInfo &Other) const {
375 // Sort by declaration location since we want the doc to be
376 // generated in the order of the source code.
377 // If the declaration location is the same, or not present
378 // we sort by defined location otherwise fallback to the extracted name
379 if (Loc.size() > 0 && Other.Loc.size() > 0 && Loc[0] != Other.Loc[0])
380 return Loc[0] < Other.Loc[0];
381
382 if (DefLoc && Other.DefLoc && *DefLoc != *Other.DefLoc)
383 return *DefLoc < *Other.DefLoc;
384
385 return extractName() < Other.extractName();
386 }
387
388 std::optional<Location> DefLoc; // Location where this decl is defined.
389 llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.
390 SmallString<16> MangledName;
391 bool IsStatic = false;
392};
393
398 const StringRef Name = StringRef())
399 : SymbolInfo(IT, USR, Name) {}
400 bool mergeable(const FriendInfo &Other);
401 void merge(FriendInfo &&Other);
402
404 std::optional<TemplateInfo> Template;
405 std::optional<TypeInfo> ReturnType;
406 std::optional<SmallVector<FieldTypeInfo, 4>> Params;
407 bool IsClass = false;
408};
409
418
419// TODO: Expand to allow for documenting templating and default args.
420// Info for functions.
421struct FunctionInfo : public SymbolInfo {
424
425 void merge(FunctionInfo &&I);
426
427 bool IsMethod = false; // Indicates whether this function is a class method.
428 Reference Parent; // Reference to the parent class decl for this method.
429 TypeInfo ReturnType; // Info about the return type of this function.
430 llvm::SmallVector<FieldTypeInfo, 4> Params; // List of parameters.
431 // Access level for this method (public, private, protected, none).
432 // AS_public is set as default because the bitcode writer requires the enum
433 // with value 0 to be used as the default.
434 // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
435 AccessSpecifier Access = AccessSpecifier::AS_public;
436
437 // Full qualified name of this function, including namespaces and template
438 // specializations.
439 SmallString<16> FullName;
440
441 // Function Prototype
442 SmallString<256> Prototype;
443
444 // When present, this function is a template or specialization.
445 std::optional<TemplateInfo> Template;
446};
447
448// TODO: Expand to allow for documenting templating, inheritance access,
449// friend classes
450// Info for types.
451struct RecordInfo : public SymbolInfo {
452 RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
453 StringRef Path = StringRef());
454
455 void merge(RecordInfo &&I);
456
457 // Type of this record (struct, class, union, interface).
458 TagTypeKind TagType = TagTypeKind::Struct;
459
460 // Full qualified name of this record, including namespaces and template
461 // specializations.
462 SmallString<16> FullName;
463
464 // When present, this record is a template or specialization.
465 std::optional<TemplateInfo> Template;
466
467 // Indicates if the record was declared using a typedef. Things like anonymous
468 // structs in a typedef:
469 // typedef struct { ... } foo_t;
470 // are converted into records with the typedef as the Name + this flag set.
471 bool IsTypeDef = false;
472
473 llvm::SmallVector<MemberTypeInfo, 4>
474 Members; // List of info about record members.
475 llvm::SmallVector<Reference, 4> Parents; // List of base/parent records
476 // (does not include virtual
477 // parents).
478 llvm::SmallVector<Reference, 4>
479 VirtualParents; // List of virtual base/parent records.
480
481 std::vector<BaseRecordInfo>
482 Bases; // List of base/parent records; this includes inherited methods and
483 // attributes
484
485 std::vector<FriendInfo> Friends;
486
488};
489
490// Info for typedef and using statements.
491struct TypedefInfo : public SymbolInfo {
494
495 void merge(TypedefInfo &&I);
496
498
499 // Underlying type declaration
500 SmallString<16> TypeDeclaration;
501
502 /// Comment description for the typedef.
503 std::vector<CommentInfo> Description;
504
505 // Indicates if this is a new C++ "using"-style typedef:
506 // using MyVector = std::vector<int>
507 // False means it's a C-style typedef:
508 // typedef std::vector<int> MyVector;
509 bool IsUsing = false;
510};
511
512struct BaseRecordInfo : public RecordInfo {
514 BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual,
515 AccessSpecifier Access, bool IsParent);
516
517 // Indicates if base corresponds to a virtual inheritance
518 bool IsVirtual = false;
519 // Access level associated with this inherited info (public, protected,
520 // private).
521 AccessSpecifier Access = AccessSpecifier::AS_public;
522 bool IsParent = false; // Indicates if this base is a direct parent
523};
524
525// Information for a single possible value of an enumeration.
527 explicit EnumValueInfo(StringRef Name = StringRef(),
528 StringRef Value = StringRef("0"),
529 StringRef ValueExpr = StringRef())
531
532 bool operator==(const EnumValueInfo &Other) const {
533 return std::tie(Name, Value, ValueExpr) ==
534 std::tie(Other.Name, Other.Value, Other.ValueExpr);
535 }
536
537 SmallString<16> Name;
538
539 // The computed value of the enumeration constant. This could be the result of
540 // evaluating the ValueExpr, or it could be automatically generated according
541 // to C rules.
542 SmallString<16> Value;
543
544 // Stores the user-supplied initialization expression for this enumeration
545 // constant. This will be empty for implicit enumeration values.
546 SmallString<16> ValueExpr;
547
548 /// Comment description of this field.
549 std::vector<CommentInfo> Description;
550};
551
552// TODO: Expand to allow for documenting templating.
553// Info for types.
554struct EnumInfo : public SymbolInfo {
557
558 void merge(EnumInfo &&I);
559
560 // Indicates whether this enum is scoped (e.g. enum class).
561 bool Scoped = false;
562
563 // Set to nonempty to the type when this is an explicitly typed enum. For
564 // enum Foo : short { ... };
565 // this will be "short".
566 std::optional<TypeInfo> BaseType;
567
568 llvm::SmallVector<EnumValueInfo, 4> Members; // List of enum members.
569};
570
581
582struct Index : public Reference {
583 Index() = default;
584 Index(StringRef Name) : Reference(SymbolID(), Name) {}
587 Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
588 : Reference(USR, Name, IT, Name, Path) {}
589 // This is used to look for a USR in a vector of Indexes using std::find
590 bool operator==(const SymbolID &Other) const { return USR == Other; }
591 bool operator<(const Index &Other) const;
592
593 std::optional<SmallString<16>> JumpToSection;
594 std::vector<Index> Children;
595
596 void sort();
597};
598
599// TODO: Add functionality to include separate markdown pages.
600
601// A standalone function to call to merge a vector of infos into one.
602// This assumes that all infos in the vector are of the same type, and will fail
603// if they are different.
604llvm::Expected<std::unique_ptr<Info>>
605mergeInfos(std::vector<std::unique_ptr<Info>> &Values);
606
608 ClangDocContext() = default;
609 ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
610 bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot,
611 StringRef RepositoryUrl, StringRef RepositoryCodeLinePrefix,
612 StringRef Base, std::vector<std::string> UserStylesheets,
613 bool FTimeTrace = false);
614 tooling::ExecutionContext *ECtx;
615 std::string ProjectName; // Name of project clang-doc is documenting.
616 bool PublicOnly; // Indicates if only public declarations are documented.
617 bool FTimeTrace; // Indicates if ftime trace is turned on
618 int Granularity; // Granularity of ftime trace
619 std::string OutDirectory; // Directory for outputting generated files.
620 std::string SourceRoot; // Directory where processed files are stored. Links
621 // to definition locations will only be generated if
622 // the file is in this dir.
623 // URL of repository that hosts code used for links to definition locations.
624 std::optional<std::string> RepositoryUrl;
625 // Prefix of line code for repository.
626 std::optional<std::string> RepositoryLinePrefix;
627 // Path of CSS stylesheets that will be copied to OutDirectory and used to
628 // style all HTML files.
629 std::vector<std::string> UserStylesheets;
630 // JavaScript files that will be imported in all HTML files.
631 std::vector<std::string> JsScripts;
632 // Base directory for remote repositories.
633 StringRef Base;
634 // Maps mustache template types to specific mustache template files.
635 // Ex. comment-template -> /path/to/comment-template.mustache
636 llvm::StringMap<std::string> MustacheTemplates;
638};
639
640} // namespace doc
641} // namespace clang
642
643#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))
llvm::Expected< std::unique_ptr< Info > > mergeInfos(std::vector< std::unique_ptr< Info > > &Values)
CommentKind stringToCommentKind(llvm::StringRef KindStr)
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
llvm::StringMap< std::string > MustacheTemplates
std::vector< std::string > JsScripts
tooling::ExecutionContext * ECtx
std::optional< std::string > RepositoryLinePrefix
SmallString< 8 > Direction
CommentInfo(CommentInfo &Other)=delete
CommentInfo & operator=(CommentInfo &&Other)=default
std::vector< std::unique_ptr< CommentInfo > > Children
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
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)
llvm::SmallVector< EnumValueInfo, 4 > Members
void merge(EnumInfo &&I)
std::optional< TypeInfo > BaseType
std::vector< 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())
SmallString< 16 > FullName
llvm::SmallVector< FieldTypeInfo, 4 > Params
void merge(FunctionInfo &&I)
std::optional< TemplateInfo > Template
SmallString< 256 > Prototype
Index(StringRef Name, StringRef JumpToSection)
std::optional< SmallString< 16 > > JumpToSection
std::vector< Index > Children
bool operator<(const Index &Other) const
bool operator==(const SymbolID &Other) const
Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
Index(StringRef Name)
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)
SmallString< 16 > Name
llvm::SmallString< 16 > getFileBaseName() const
Returns the basename that should be used for this Info.
std::vector< CommentInfo > Description
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)
std::vector< CommentInfo > Description
bool operator==(const MemberTypeInfo &Other) const
NamespaceInfo(SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
void merge(NamespaceInfo &&I)
llvm::SmallVector< MemberTypeInfo, 4 > Members
RecordInfo(SymbolID USR=SymbolID(), StringRef Name=StringRef(), StringRef Path=StringRef())
std::optional< TemplateInfo > Template
SmallString< 16 > FullName
std::vector< FriendInfo > Friends
llvm::SmallVector< Reference, 4 > VirtualParents
llvm::SmallVector< Reference, 4 > Parents
void merge(RecordInfo &&I)
std::vector< BaseRecordInfo > Bases
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
std::vector< Reference > Records
std::vector< TypedefInfo > Typedefs
std::vector< FunctionInfo > Functions
std::vector< Reference > Namespaces
std::vector< VarInfo > Variables
std::vector< EnumInfo > Enums
std::vector< ConceptInfo > Concepts
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)
std::vector< ConstraintInfo > Constraints
std::vector< TemplateParamInfo > Params
std::optional< TemplateSpecializationInfo > Specialization
TemplateParamInfo(StringRef Contents)
std::vector< TemplateParamInfo > Params
TypeInfo(StringRef Name, StringRef Path=StringRef())
TypeInfo(const Reference &R)
bool operator==(const TypeInfo &Other) const
void merge(TypedefInfo &&I)
TypedefInfo(SymbolID USR=SymbolID())
SmallString< 16 > TypeDeclaration
std::vector< CommentInfo > Description
Comment description for the typedef.
VarInfo(SymbolID USR)
void merge(VarInfo &&I)