@@ -208,20 +208,20 @@ struct APIRecord {
208
208
RK_ClassTemplate,
209
209
RK_ClassTemplateSpecialization,
210
210
RK_ClassTemplatePartialSpecialization,
211
- RK_LastRecordContext,
212
- RK_GlobalFunction,
213
- RK_GlobalFunctionTemplate,
214
- RK_GlobalFunctionTemplateSpecialization,
211
+ RK_StructField,
212
+ RK_UnionField,
213
+ RK_CXXField,
214
+ RK_StaticField,
215
+ RK_CXXFieldTemplate,
215
216
RK_GlobalVariable,
216
217
RK_GlobalVariableTemplate,
217
218
RK_GlobalVariableTemplateSpecialization,
218
219
RK_GlobalVariableTemplatePartialSpecialization,
220
+ RK_LastRecordContext,
221
+ RK_GlobalFunction,
222
+ RK_GlobalFunctionTemplate,
223
+ RK_GlobalFunctionTemplateSpecialization,
219
224
RK_EnumConstant,
220
- RK_StructField,
221
- RK_UnionField,
222
- RK_StaticField,
223
- RK_CXXField,
224
- RK_CXXFieldTemplate,
225
225
RK_Concept,
226
226
RK_CXXStaticMethod,
227
227
RK_CXXInstanceMethod,
@@ -321,6 +321,10 @@ class RecordContext {
321
321
322
322
RecordContext (APIRecord::RecordKind Kind) : Kind(Kind) {}
323
323
324
+ // / Append \p Other children chain into ours and empty out Other's record
325
+ // / chain.
326
+ void stealRecordChain (RecordContext &Other);
327
+
324
328
APIRecord::RecordKind getKind () const { return Kind; }
325
329
326
330
struct record_iterator {
@@ -370,6 +374,7 @@ class RecordContext {
370
374
APIRecord::RecordKind Kind;
371
375
mutable APIRecord *First = nullptr ;
372
376
mutable APIRecord *Last = nullptr ;
377
+ bool IsWellFormed () const ;
373
378
374
379
protected:
375
380
friend class APISet ;
@@ -475,31 +480,36 @@ struct GlobalFunctionTemplateSpecializationRecord : GlobalFunctionRecord {
475
480
};
476
481
477
482
// / This holds information associated with global functions.
478
- struct GlobalVariableRecord : APIRecord {
483
+ struct GlobalVariableRecord : APIRecord, RecordContext {
479
484
GlobalVariableRecord (StringRef USR, StringRef Name, SymbolReference Parent,
480
485
PresumedLoc Loc, AvailabilityInfo Availability,
481
486
LinkageInfo Linkage, const DocComment &Comment,
482
487
DeclarationFragments Declaration,
483
488
DeclarationFragments SubHeading, bool IsFromSystemHeader)
484
489
: APIRecord(RK_GlobalVariable, USR, Name, Parent, Loc,
485
490
std::move (Availability), Linkage, Comment, Declaration,
486
- SubHeading, IsFromSystemHeader) {}
491
+ SubHeading, IsFromSystemHeader),
492
+ RecordContext(RK_GlobalVariable) {}
487
493
488
494
GlobalVariableRecord (RecordKind Kind, StringRef USR, StringRef Name,
489
- SymbolReference Parent,
490
-
491
- PresumedLoc Loc, AvailabilityInfo Availability,
492
- LinkageInfo Linkage, const DocComment &Comment,
495
+ SymbolReference Parent, PresumedLoc Loc,
496
+ AvailabilityInfo Availability, LinkageInfo Linkage,
497
+ const DocComment &Comment,
493
498
DeclarationFragments Declaration,
494
499
DeclarationFragments SubHeading, bool IsFromSystemHeader)
495
500
: APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
496
501
Linkage, Comment, Declaration, SubHeading,
497
- IsFromSystemHeader) {}
502
+ IsFromSystemHeader),
503
+ RecordContext(Kind) {}
498
504
499
505
static bool classof (const APIRecord *Record) {
500
506
return classofKind (Record->getKind ());
501
507
}
502
- static bool classofKind (RecordKind K) { return K == RK_GlobalVariable; }
508
+ static bool classofKind (RecordKind K) {
509
+ return K == RK_GlobalVariable || K == RK_GlobalVariableTemplate ||
510
+ K == RK_GlobalVariableTemplateSpecialization ||
511
+ K == RK_GlobalVariableTemplatePartialSpecialization;
512
+ }
503
513
504
514
private:
505
515
virtual void anchor ();
@@ -591,36 +601,64 @@ struct EnumConstantRecord : APIRecord {
591
601
virtual void anchor ();
592
602
};
593
603
604
+ struct TagRecord : APIRecord, RecordContext {
605
+ TagRecord (RecordKind Kind, StringRef USR, StringRef Name,
606
+ SymbolReference Parent, PresumedLoc Loc,
607
+ AvailabilityInfo Availability, const DocComment &Comment,
608
+ DeclarationFragments Declaration, DeclarationFragments SubHeading,
609
+ bool IsFromSystemHeader, bool IsEmbeddedInVarDeclarator,
610
+ AccessControl Access = AccessControl())
611
+ : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
612
+ LinkageInfo::none (), Comment, Declaration, SubHeading,
613
+ IsFromSystemHeader, std::move(Access)),
614
+ RecordContext(Kind),
615
+ IsEmbeddedInVarDeclarator(IsEmbeddedInVarDeclarator){};
616
+
617
+ static bool classof (const APIRecord *Record) {
618
+ return classofKind (Record->getKind ());
619
+ }
620
+ static bool classofKind (RecordKind K) {
621
+ return K == RK_Struct || K == RK_Union || K == RK_Enum;
622
+ }
623
+
624
+ bool IsEmbeddedInVarDeclarator;
625
+
626
+ virtual ~TagRecord () = 0 ;
627
+ };
628
+
594
629
// / This holds information associated with enums.
595
- struct EnumRecord : APIRecord, RecordContext {
630
+ struct EnumRecord : TagRecord {
596
631
EnumRecord (StringRef USR, StringRef Name, SymbolReference Parent,
597
632
PresumedLoc Loc, AvailabilityInfo Availability,
598
633
const DocComment &Comment, DeclarationFragments Declaration,
599
- DeclarationFragments SubHeading, bool IsFromSystemHeader)
600
- : APIRecord(RK_Enum, USR, Name, Parent, Loc, std::move(Availability),
601
- LinkageInfo::none (), Comment, Declaration, SubHeading,
602
- IsFromSystemHeader),
603
- RecordContext(RK_Enum) {}
634
+ DeclarationFragments SubHeading, bool IsFromSystemHeader,
635
+ bool IsEmbeddedInVarDeclarator,
636
+ AccessControl Access = AccessControl())
637
+ : TagRecord(RK_Enum, USR, Name, Parent, Loc, std::move(Availability),
638
+ Comment, Declaration, SubHeading, IsFromSystemHeader,
639
+ IsEmbeddedInVarDeclarator, std::move(Access)) {}
604
640
605
641
static bool classof (const APIRecord *Record) {
606
642
return classofKind (Record->getKind ());
607
643
}
644
+
608
645
static bool classofKind (RecordKind K) { return K == RK_Enum; }
609
646
610
647
private:
611
648
virtual void anchor ();
612
649
};
613
650
614
651
// / This holds information associated with struct or union fields fields.
615
- struct RecordFieldRecord : APIRecord {
652
+ struct RecordFieldRecord : APIRecord, RecordContext {
616
653
RecordFieldRecord (RecordKind Kind, StringRef USR, StringRef Name,
617
654
SymbolReference Parent, PresumedLoc Loc,
618
655
AvailabilityInfo Availability, const DocComment &Comment,
619
656
DeclarationFragments Declaration,
620
657
DeclarationFragments SubHeading, bool IsFromSystemHeader)
621
658
: APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
622
659
LinkageInfo::none (), Comment, Declaration, SubHeading,
623
- IsFromSystemHeader) {}
660
+ IsFromSystemHeader),
661
+ RecordContext(Kind) {}
624
662
625
663
static bool classof (const APIRecord *Record) {
626
664
return classofKind (Record->getKind ());
@@ -633,16 +671,17 @@ struct RecordFieldRecord : APIRecord {
633
671
};
634
672
635
673
// / This holds information associated with structs and unions.
636
- struct RecordRecord : APIRecord, RecordContext {
674
+ struct RecordRecord : TagRecord {
637
675
RecordRecord (RecordKind Kind, StringRef USR, StringRef Name,
638
676
SymbolReference Parent, PresumedLoc Loc,
639
677
AvailabilityInfo Availability, const DocComment &Comment,
640
678
DeclarationFragments Declaration,
641
- DeclarationFragments SubHeading, bool IsFromSystemHeader)
642
- : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
643
- LinkageInfo::none (), Comment, Declaration, SubHeading,
644
- IsFromSystemHeader),
645
- RecordContext(Kind) {}
679
+ DeclarationFragments SubHeading, bool IsFromSystemHeader,
680
+ bool IsEmbeddedInVarDeclarator,
681
+ AccessControl Access = AccessControl())
682
+ : TagRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
683
+ Comment, Declaration, SubHeading, IsFromSystemHeader,
684
+ IsEmbeddedInVarDeclarator, std::move(Access)) {}
646
685
647
686
static bool classof (const APIRecord *Record) {
648
687
return classofKind (Record->getKind ());
@@ -651,6 +690,8 @@ struct RecordRecord : APIRecord, RecordContext {
651
690
return K == RK_Struct || K == RK_Union;
652
691
}
653
692
693
+ bool isAnonymousWithNoTypedef () { return Name.empty (); }
694
+
654
695
virtual ~RecordRecord () = 0 ;
655
696
};
656
697
@@ -676,9 +717,11 @@ struct StructRecord : RecordRecord {
676
717
StructRecord (StringRef USR, StringRef Name, SymbolReference Parent,
677
718
PresumedLoc Loc, AvailabilityInfo Availability,
678
719
const DocComment &Comment, DeclarationFragments Declaration,
679
- DeclarationFragments SubHeading, bool IsFromSystemHeader)
720
+ DeclarationFragments SubHeading, bool IsFromSystemHeader,
721
+ bool IsEmbeddedInVarDeclarator)
680
722
: RecordRecord(RK_Struct, USR, Name, Parent, Loc, std::move(Availability),
681
- Comment, Declaration, SubHeading, IsFromSystemHeader) {}
723
+ Comment, Declaration, SubHeading, IsFromSystemHeader,
724
+ IsEmbeddedInVarDeclarator) {}
682
725
683
726
static bool classof (const APIRecord *Record) {
684
727
return classofKind (Record->getKind ());
@@ -711,9 +754,11 @@ struct UnionRecord : RecordRecord {
711
754
UnionRecord (StringRef USR, StringRef Name, SymbolReference Parent,
712
755
PresumedLoc Loc, AvailabilityInfo Availability,
713
756
const DocComment &Comment, DeclarationFragments Declaration,
714
- DeclarationFragments SubHeading, bool IsFromSystemHeader)
757
+ DeclarationFragments SubHeading, bool IsFromSystemHeader,
758
+ bool IsEmbeddedInVarDeclarator)
715
759
: RecordRecord(RK_Union, USR, Name, Parent, Loc, std::move(Availability),
716
- Comment, Declaration, SubHeading, IsFromSystemHeader) {}
760
+ Comment, Declaration, SubHeading, IsFromSystemHeader,
761
+ IsEmbeddedInVarDeclarator) {}
717
762
718
763
static bool classof (const APIRecord *Record) {
719
764
return classofKind (Record->getKind ());
@@ -724,15 +769,16 @@ struct UnionRecord : RecordRecord {
724
769
virtual void anchor ();
725
770
};
726
771
727
- struct CXXFieldRecord : APIRecord {
772
+ struct CXXFieldRecord : APIRecord, RecordContext {
728
773
CXXFieldRecord (StringRef USR, StringRef Name, SymbolReference Parent,
729
774
PresumedLoc Loc, AvailabilityInfo Availability,
730
775
const DocComment &Comment, DeclarationFragments Declaration,
731
776
DeclarationFragments SubHeading, AccessControl Access,
732
777
bool IsFromSystemHeader)
733
778
: APIRecord(RK_CXXField, USR, Name, Parent, Loc, std::move(Availability),
734
779
LinkageInfo::none (), Comment, Declaration, SubHeading,
735
- IsFromSystemHeader, std::move(Access)) {}
780
+ IsFromSystemHeader, std::move(Access)),
781
+ RecordContext(RK_CXXField) {}
736
782
737
783
CXXFieldRecord (RecordKind Kind, StringRef USR, StringRef Name,
738
784
SymbolReference Parent, PresumedLoc Loc,
@@ -742,7 +788,8 @@ struct CXXFieldRecord : APIRecord {
742
788
bool IsFromSystemHeader)
743
789
: APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
744
790
LinkageInfo::none(), Comment, Declaration, SubHeading,
745
- IsFromSystemHeader, std::move(Access)) {}
791
+ IsFromSystemHeader, std::move(Access)),
792
+ RecordContext(Kind) {}
746
793
747
794
static bool classof (const APIRecord *Record) {
748
795
return classofKind (Record->getKind ());
@@ -1118,18 +1165,18 @@ struct ObjCContainerRecord : APIRecord, RecordContext {
1118
1165
virtual ~ObjCContainerRecord () = 0 ;
1119
1166
};
1120
1167
1121
- struct CXXClassRecord : APIRecord, RecordContext {
1168
+ struct CXXClassRecord : RecordRecord {
1122
1169
SmallVector<SymbolReference> Bases;
1123
1170
1124
1171
CXXClassRecord (StringRef USR, StringRef Name, SymbolReference Parent,
1125
1172
PresumedLoc Loc, AvailabilityInfo Availability,
1126
1173
const DocComment &Comment, DeclarationFragments Declaration,
1127
1174
DeclarationFragments SubHeading, RecordKind Kind,
1128
- AccessControl Access, bool IsFromSystemHeader)
1129
- : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
1130
- LinkageInfo::none (), Comment, Declaration, SubHeading ,
1131
- IsFromSystemHeader, std::move(Access)) ,
1132
- RecordContext(Kind ) {}
1175
+ AccessControl Access, bool IsFromSystemHeader,
1176
+ bool IsEmbeddedInVarDeclarator = false )
1177
+ : RecordRecord(Kind, USR, Name, Parent, Loc, std::move(Availability) ,
1178
+ Comment, Declaration, SubHeading, IsFromSystemHeader ,
1179
+ IsEmbeddedInVarDeclarator, std::move(Access) ) {}
1133
1180
1134
1181
static bool classof (const APIRecord *Record) {
1135
1182
return classofKind (Record->getKind ());
0 commit comments