@@ -535,22 +535,18 @@ static void populateInfo(Info &I, const T *D, const FullComment *C,
535
535
536
536
template <typename T>
537
537
static void populateSymbolInfo (SymbolInfo &I, const T *D, const FullComment *C,
538
- int LineNumber, StringRef Filename,
539
- bool IsFileInRootDir,
540
- bool &IsInAnonymousNamespace) {
538
+ Location Loc, bool &IsInAnonymousNamespace) {
541
539
populateInfo (I, D, C, IsInAnonymousNamespace);
542
540
if (D->isThisDeclarationADefinition ())
543
- I.DefLoc . emplace (LineNumber, Filename, IsFileInRootDir) ;
541
+ I.DefLoc = Loc ;
544
542
else
545
- I.Loc .emplace_back (LineNumber, Filename, IsFileInRootDir );
543
+ I.Loc .emplace_back (Loc );
546
544
}
547
545
548
546
static void populateFunctionInfo (FunctionInfo &I, const FunctionDecl *D,
549
- const FullComment *FC, int LineNumber,
550
- StringRef Filename, bool IsFileInRootDir,
547
+ const FullComment *FC, Location Loc,
551
548
bool &IsInAnonymousNamespace) {
552
- populateSymbolInfo (I, D, FC, LineNumber, Filename, IsFileInRootDir,
553
- IsInAnonymousNamespace);
549
+ populateSymbolInfo (I, D, FC, Loc, IsInAnonymousNamespace);
554
550
auto &LO = D->getLangOpts ();
555
551
I.ReturnType = getTypeInfoForType (D->getReturnType (), LO);
556
552
parseParameters (I, D);
@@ -579,7 +575,7 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D,
579
575
static void populateMemberTypeInfo (MemberTypeInfo &I, const Decl *D) {
580
576
assert (D && " Expect non-null FieldDecl in populateMemberTypeInfo" );
581
577
582
- ASTContext& Context = D->getASTContext ();
578
+ ASTContext & Context = D->getASTContext ();
583
579
// TODO investigate whether we can use ASTContext::getCommentForDecl instead
584
580
// of this logic. See also similar code in Mapper.cpp.
585
581
RawComment *Comment = Context.getRawCommentForDeclNoCache (D);
@@ -643,8 +639,7 @@ parseBases(RecordInfo &I, const CXXRecordDecl *D, bool IsFileInRootDir,
643
639
// reference, its value is not relevant in here so it's not used
644
640
// anywhere besides the function call.
645
641
bool IsInAnonymousNamespace;
646
- populateFunctionInfo (FI, MD, /* FullComment=*/ {}, /* LineNumber=*/ {},
647
- /* FileName=*/ {}, IsFileInRootDir,
642
+ populateFunctionInfo (FI, MD, /* FullComment=*/ {}, /* Location=*/ {},
648
643
IsInAnonymousNamespace);
649
644
FI.Access =
650
645
getFinalAccessSpecifier (BI.Access , MD->getAccessUnsafe ());
@@ -662,8 +657,8 @@ parseBases(RecordInfo &I, const CXXRecordDecl *D, bool IsFileInRootDir,
662
657
}
663
658
664
659
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
665
- emitInfo (const NamespaceDecl *D, const FullComment *FC, int LineNumber ,
666
- llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
660
+ emitInfo (const NamespaceDecl *D, const FullComment *FC, Location Loc ,
661
+ bool PublicOnly) {
667
662
auto NSI = std::make_unique<NamespaceInfo>();
668
663
bool IsInAnonymousNamespace = false ;
669
664
populateInfo (*NSI, D, FC, IsInAnonymousNamespace);
@@ -683,12 +678,11 @@ emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber,
683
678
}
684
679
685
680
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
686
- emitInfo (const RecordDecl *D, const FullComment *FC, int LineNumber ,
687
- llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
681
+ emitInfo (const RecordDecl *D, const FullComment *FC, Location Loc ,
682
+ bool PublicOnly) {
688
683
auto RI = std::make_unique<RecordInfo>();
689
684
bool IsInAnonymousNamespace = false ;
690
- populateSymbolInfo (*RI, D, FC, LineNumber, File, IsFileInRootDir,
691
- IsInAnonymousNamespace);
685
+ populateSymbolInfo (*RI, D, FC, Loc, IsInAnonymousNamespace);
692
686
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
693
687
return {};
694
688
@@ -701,7 +695,7 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
701
695
}
702
696
// TODO: remove first call to parseBases, that function should be deleted
703
697
parseBases (*RI, C);
704
- parseBases (*RI, C, IsFileInRootDir, PublicOnly, true );
698
+ parseBases (*RI, C, /* IsFileInRootDir= */ true , PublicOnly, /* IsParent= */ true );
705
699
}
706
700
RI->Path = getInfoRelativePath (RI->Namespace );
707
701
@@ -750,12 +744,11 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
750
744
}
751
745
752
746
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
753
- emitInfo (const FunctionDecl *D, const FullComment *FC, int LineNumber ,
754
- llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
747
+ emitInfo (const FunctionDecl *D, const FullComment *FC, Location Loc ,
748
+ bool PublicOnly) {
755
749
FunctionInfo Func;
756
750
bool IsInAnonymousNamespace = false ;
757
- populateFunctionInfo (Func, D, FC, LineNumber, File, IsFileInRootDir,
758
- IsInAnonymousNamespace);
751
+ populateFunctionInfo (Func, D, FC, Loc, IsInAnonymousNamespace);
759
752
Func.Access = clang::AccessSpecifier::AS_none;
760
753
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
761
754
return {};
@@ -765,12 +758,11 @@ emitInfo(const FunctionDecl *D, const FullComment *FC, int LineNumber,
765
758
}
766
759
767
760
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
768
- emitInfo (const CXXMethodDecl *D, const FullComment *FC, int LineNumber ,
769
- llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
761
+ emitInfo (const CXXMethodDecl *D, const FullComment *FC, Location Loc ,
762
+ bool PublicOnly) {
770
763
FunctionInfo Func;
771
764
bool IsInAnonymousNamespace = false ;
772
- populateFunctionInfo (Func, D, FC, LineNumber, File, IsFileInRootDir,
773
- IsInAnonymousNamespace);
765
+ populateFunctionInfo (Func, D, FC, Loc, IsInAnonymousNamespace);
774
766
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
775
767
return {};
776
768
@@ -795,43 +787,52 @@ emitInfo(const CXXMethodDecl *D, const FullComment *FC, int LineNumber,
795
787
}
796
788
797
789
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
798
- emitInfo (const TypedefDecl *D, const FullComment *FC, int LineNumber,
799
- StringRef File, bool IsFileInRootDir, bool PublicOnly) {
800
- TypedefInfo Info;
790
+ emitInfo (const TypedefDecl *D, const FullComment *FC, Location Loc,
791
+ bool PublicOnly) {
801
792
793
+ TypedefInfo Info;
794
+ ASTContext &Context = D->getASTContext ();
802
795
bool IsInAnonymousNamespace = false ;
803
796
populateInfo (Info, D, FC, IsInAnonymousNamespace);
797
+
804
798
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
805
799
return {};
806
800
807
- Info.DefLoc . emplace (LineNumber, File, IsFileInRootDir) ;
801
+ Info.DefLoc = Loc ;
808
802
auto &LO = D->getLangOpts ();
809
803
Info.Underlying = getTypeInfoForType (D->getUnderlyingType (), LO);
804
+
810
805
if (Info.Underlying .Type .Name .empty ()) {
811
806
// Typedef for an unnamed type. This is like "typedef struct { } Foo;"
812
807
// The record serializer explicitly checks for this syntax and constructs
813
808
// a record with that name, so we don't want to emit a duplicate here.
814
809
return {};
815
810
}
816
811
Info.IsUsing = false ;
817
-
812
+ if (RawComment *Comment = D->getASTContext ().getRawCommentForDeclNoCache (D)) {
813
+ Comment->setAttached ();
814
+ if (comments::FullComment *Fc = Comment->parse (Context, nullptr , D)) {
815
+ Info.Description .emplace_back ();
816
+ parseFullComment (Fc, Info.Description .back ());
817
+ }
818
+ }
818
819
// Info is wrapped in its parent scope so is returned in the second position.
819
820
return {nullptr , makeAndInsertIntoParent<TypedefInfo &&>(std::move (Info))};
820
821
}
821
822
822
823
// A type alias is a C++ "using" declaration for a type. It gets mapped to a
823
824
// TypedefInfo with the IsUsing flag set.
824
825
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
825
- emitInfo (const TypeAliasDecl *D, const FullComment *FC, int LineNumber ,
826
- StringRef File, bool IsFileInRootDir, bool PublicOnly) {
826
+ emitInfo (const TypeAliasDecl *D, const FullComment *FC, Location Loc ,
827
+ bool PublicOnly) {
827
828
TypedefInfo Info;
828
829
829
830
bool IsInAnonymousNamespace = false ;
830
831
populateInfo (Info, D, FC, IsInAnonymousNamespace);
831
832
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
832
833
return {};
833
834
834
- Info.DefLoc . emplace (LineNumber, File, IsFileInRootDir) ;
835
+ Info.DefLoc = Loc ;
835
836
auto &LO = D->getLangOpts ();
836
837
Info.Underlying = getTypeInfoForType (D->getUnderlyingType (), LO);
837
838
Info.IsUsing = true ;
@@ -841,12 +842,12 @@ emitInfo(const TypeAliasDecl *D, const FullComment *FC, int LineNumber,
841
842
}
842
843
843
844
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
844
- emitInfo (const EnumDecl *D, const FullComment *FC, int LineNumber ,
845
- llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
845
+ emitInfo (const EnumDecl *D, const FullComment *FC, Location Loc ,
846
+ bool PublicOnly) {
846
847
EnumInfo Enum;
847
848
bool IsInAnonymousNamespace = false ;
848
- populateSymbolInfo (Enum, D, FC, LineNumber, File, IsFileInRootDir,
849
- IsInAnonymousNamespace);
849
+ populateSymbolInfo (Enum, D, FC, Loc, IsInAnonymousNamespace);
850
+
850
851
if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
851
852
return {};
852
853
0 commit comments