@@ -950,6 +950,8 @@ populate(
950
950
FunctionInfo& I,
951
951
DeclTy* D)
952
952
{
953
+ MRDOCS_SYMBOL_TRACE (D, context_);
954
+
953
955
// D is the templated declaration if FTD is non-null
954
956
if (D->isFunctionTemplateSpecialization ())
955
957
{
@@ -987,91 +989,91 @@ populate(
987
989
}
988
990
}
989
991
990
- // KRYSTIAN TODO: move other extraction that requires
991
- // a valid function type here
992
- if (auto FT = getDeclaratorType (D); ! FT.isNull ())
992
+ // Get the function type and extract information that comes from the type
993
+ if (auto FT = getDeclaratorType (D); !FT.isNull ())
993
994
{
995
+ MRDOCS_SYMBOL_TRACE (FT, context_);
994
996
const auto * FPT = FT->template getAs <FunctionProtoType>();
997
+ MRDOCS_SYMBOL_TRACE (FPT, context_);
995
998
populate (I.Noexcept , FPT);
996
999
I.HasTrailingReturn |= FPT->hasTrailingReturn ();
997
1000
}
998
1001
999
1002
//
1000
1003
// FunctionDecl
1001
1004
//
1002
- I.OverloadedOperator = toOperatorKind (
1003
- D->getOverloadedOperator ());
1004
- I.IsVariadic |= D->isVariadic ();
1005
- I.IsDefaulted |= D->isDefaulted ();
1006
- I.IsExplicitlyDefaulted |= D->isExplicitlyDefaulted ();
1007
- I.IsDeleted |= D->isDeleted ();
1008
- I.IsDeletedAsWritten |= D->isDeletedAsWritten ();
1009
- I.IsNoReturn |= D->isNoReturn ();
1010
- // subsumes D->hasAttr<NoReturnAttr>()
1011
- // subsumes D->hasAttr<CXX11NoReturnAttr>()
1012
- // subsumes D->hasAttr<C11NoReturnAttr>()
1013
- // subsumes D->getType()->getAs<FunctionType>()->getNoReturnAttr()
1014
- I.HasOverrideAttr |= D->template hasAttr <OverrideAttr>();
1015
-
1016
- if (ConstexprSpecKind const CSK = D->getConstexprKind ();
1005
+ FunctionDecl const * FD = D;
1006
+ I.OverloadedOperator = toOperatorKind (FD->getOverloadedOperator ());
1007
+ I.IsVariadic |= FD->isVariadic ();
1008
+ I.IsDefaulted |= FD->isDefaulted ();
1009
+ I.IsExplicitlyDefaulted |= FD->isExplicitlyDefaulted ();
1010
+ I.IsDeleted |= FD->isDeleted ();
1011
+ I.IsDeletedAsWritten |= FD->isDeletedAsWritten ();
1012
+ I.IsNoReturn |= FD->isNoReturn ();
1013
+ I.HasOverrideAttr |= FD->template hasAttr <OverrideAttr>();
1014
+
1015
+ if (ConstexprSpecKind const CSK = FD->getConstexprKind ();
1017
1016
CSK != ConstexprSpecKind::Unspecified)
1018
1017
{
1019
1018
I.Constexpr = toConstexprKind (CSK);
1020
1019
}
1021
1020
1022
- if (StorageClass const SC = D ->getStorageClass ())
1021
+ if (StorageClass const SC = FD ->getStorageClass ())
1023
1022
{
1024
1023
I.StorageClass = toStorageClassKind (SC);
1025
1024
}
1026
1025
1027
- I.IsNodiscard |= D->template hasAttr <WarnUnusedResultAttr>();
1028
- I.IsExplicitObjectMemberFunction |= D->hasCXXExplicitFunctionObjectParameter ();
1026
+ I.IsNodiscard |= FD->template hasAttr <WarnUnusedResultAttr>();
1027
+ I.IsExplicitObjectMemberFunction |= FD->hasCXXExplicitFunctionObjectParameter ();
1028
+
1029
1029
//
1030
1030
// CXXMethodDecl
1031
1031
//
1032
1032
if constexpr (std::derived_from<DeclTy, CXXMethodDecl>)
1033
1033
{
1034
- I. IsVirtual | = D-> isVirtual () ;
1035
- I.IsVirtualAsWritten |= D-> isVirtualAsWritten ();
1036
- I.IsPure |= D-> isPureVirtual ();
1037
- I.IsConst |= D-> isConst ();
1038
- I.IsVolatile |= D-> isVolatile ();
1039
- I.RefQualifier = toReferenceKind (D-> getRefQualifier () );
1040
- I.IsFinal |= D-> template hasAttr <FinalAttr>( );
1041
- // D->isCopyAssignmentOperator()
1042
- // D->isMoveAssignmentOperator ()
1043
- // D->isOverloadedOperator();
1044
- // D->isStaticOverloadedOperator ();
1045
- }
1034
+ CXXMethodDecl const * MD = D;
1035
+ I.IsVirtual |= MD-> isVirtual ();
1036
+ I.IsVirtualAsWritten |= MD-> isVirtualAsWritten ();
1037
+ I.IsPure |= MD-> isPureVirtual ();
1038
+ I.IsConst |= MD-> isConst ();
1039
+ I.IsVolatile |= MD-> isVolatile ( );
1040
+ I.RefQualifier = toReferenceKind (MD-> getRefQualifier () );
1041
+ I. IsFinal |= MD-> template hasAttr <FinalAttr>();
1042
+ // MD->isCopyAssignmentOperator ()
1043
+ // MD->isMoveAssignmentOperator()
1044
+ // MD->isOverloadedOperator ();
1045
+ // MD->isStaticOverloadedOperator();
1046
1046
1047
- //
1048
- // CXXDestructorDecl
1049
- //
1050
- // if constexpr(std::derived_from<DeclTy, CXXDestructorDecl>)
1051
- // {
1052
- // }
1047
+ //
1048
+ // CXXDestructorDecl
1049
+ //
1050
+ // if constexpr(std::derived_from<DeclTy, CXXDestructorDecl>)
1051
+ // {
1052
+ // }
1053
1053
1054
- //
1055
- // CXXConstructorDecl
1056
- //
1057
- if constexpr (std::derived_from<DeclTy, CXXConstructorDecl>)
1058
- {
1059
- populate (I.Explicit , D->getExplicitSpecifier ());
1060
- }
1054
+ //
1055
+ // CXXConstructorDecl
1056
+ //
1057
+ if constexpr (std::derived_from<DeclTy, CXXConstructorDecl>)
1058
+ {
1059
+ populate (I.Explicit , D->getExplicitSpecifier ());
1060
+ }
1061
1061
1062
- //
1063
- // CXXConversionDecl
1064
- //
1065
- if constexpr (std::derived_from<DeclTy, CXXConversionDecl>)
1066
- {
1067
- populate (I.Explicit , D->getExplicitSpecifier ());
1062
+ //
1063
+ // CXXConversionDecl
1064
+ //
1065
+ if constexpr (std::derived_from<DeclTy, CXXConversionDecl>)
1066
+ {
1067
+ populate (I.Explicit , D->getExplicitSpecifier ());
1068
+ }
1068
1069
}
1069
1070
1070
- ArrayRef<ParmVarDecl*> const params = D ->parameters ();
1071
+ ArrayRef<ParmVarDecl*> const params = FD ->parameters ();
1071
1072
I.Params .resize (params.size ());
1072
1073
for (std::size_t i = 0 ; i < params.size (); ++i)
1073
1074
{
1074
1075
ParmVarDecl const * P = params[i];
1076
+ MRDOCS_SYMBOL_TRACE (P, context_);
1075
1077
Param& param = I.Params [i];
1076
1078
1077
1079
if (param.Name .empty ())
@@ -1099,16 +1101,16 @@ populate(
1099
1101
}
1100
1102
}
1101
1103
1102
- I.Class = toFunctionClass (D ->getDeclKind ());
1104
+ I.Class = toFunctionClass (FD ->getDeclKind ());
1103
1105
1104
1106
// extract the return type in direct dependency mode
1105
1107
// if it contains a placeholder type which is
1106
1108
// deduceded as a local class type
1107
- QualType const RT = D ->getReturnType ();
1109
+ QualType const RT = FD ->getReturnType ();
1108
1110
MRDOCS_SYMBOL_TRACE (RT, context_);
1109
1111
I.ReturnType = toTypeInfo (RT);
1110
1112
1111
- if (auto * TRC = D ->getTrailingRequiresClause ())
1113
+ if (auto * TRC = FD ->getTrailingRequiresClause ())
1112
1114
{
1113
1115
populate (I.Requires , TRC);
1114
1116
}
@@ -1120,8 +1122,9 @@ void
1120
1122
ASTVisitor::
1121
1123
populate (FunctionInfo& I, FunctionTemplateDecl* D)
1122
1124
{
1123
- populate (I.Template , D->getTemplatedDecl (), D);
1124
- populate (I, D->getTemplatedDecl ());
1125
+ FunctionDecl* TD = D->getTemplatedDecl ();
1126
+ populate (I.Template , TD, D);
1127
+ populate (I, TD);
1125
1128
}
1126
1129
1127
1130
void
@@ -1375,7 +1378,8 @@ ASTVisitor::
1375
1378
populate (TemplateInfo& Template, DeclTy*, TemplateDeclTy* TD)
1376
1379
{
1377
1380
MRDOCS_ASSERT (TD);
1378
- populate (Template, TD->getTemplateParameters ());
1381
+ TemplateParameterList const * TPL = TD->getTemplateParameters ();
1382
+ populate (Template, TPL);
1379
1383
}
1380
1384
1381
1385
template <std::derived_from<CXXRecordDecl> CXXRecordDeclTy>
@@ -1592,18 +1596,25 @@ populate(
1592
1596
{
1593
1597
I = std::make_unique<TemplateTParam>();
1594
1598
}
1595
- auto * R = dynamic_cast <TemplateTParam*>(I.get ());
1596
- if (R->Params .empty ())
1599
+ TemplateTemplateParmDecl const * TTPD = cast<TemplateTemplateParmDecl>(P);
1600
+ MRDOCS_CHECK_OR (TTPD);
1601
+ TemplateParameterList const * TPL = TTPD->getTemplateParameters ();
1602
+ MRDOCS_CHECK_OR (TPL);
1603
+ auto * Result = dynamic_cast <TemplateTParam*>(I.get ());
1604
+ if (Result->Params .size () < TPL->size ())
1597
1605
{
1598
- for (NamedDecl const * NP: *P->getTemplateParameters ())
1599
- {
1600
- populate (R->Params .emplace_back (), NP);
1601
- }
1606
+ Result->Params .resize (TPL->size ());
1602
1607
}
1603
- if (P-> hasDefaultArgument () && !R-> Default )
1608
+ for (std:: size_t i = 0 ; i < TPL-> size (); ++i )
1604
1609
{
1605
- R->Default = toTArg (
1606
- P->getDefaultArgument ().getArgument ());
1610
+ NamedDecl const * TP = TPL->getParam (i);
1611
+ populate (Result->Params [i], TP);
1612
+ }
1613
+ if (TTPD->hasDefaultArgument () && !Result->Default )
1614
+ {
1615
+ TemplateArgumentLoc const & TAL = TTPD->getDefaultArgument ();
1616
+ TemplateArgument const & TA = TAL.getArgument ();
1617
+ Result->Default = toTArg (TA);
1607
1618
}
1608
1619
return ;
1609
1620
}
@@ -1634,9 +1645,10 @@ populate(
1634
1645
{
1635
1646
TI.Params .resize (TPL->size ());
1636
1647
}
1637
- for (std::size_t I = 0 ; I < TPL->size (); ++I )
1648
+ for (std::size_t i = 0 ; i < TPL->size (); ++i )
1638
1649
{
1639
- populate (TI.Params [I], TPL->getParam (I));
1650
+ NamedDecl const * P = TPL->getParam (i);
1651
+ populate (TI.Params [i], P);
1640
1652
}
1641
1653
if (auto * RC = TPL->getRequiresClause ())
1642
1654
{
0 commit comments