diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -392,6 +392,11 @@ return &I->Description.back(); } +template <> llvm::Expected getCommentInfo(TypedefInfo *I) { + I->Description.emplace_back(); + return &I->Description.back(); +} + template <> llvm::Expected getCommentInfo(CommentInfo *I) { I->Children.emplace_back(std::make_unique()); return I->Children.back().get(); diff --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp b/clang-tools-extra/clang-doc/BitcodeWriter.cpp --- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp +++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp @@ -432,6 +432,8 @@ emitRecord(T.Name, TYPEDEF_NAME); for (const auto &N : T.Namespace) emitBlock(N, FieldId::F_namespace); + for (const auto &CI : T.Description) + emitBlock(CI); if (T.DefLoc) emitRecord(*T.DefLoc, TYPEDEF_DEFLOCATION); emitRecord(T.IsUsing, TYPEDEF_IS_USING); diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h --- a/clang-tools-extra/clang-doc/Representation.h +++ b/clang-tools-extra/clang-doc/Representation.h @@ -365,7 +365,7 @@ // using MyVector = std::vector // False means it's a C-style typedef: // typedef std::vector MyVector; - bool IsUsing; + bool IsUsing = false; }; struct BaseRecordInfo : public RecordInfo { diff --git a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp --- a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp @@ -183,6 +183,17 @@ I.Underlying = TypeInfo("unsigned"); I.IsUsing = true; + CommentInfo Top; + Top.Kind = "FullComment"; + + Top.Children.emplace_back(std::make_unique()); + CommentInfo *BlankLine = Top.Children.back().get(); + BlankLine->Kind = "ParagraphComment"; + BlankLine->Children.emplace_back(std::make_unique()); + BlankLine->Children.back()->Kind = "TextComment"; + + I.Description.emplace_back(std::move(Top)); + std::string WriteResult = writeInfo(&I); EXPECT_TRUE(WriteResult.size() > 0); std::vector> ReadResults = readInfo(WriteResult, 1);