Skip to content

Commit 938b673

Browse files
committed
unify traverse functions
#refactor
1 parent 1579517 commit 938b673

File tree

12 files changed

+459
-469
lines changed

12 files changed

+459
-469
lines changed

include/mrdocs/Metadata/Concept.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct ConceptInfo
2828
{
2929
/** The concepts template parameters
3030
*/
31-
std::unique_ptr<TemplateInfo> Template;
31+
std::optional<TemplateInfo> Template;
3232

3333
/** The concepts constraint-expression
3434
*/

include/mrdocs/Metadata/Function.hpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,16 @@ struct FunctionInfo
126126
: InfoCommonBase<InfoKind::Function>
127127
, SourceInfo
128128
{
129-
std::unique_ptr<TypeInfo> ReturnType; // Info about the return type of this function.
130-
std::vector<Param> Params; // List of parameters.
129+
/// Info about the return type of this function.
130+
std::unique_ptr<TypeInfo> ReturnType;
131131

132-
// When present, this function is a template or specialization.
133-
std::unique_ptr<TemplateInfo> Template;
132+
/// List of parameters.
133+
std::vector<Param> Params;
134134

135-
// the class of function this is
135+
/// When present, this function is a template or specialization.
136+
std::optional<TemplateInfo> Template;
137+
138+
/// The class of function this is
136139
FunctionClass Class = FunctionClass::Normal;
137140

138141
NoexceptInfo Noexcept;

include/mrdocs/Metadata/Guide.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct GuideInfo
3838

3939
/** Template head, if any.
4040
*/
41-
std::unique_ptr<TemplateInfo> Template;
41+
std::optional<TemplateInfo> Template;
4242

4343
/** The parameters of the deduction guide.
4444
*/

include/mrdocs/Metadata/Record.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ struct RecordInfo
8585
*/
8686
RecordKeyKind KeyKind = RecordKeyKind::Struct;
8787

88-
// When present, this record is a template or specialization.
89-
std::unique_ptr<TemplateInfo> Template;
88+
/// When present, this record is a template or specialization.
89+
std::optional<TemplateInfo> Template;
9090

91-
// Indicates if the record was declared using a typedef. Things like anonymous
92-
// structs in a typedef:
91+
// Indicates if the record was declared using a typedef.
92+
// Things like anonymous structs in a typedef:
9393
// typedef struct { ... } foo_t;
9494
// are converted into records with the typedef as the Name + this flag set.
9595
// KRYSTIAN FIXME: this does not account for alias-declarations

include/mrdocs/Metadata/Template.hpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,14 @@ struct TemplateInfo
369369
TemplateSpecKind specializationKind() const noexcept
370370
{
371371
if(Params.empty())
372+
{
372373
return TemplateSpecKind::Explicit;
373-
return Args.empty() ? TemplateSpecKind::Primary :
374-
TemplateSpecKind::Partial;
374+
}
375+
if (Args.empty())
376+
{
377+
return TemplateSpecKind::Primary;
378+
}
379+
return TemplateSpecKind::Partial;
375380
}
376381
};
377382

@@ -388,7 +393,7 @@ void
388393
tag_invoke(
389394
dom::ValueFromTag,
390395
dom::Value& v,
391-
std::unique_ptr<TemplateInfo> const& I,
396+
std::optional<TemplateInfo> const& I,
392397
DomCorpus const* domCorpus)
393398
{
394399
if (!I)

include/mrdocs/Metadata/Typedef.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct TypedefInfo
3535
// typedef std::vector<int> MyVector;
3636
bool IsUsing = false;
3737

38-
std::unique_ptr<TemplateInfo> Template;
38+
std::optional<TemplateInfo> Template;
3939

4040
//--------------------------------------------
4141

include/mrdocs/Metadata/Variable.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct VariableInfo
3434
/** The type of the variable */
3535
std::unique_ptr<TypeInfo> Type;
3636

37-
std::unique_ptr<TemplateInfo> Template;
37+
std::optional<TemplateInfo> Template;
3838

3939
ExprInfo Initializer;
4040

0 commit comments

Comments
 (0)