From 93a290fdc974007ed3eeb7be11b527f66f43a01d Mon Sep 17 00:00:00 2001 From: Julie Hockett Date: Fri, 28 Jun 2019 18:17:58 +0000 Subject: [clang-doc] De-duplicate comments and locations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit De-duplicate comments and declaration locations in reduce function. When two files include the same header file, this file's content is mapped twice causing comments and locations to be duplicated after the reduce stage. Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com). Differential Revision: https://reviews.llvm.org/D62970 llvm-svn: 364670 --- .../unittests/clang-doc/MergeTest.cpp | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'clang-tools-extra/unittests/clang-doc/MergeTest.cpp') diff --git a/clang-tools-extra/unittests/clang-doc/MergeTest.cpp b/clang-tools-extra/unittests/clang-doc/MergeTest.cpp index 7adc1f3d154..7b3e2302ac2 100644 --- a/clang-tools-extra/unittests/clang-doc/MergeTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/MergeTest.cpp @@ -159,15 +159,37 @@ TEST(MergeTest, mergeFunctionInfos) { One.IsMethod = true; One.Parent = Reference(EmptySID, "Parent", InfoType::IT_namespace); + One.Description.emplace_back(); + auto OneFullComment = &One.Description.back(); + OneFullComment->Kind = "FullComment"; + auto OneParagraphComment = llvm::make_unique(); + OneParagraphComment->Kind = "ParagraphComment"; + auto OneTextComment = llvm::make_unique(); + OneTextComment->Kind = "TextComment"; + OneTextComment->Text = "This is a text comment."; + OneParagraphComment->Children.push_back(std::move(OneTextComment)); + OneFullComment->Children.push_back(std::move(OneParagraphComment)); + FunctionInfo Two; Two.Name = "f"; Two.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); - Two.Loc.emplace_back(20, llvm::SmallString<16>{"test.cpp"}); + Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); Two.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); Two.Params.emplace_back("int", "P"); + Two.Description.emplace_back(); + auto TwoFullComment = &Two.Description.back(); + TwoFullComment->Kind = "FullComment"; + auto TwoParagraphComment = llvm::make_unique(); + TwoParagraphComment->Kind = "ParagraphComment"; + auto TwoTextComment = llvm::make_unique(); + TwoTextComment->Kind = "TextComment"; + TwoTextComment->Text = "This is a text comment."; + TwoParagraphComment->Children.push_back(std::move(TwoTextComment)); + TwoFullComment->Children.push_back(std::move(TwoParagraphComment)); + std::vector> Infos; Infos.emplace_back(llvm::make_unique(std::move(One))); Infos.emplace_back(llvm::make_unique(std::move(Two))); @@ -178,13 +200,23 @@ TEST(MergeTest, mergeFunctionInfos) { Expected->DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); Expected->Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - Expected->Loc.emplace_back(20, llvm::SmallString<16>{"test.cpp"}); Expected->ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); Expected->Params.emplace_back("int", "P"); Expected->IsMethod = true; Expected->Parent = Reference(EmptySID, "Parent", InfoType::IT_namespace); + Expected->Description.emplace_back(); + auto ExpectedFullComment = &Expected->Description.back(); + ExpectedFullComment->Kind = "FullComment"; + auto ExpectedParagraphComment = llvm::make_unique(); + ExpectedParagraphComment->Kind = "ParagraphComment"; + auto ExpectedTextComment = llvm::make_unique(); + ExpectedTextComment->Kind = "TextComment"; + ExpectedTextComment->Text = "This is a text comment."; + ExpectedParagraphComment->Children.push_back(std::move(ExpectedTextComment)); + ExpectedFullComment->Children.push_back(std::move(ExpectedParagraphComment)); + auto Actual = mergeInfos(Infos); assert(Actual); CheckFunctionInfo(InfoAsFunction(Expected.get()), -- cgit v1.2.3