@@ -729,6 +729,62 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
729
729
return {std::move (I), std::move (Parent)};
730
730
}
731
731
732
+ std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
733
+ emitInfo (const VarDecl *D, const FullComment *FC, int LineNumber,
734
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
735
+ auto I = std::make_unique<RecordInfo>();
736
+ bool IsInAnonymousNamespace = false ;
737
+ populateSymbolInfo (*I, D, FC, LineNumber, File, IsFileInRootDir,
738
+ IsInAnonymousNamespace);
739
+ if (!shouldSerializeInfo (PublicOnly, IsInAnonymousNamespace, D))
740
+ return {};
741
+
742
+ I->Path = getInfoRelativePath (I->Namespace );
743
+
744
+ PopulateTemplateParameters (I->Template , D);
745
+
746
+ // Full and partial specializations.
747
+ if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
748
+ if (!I->Template )
749
+ I->Template .emplace ();
750
+ I->Template ->Specialization .emplace ();
751
+ auto &Specialization = *I->Template ->Specialization ;
752
+
753
+ // What this is a specialization of.
754
+ auto SpecOf = CTSD->getSpecializedTemplateOrPartial ();
755
+ if (auto *CTD = dyn_cast<ClassTemplateDecl *>(SpecOf))
756
+ Specialization.SpecializationOf = getUSRForDecl (CTD);
757
+ else if (auto *CTPSD =
758
+ dyn_cast<ClassTemplatePartialSpecializationDecl *>(SpecOf))
759
+ Specialization.SpecializationOf = getUSRForDecl (CTPSD);
760
+
761
+ // Parameters to the specilization. For partial specializations, get the
762
+ // parameters "as written" from the ClassTemplatePartialSpecializationDecl
763
+ // because the non-explicit template parameters will have generated internal
764
+ // placeholder names rather than the names the user typed that match the
765
+ // template parameters.
766
+ if (const ClassTemplatePartialSpecializationDecl *CTPSD =
767
+ dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
768
+ if (const ASTTemplateArgumentListInfo *AsWritten =
769
+ CTPSD->getTemplateArgsAsWritten ()) {
770
+ for (unsigned i = 0 ; i < AsWritten->getNumTemplateArgs (); i++) {
771
+ Specialization.Params .emplace_back (
772
+ getSourceCode (D, (*AsWritten)[i].getSourceRange ()));
773
+ }
774
+ }
775
+ } else {
776
+ for (const TemplateArgument &Arg : CTSD->getTemplateArgs ().asArray ()) {
777
+ Specialization.Params .push_back (TemplateArgumentToInfo (D, Arg));
778
+ }
779
+ }
780
+ }
781
+
782
+ // Records are inserted into the parent by reference, so we need to return
783
+ // both the parent and the record itself.
784
+ auto Parent = MakeAndInsertIntoParent<const RecordInfo &>(*I);
785
+ return {std::move (I), std::move (Parent)};
786
+ }
787
+
732
788
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
733
789
emitInfo (const FunctionDecl *D, const FullComment *FC, int LineNumber,
734
790
llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
0 commit comments