Index: clang-tools-extra/clang-doc/Representation.h =================================================================== --- clang-tools-extra/clang-doc/Representation.h +++ clang-tools-extra/clang-doc/Representation.h @@ -47,6 +47,23 @@ CommentInfo(CommentInfo &Other) = delete; CommentInfo(CommentInfo &&Other) = default; + bool operator==(const CommentInfo &Other) const { + bool AreEqual = + Kind == Other.Kind && Text == Other.Text && Name == Other.Name && + Direction == Other.Direction && ParamName == Other.ParamName && + CloseName == Other.CloseName && SelfClosing == Other.SelfClosing && + Explicit == Other.Explicit && AttrKeys == Other.AttrKeys && + AttrValues == Other.AttrValues && Args == Other.Args && + Children.size() == Other.Children.size(); + if (!AreEqual) + return false; + for (unsigned I = 0; I < Children.size(); ++I) { + if (!(*Children[I] == *Other.Children[I])) + return false; + } + return true; + } + SmallString<16> Kind; // Kind of comment (FullComment, ParagraphComment, TextComment, // InlineCommandComment, HTMLStartTagComment, HTMLEndTagComment, Index: clang-tools-extra/clang-doc/Representation.cpp =================================================================== --- clang-tools-extra/clang-doc/Representation.cpp +++ clang-tools-extra/clang-doc/Representation.cpp @@ -120,8 +120,12 @@ if (Namespace.empty()) Namespace = std::move(Other.Namespace); // Unconditionally extend the description, since each decl may have a comment. - std::move(Other.Description.begin(), Other.Description.end(), - std::back_inserter(Description)); + for (auto &Comment : Other.Description) { + bool IsCommentUnique = std::find(Description.begin(), Description.end(), + Comment) == Description.end(); + if (IsCommentUnique) + Description.emplace_back(std::move(Comment)); + } } bool Info::mergeable(const Info &Other) {