@@ -38,6 +38,8 @@ namespace impl {
38
38
39
39
template <typename Derived>
40
40
class ExtractAPIVisitorBase : public RecursiveASTVisitor <Derived> {
41
+ using Base = RecursiveASTVisitor<Derived>;
42
+
41
43
protected:
42
44
ExtractAPIVisitorBase (ASTContext &Context, APISet &API)
43
45
: Context(Context), API(API) {}
@@ -79,8 +81,10 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
79
81
80
82
bool VisitNamespaceDecl (const NamespaceDecl *Decl);
81
83
84
+ bool TraverseRecordDecl (RecordDecl *Decl);
82
85
bool VisitRecordDecl (const RecordDecl *Decl);
83
86
87
+ bool TraverseCXXRecordDecl (CXXRecordDecl *Decl);
84
88
bool VisitCXXRecordDecl (const CXXRecordDecl *Decl);
85
89
86
90
bool VisitCXXMethodDecl (const CXXMethodDecl *Decl);
@@ -548,6 +552,19 @@ bool ExtractAPIVisitorBase<Derived>::VisitNamespaceDecl(
548
552
return true ;
549
553
}
550
554
555
+ template <typename Derived>
556
+ bool ExtractAPIVisitorBase<Derived>::TraverseRecordDecl(RecordDecl *Decl) {
557
+ bool Ret = Base::TraverseRecordDecl (Decl);
558
+
559
+ if (!isEmbeddedInVarDeclarator (*Decl) && Decl->isAnonymousStructOrUnion ()) {
560
+ SmallString<128 > USR;
561
+ index::generateUSRForDecl (Decl, USR);
562
+ API.removeRecord (USR);
563
+ }
564
+
565
+ return Ret;
566
+ }
567
+
551
568
template <typename Derived>
552
569
bool ExtractAPIVisitorBase<Derived>::VisitRecordDecl(const RecordDecl *Decl) {
553
570
if (!getDerivedExtractAPIVisitor ().shouldDeclBeIncluded (Decl))
@@ -588,6 +605,19 @@ bool ExtractAPIVisitorBase<Derived>::VisitRecordDecl(const RecordDecl *Decl) {
588
605
return true ;
589
606
}
590
607
608
+ template <typename Derived>
609
+ bool ExtractAPIVisitorBase<Derived>::TraverseCXXRecordDecl(CXXRecordDecl *Decl) {
610
+ bool Ret = Base::TraverseCXXRecordDecl (Decl);
611
+
612
+ if (!isEmbeddedInVarDeclarator (*Decl) && Decl->isAnonymousStructOrUnion ()) {
613
+ SmallString<128 > USR;
614
+ index::generateUSRForDecl (Decl, USR);
615
+ API.removeRecord (USR);
616
+ }
617
+
618
+ return Ret;
619
+ }
620
+
591
621
template <typename Derived>
592
622
bool ExtractAPIVisitorBase<Derived>::VisitCXXRecordDecl(
593
623
const CXXRecordDecl *Decl) {
0 commit comments