@@ -547,6 +547,11 @@ class ASTVisitor
547
547
if (DC->isFileContext () ||
548
548
DC->isFunctionOrMethod ())
549
549
break ;
550
+
551
+ if (auto * RD = dyn_cast<CXXRecordDecl>(DC);
552
+ RD && RD->isAnonymousStructOrUnion ())
553
+ continue ;
554
+
550
555
// when extracting dependencies, we want to extract
551
556
// all members of the containing class, not just this one
552
557
if (auto * TD = dyn_cast<TagDecl>(DC))
@@ -1519,6 +1524,16 @@ class ASTVisitor
1519
1524
return false ;
1520
1525
}
1521
1526
1527
+ // don't extract anonymous unions
1528
+ if (const auto * RD = dyn_cast<RecordDecl>(D);
1529
+ RD && RD->isAnonymousStructOrUnion ())
1530
+ return false ;
1531
+
1532
+ // don't extract implicitly generated declarations
1533
+ // (except for IndirectFieldDecls)
1534
+ if (D->isImplicit () && !isa<IndirectFieldDecl>(D))
1535
+ return false ;
1536
+
1522
1537
if (!config_->input .include .empty ())
1523
1538
{
1524
1539
// Get filename
@@ -1959,10 +1974,15 @@ class ASTVisitor
1959
1974
{
1960
1975
switch (D->getKind ())
1961
1976
{
1977
+ case Decl::CXXRecord:
1978
+ // we treat anonymous unions as "transparent"
1979
+ if (auto * RD = cast<CXXRecordDecl>(D);
1980
+ RD->isAnonymousStructOrUnion ())
1981
+ break ;
1982
+ [[fallthrough]];
1962
1983
case Decl::TranslationUnit:
1963
1984
case Decl::Namespace:
1964
1985
case Decl::Enum:
1965
- case Decl::CXXRecord:
1966
1986
case Decl::ClassTemplateSpecialization:
1967
1987
case Decl::ClassTemplatePartialSpecialization:
1968
1988
return D;
@@ -2373,6 +2393,8 @@ class ASTVisitor
2373
2393
2374
2394
I.Type = buildTypeInfo (D->getType ());
2375
2395
2396
+ I.IsVariant = D->getParent ()->isUnion ();
2397
+
2376
2398
I.IsMutable = D->isMutable ();
2377
2399
2378
2400
if (const Expr* E = D->getInClassInitializer ())
@@ -2793,6 +2815,17 @@ class ASTVisitor
2793
2815
void
2794
2816
traverse (FieldDecl*);
2795
2817
2818
+ /* * Traverse a member of an anonymous union.
2819
+
2820
+ This function is called by traverseDecl to traverse
2821
+ a member of an anonymous union.
2822
+
2823
+ A IndirectFieldDecl inherits from ValueDecl.
2824
+
2825
+ */
2826
+ void
2827
+ traverse (IndirectFieldDecl*);
2828
+
2796
2829
/* * Traverse a concept definition
2797
2830
2798
2831
This function is called by traverseDecl to traverse a
@@ -3061,6 +3094,14 @@ traverse(FieldDecl* D)
3061
3094
auto [I, created] = *exp ;
3062
3095
buildField (I, created, D);
3063
3096
}
3097
+
3098
+ void
3099
+ ASTVisitor::
3100
+ traverse (IndirectFieldDecl* D)
3101
+ {
3102
+ traverse (D->getAnonField ());
3103
+ }
3104
+
3064
3105
// ------------------------------------------------
3065
3106
// ConceptDecl
3066
3107
@@ -3348,9 +3389,8 @@ traverseDecl(
3348
3389
{
3349
3390
MRDOCS_ASSERT (D);
3350
3391
3351
- // Decl had a semantic error or is implicitly
3352
- // generated by the implementation
3353
- if (D->isInvalidDecl () || D->isImplicit ())
3392
+ // Decl had a semantic error
3393
+ if (D->isInvalidDecl ())
3354
3394
return ;
3355
3395
3356
3396
SymbolFilter::FilterScope scope (symbolFilter_);
0 commit comments