@@ -522,6 +522,7 @@ populate(Info& I, bool const isNew, DeclTy const* D)
522522{
523523 populate (I.javadoc , D);
524524 populate (dynamic_cast <SourceInfo&>(I), D);
525+ populateAttributes (I, D);
525526
526527 // All other information is redundant if the symbol is not new
527528 MRDOCS_CHECK_OR (isNew);
@@ -767,7 +768,6 @@ populate(
767768 I.IsExplicitlyDefaulted |= D->isExplicitlyDefaulted ();
768769 I.IsDeleted |= D->isDeleted ();
769770 I.IsDeletedAsWritten |= D->isDeletedAsWritten ();
770- I.IsNoReturn |= D->isNoReturn ();
771771
772772 if (ConstexprSpecKind const CSK = D->getConstexprKind ();
773773 CSK != ConstexprSpecKind::Unspecified)
@@ -780,7 +780,6 @@ populate(
780780 I.StorageClass = toStorageClassKind (SC);
781781 }
782782
783- I.IsNodiscard |= D->hasAttr <WarnUnusedResultAttr>();
784783 I.IsExplicitObjectMemberFunction |= D->hasCXXExplicitFunctionObjectParameter ();
785784
786785 ArrayRef<ParmVarDecl*> const params = D->parameters ();
@@ -867,8 +866,6 @@ populate(
867866 }
868867 }
869868 }
870-
871- populateAttributes (I, D);
872869}
873870
874871void
@@ -1024,7 +1021,6 @@ populate(
10241021 QT.removeLocalConst ();
10251022 }
10261023 I.Type = toTypeInfo (QT);
1027- populateAttributes (I, D);
10281024}
10291025
10301026void
@@ -1068,10 +1064,6 @@ populate(
10681064 I.IsBitfield = true ;
10691065 populate (I.BitfieldWidth , D->getBitWidth ());
10701066 }
1071- I.HasNoUniqueAddress = D->hasAttr <NoUniqueAddressAttr>();
1072- I.IsDeprecated = D->hasAttr <DeprecatedAttr>();
1073- I.IsMaybeUnused = D->hasAttr <UnusedAttr>();
1074- populateAttributes (I, D);
10751067}
10761068
10771069void
@@ -1568,11 +1560,53 @@ populate(
15681560 }));
15691561}
15701562
1571- template <std::derived_from<Info> InfoTy>
15721563void
15731564ASTVisitor::
1574- populateAttributes (InfoTy& I, Decl const * D)
1575- {
1565+ populateAttributes (Info& I, Decl const * D)
1566+ {
1567+ for (const Attr* AT : D->getAttrs ())
1568+ {
1569+ switch (AT->getKind ())
1570+ {
1571+ case attr::Kind::Deprecated:
1572+ addAttribute (I, AttributeKind::Deprecated);
1573+ break ;
1574+ case attr::Kind::Unused:
1575+ addAttribute (I, AttributeKind::MaybeUnused);
1576+ break ;
1577+ case attr::Kind::WarnUnusedResult:
1578+ addAttribute (I, AttributeKind::Nodiscard);
1579+ break ;
1580+ case attr::Kind::NoReturn:
1581+ addAttribute (I, AttributeKind::Noreturn);
1582+ break ;
1583+ case attr::Kind::NoUniqueAddress:
1584+ addAttribute (I, AttributeKind::NoUniqueAddress);
1585+ break ;
1586+ default :
1587+ // KRYSTIAN TODO: handle more attributes types
1588+ break ;
1589+ }
1590+ }
1591+
1592+ #if 0
1593+ if(D->hasAttr<DeprecatedAttr>())
1594+ addAttribute(I, AttributeKind::Deprecated);
1595+
1596+ if(D->hasAttr<UnusedAttr>())
1597+ addAttribute(I, AttributeKind::MaybeUnused);
1598+
1599+ if(D->hasAttr<WarnUnusedResultAttr>())
1600+ addAttribute(I, AttributeKind::Nodiscard);
1601+
1602+ if(D->hasAttr<NoReturnAttr>())
1603+ addAttribute(I, AttributeKind::Noreturn);
1604+
1605+ if(D->hasAttr<NoUniqueAddressAttr>())
1606+ addAttribute(I, AttributeKind::NoUniqueAddress);
1607+ #endif
1608+
1609+ #if 0
15761610 if constexpr (requires { I.Attributes; })
15771611 {
15781612 MRDOCS_CHECK_OR(D->hasAttrs());
@@ -1589,6 +1623,18 @@ populateAttributes(InfoTy& I, Decl const* D)
15891623 }
15901624 }
15911625 }
1626+ #endif
1627+ }
1628+
1629+ void
1630+ ASTVisitor::
1631+ addAttribute (
1632+ Info& I,
1633+ AttributeKind kind)
1634+ {
1635+ if (std::ranges::find (I.Attributes , kind) != I.Attributes .end ())
1636+ return ;
1637+ I.Attributes .emplace_back (kind);
15921638}
15931639
15941640void
0 commit comments