diff options
author | Brett Wilson <brettw@gmail.com> | 2022-12-07 10:22:05 -0800 |
---|---|---|
committer | Brett Wilson <brettw@gmail.com> | 2022-12-07 10:22:51 -0800 |
commit | 91b38c6aaddefabad2a4c959ea3865e356761ed5 (patch) | |
tree | d1bc4aa66f0e8d9a7c2a06b03b713b383a23f7be /clang-tools-extra/unittests | |
parent | f1fd5c9b365b1280923fa83444af024fa5204a29 (diff) | |
download | llvm-91b38c6aaddefabad2a4c959ea3865e356761ed5.zip llvm-91b38c6aaddefabad2a4c959ea3865e356761ed5.tar.gz llvm-91b38c6aaddefabad2a4c959ea3865e356761ed5.tar.bz2 |
Revert "[clang-doc] Add template support."
Causes a build failure in YAML specializations.
This reverts commit 0f6dbb5f164662c3e6a167a89e7a89f07c60e32b.
Diffstat (limited to 'clang-tools-extra/unittests')
3 files changed, 42 insertions, 153 deletions
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp index 5141259..d912253 100644 --- a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -44,10 +44,9 @@ TEST(HTMLGeneratorTest, emitNamespaceHTML) { I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); I.Children.Namespaces.emplace_back(EmptySID, "ChildNamespace", - InfoType::IT_namespace, - "Namespace::ChildNamespace", "Namespace"); + InfoType::IT_namespace, "Namespace"); I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record, - "Namespace::ChildStruct", "Namespace"); + "Namespace"); I.Children.Functions.emplace_back(); I.Children.Functions.back().Access = AccessSpecifier::AS_none; I.Children.Functions.back().Name = "OneFunction"; @@ -153,13 +152,14 @@ TEST(HTMLGeneratorTest, emitRecordHTML) { SmallString<16> PathTo; llvm::sys::path::native("path/to", PathTo); - I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private); + I.Members.emplace_back(TypeInfo("int", "X/Y"), "X", + AccessSpecifier::AS_private); I.TagType = TagTypeKind::TTK_Class; - I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "F", PathTo); + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record, - "X::Y::Z::r::ChildStruct", "X/Y/Z/r"); + "X/Y/Z/r"); I.Children.Functions.emplace_back(); I.Children.Functions.back().Name = "OneFunction"; I.Children.Enums.emplace_back(); @@ -195,7 +195,11 @@ TEST(HTMLGeneratorTest, emitRecordHTML) { </p> <h2 id="Members">Members</h2> <ul> - <li>private int X</li> + <li> + private + <a href="../../../X/Y/int.html">int</a> + X + </li> </ul> <h2 id="Records">Records</h2> <ul> @@ -273,8 +277,8 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) { SmallString<16> PathTo; llvm::sys::path::native("path/to", PathTo); - I.ReturnType = TypeInfo( - Reference(EmptySID, "float", InfoType::IT_default, "float", PathTo)); + I.ReturnType = + TypeInfo(Reference(EmptySID, "float", InfoType::IT_default, PathTo)); I.Params.emplace_back(TypeInfo("int", PathTo), "P"); I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); diff --git a/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp b/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp index ca370de..05b6245 100644 --- a/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp @@ -390,7 +390,7 @@ class J : public I<int> {} ;)raw", RecordInfo *F = InfoAsRecord(Infos[0].get()); RecordInfo ExpectedF(EmptySID, /*Name=*/"F", /*Path=*/"GlobalNamespace"); ExpectedF.Namespace.emplace_back(EmptySID, "GlobalNamespace", - InfoType::IT_namespace, ""); + InfoType::IT_namespace); ExpectedF.TagType = TagTypeKind::TTK_Class; ExpectedF.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); CheckRecordInfo(&ExpectedF, F); @@ -410,10 +410,9 @@ class J : public I<int> {} ;)raw", ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace", InfoType::IT_namespace); ExpectedE.Parents.emplace_back(EmptySID, /*Name=*/"F", InfoType::IT_record, - /*QualName=*/"", /*Path*=*/"GlobalNamespace"); - ExpectedE.VirtualParents.emplace_back(EmptySID, /*Name=*/"G", - InfoType::IT_record, /*QualName=*/"G", - /*Path*=*/"GlobalNamespace"); + /*Path*=*/"GlobalNamespace"); + ExpectedE.VirtualParents.emplace_back( + EmptySID, /*Name=*/"G", InfoType::IT_record, /*Path*=*/"GlobalNamespace"); ExpectedE.Bases.emplace_back(EmptySID, /*Name=*/"F", /*Path=*/"GlobalNamespace", false, AccessSpecifier::AS_public, true); @@ -456,10 +455,9 @@ class J : public I<int> {} ;)raw", ExpectedH.TagType = TagTypeKind::TTK_Class; ExpectedH.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"}); ExpectedH.Parents.emplace_back(EmptySID, /*Name=*/"E", InfoType::IT_record, - /*QualName=*/"E", /*Path=*/"GlobalNamespace"); - ExpectedH.VirtualParents.emplace_back(EmptySID, /*Name=*/"G", - InfoType::IT_record, /*QualName=*/"G", - /*Path=*/"GlobalNamespace"); + /*Path=*/"GlobalNamespace"); + ExpectedH.VirtualParents.emplace_back( + EmptySID, /*Name=*/"G", InfoType::IT_record, /*Path=*/"GlobalNamespace"); ExpectedH.Bases.emplace_back(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace", false, AccessSpecifier::AS_private, true); @@ -564,7 +562,7 @@ TEST(SerializeTest, emitChildRecords) { NamespaceInfo *ParentA = InfoAsNamespace(Infos[1].get()); NamespaceInfo ExpectedParentA(EmptySID); ExpectedParentA.Children.Records.emplace_back( - EmptySID, "A", InfoType::IT_record, "A", "GlobalNamespace"); + EmptySID, "A", InfoType::IT_record, "GlobalNamespace"); CheckNamespaceInfo(&ExpectedParentA, ParentA); RecordInfo *ParentB = InfoAsRecord(Infos[3].get()); @@ -572,13 +570,13 @@ TEST(SerializeTest, emitChildRecords) { llvm::SmallString<128> ExpectedParentBPath("GlobalNamespace/A"); llvm::sys::path::native(ExpectedParentBPath); ExpectedParentB.Children.Records.emplace_back( - EmptySID, "B", InfoType::IT_record, "A::B", ExpectedParentBPath); + EmptySID, "B", InfoType::IT_record, ExpectedParentBPath); CheckRecordInfo(&ExpectedParentB, ParentB); NamespaceInfo *ParentC = InfoAsNamespace(Infos[7].get()); NamespaceInfo ExpectedParentC(EmptySID); ExpectedParentC.Children.Records.emplace_back( - EmptySID, "C", InfoType::IT_record, "C", "@nonymous_namespace"); + EmptySID, "C", InfoType::IT_record, "@nonymous_namespace"); CheckNamespaceInfo(&ExpectedParentC, ParentC); } @@ -596,8 +594,8 @@ TEST(SerializeTest, emitChildNamespaces) { NamespaceInfo *ParentB = InfoAsNamespace(Infos[3].get()); NamespaceInfo ExpectedParentB(EmptySID); - ExpectedParentB.Children.Namespaces.emplace_back( - EmptySID, "B", InfoType::IT_namespace, "A::B", "A"); + ExpectedParentB.Children.Namespaces.emplace_back(EmptySID, "B", + InfoType::IT_namespace, "A"); CheckNamespaceInfo(&ExpectedParentB, ParentB); } @@ -628,105 +626,5 @@ TEST(SerializeTests, emitTypedefs) { EXPECT_EQ("double", SecondTD.Underlying.Type.Name); } -TEST(SerializeTests, emitFunctionTemplate) { - EmittedInfoList Infos; - // A template and a specialization. - ExtractInfosFromCode("template<typename T = int> void GetFoo(T);\n" - "template<> void GetFoo<bool>(bool);", - 2, - /*Public=*/false, Infos); - - // First info will be the global namespace. - NamespaceInfo *GlobalNS1 = InfoAsNamespace(Infos[0].get()); - ASSERT_EQ(1u, GlobalNS1->Children.Functions.size()); - - const FunctionInfo &Func1 = GlobalNS1->Children.Functions[0]; - EXPECT_EQ("GetFoo", Func1.Name); - ASSERT_TRUE(Func1.Template); - EXPECT_FALSE(Func1.Template->Specialization); // Not a specialization. - - // Template parameter. - ASSERT_EQ(1u, Func1.Template->Params.size()); - EXPECT_EQ("typename T = int", Func1.Template->Params[0].Contents); - - // The second will be another global namespace with the function in it (the - // global namespace is duplicated because the items haven't been merged at the - // serialization phase of processing). - NamespaceInfo *GlobalNS2 = InfoAsNamespace(Infos[1].get()); - ASSERT_EQ(1u, GlobalNS2->Children.Functions.size()); - - // This one is a template specialization. - const FunctionInfo &Func2 = GlobalNS2->Children.Functions[0]; - EXPECT_EQ("GetFoo", Func2.Name); - ASSERT_TRUE(Func2.Template); - EXPECT_TRUE(Func2.Template->Params.empty()); // No template params. - ASSERT_TRUE(Func2.Template->Specialization); - - // Specialization values. - ASSERT_EQ(1u, Func2.Template->Specialization->Params.size()); - EXPECT_EQ("bool", Func2.Template->Specialization->Params[0].Contents); - EXPECT_EQ(Func1.USR, Func2.Template->Specialization->SpecializationOf); -} - -TEST(SerializeTests, emitClassTemplate) { - EmittedInfoList Infos; - // This will generate 2x the number of infos: each Record will be followed by - // a copy of the global namespace containing it (this test checks the data - // pre-merge). - ExtractInfosFromCode( - "template<int I> class MyTemplate { int i[I]; };\n" - "template<> class MyTemplate<0> {};\n" - "template<typename T, int U = 1> class OtherTemplate {};\n" - "template<int U> class OtherTemplate<MyTemplate<0>, U> {};", - 8, - /*Public=*/false, Infos); - - // First record. - const RecordInfo *Rec1 = InfoAsRecord(Infos[0].get()); - EXPECT_EQ("MyTemplate", Rec1->Name); - ASSERT_TRUE(Rec1->Template); - EXPECT_FALSE(Rec1->Template->Specialization); // Not a specialization. - - // First record template parameter. - ASSERT_EQ(1u, Rec1->Template->Params.size()); - EXPECT_EQ("int I", Rec1->Template->Params[0].Contents); - - // Second record. - const RecordInfo *Rec2 = InfoAsRecord(Infos[2].get()); - EXPECT_EQ("MyTemplate", Rec2->Name); - ASSERT_TRUE(Rec2->Template); - EXPECT_TRUE(Rec2->Template->Params.empty()); // No template params. - ASSERT_TRUE(Rec2->Template->Specialization); - - // Second record specialization values. - ASSERT_EQ(1u, Rec2->Template->Specialization->Params.size()); - EXPECT_EQ("0", Rec2->Template->Specialization->Params[0].Contents); - EXPECT_EQ(Rec1->USR, Rec2->Template->Specialization->SpecializationOf); - - // Third record. - const RecordInfo *Rec3 = InfoAsRecord(Infos[4].get()); - EXPECT_EQ("OtherTemplate", Rec3->Name); - ASSERT_TRUE(Rec3->Template); - - // Third record template parameters. - ASSERT_EQ(2u, Rec3->Template->Params.size()); - EXPECT_EQ("typename T", Rec3->Template->Params[0].Contents); - EXPECT_EQ("int U = 1", Rec3->Template->Params[1].Contents); - - // Fourth record. - const RecordInfo *Rec4 = InfoAsRecord(Infos[6].get()); - EXPECT_EQ("OtherTemplate", Rec3->Name); - ASSERT_TRUE(Rec4->Template); - ASSERT_TRUE(Rec4->Template->Specialization); - - // Fourth record template + specialization parameters. - ASSERT_EQ(1u, Rec4->Template->Params.size()); - EXPECT_EQ("int U", Rec4->Template->Params[0].Contents); - ASSERT_EQ(2u, Rec4->Template->Specialization->Params.size()); - EXPECT_EQ("MyTemplate<0>", - Rec4->Template->Specialization->Params[0].Contents); - EXPECT_EQ("U", Rec4->Template->Specialization->Params[1].Contents); -} - } // namespace doc } // end namespace clang diff --git a/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp index 535d491..d6410f2 100644 --- a/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp @@ -28,11 +28,10 @@ TEST(YAMLGeneratorTest, emitNamespaceYAML) { I.Path = "path/to/A"; I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); - I.Children.Namespaces.emplace_back( - EmptySID, "ChildNamespace", InfoType::IT_namespace, - "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace"); + I.Children.Namespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace, + "path/to/A/Namespace"); I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record, - "path::to::A::Namespace::ChildStruct", "path/to/A/Namespace"); I.Children.Functions.emplace_back(); I.Children.Functions.back().Name = "OneFunction"; @@ -54,16 +53,13 @@ Path: 'path/to/A' Namespace: - Type: Namespace Name: 'A' - QualName: 'A' ChildNamespaces: - Type: Namespace Name: 'ChildNamespace' - QualName: 'path::to::A::Namespace::ChildNamespace' Path: 'path/to/A/Namespace' ChildRecords: - Type: Record Name: 'ChildStruct' - QualName: 'path::to::A::Namespace::ChildStruct' Path: 'path/to/A/Namespace' ChildFunctions: - USR: '0000000000000000000000000000000000000000' @@ -87,7 +83,8 @@ TEST(YAMLGeneratorTest, emitRecordYAML) { I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); - I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private); + I.Members.emplace_back(TypeInfo("int", "path/to/int"), "X", + AccessSpecifier::AS_private); // Member documentation. CommentInfo TopComment; @@ -106,15 +103,15 @@ TEST(YAMLGeneratorTest, emitRecordYAML) { AccessSpecifier::AS_public, true); I.Bases.back().Children.Functions.emplace_back(); I.Bases.back().Children.Functions.back().Name = "InheritedFunctionOne"; - I.Bases.back().Members.emplace_back(TypeInfo("int"), "N", + I.Bases.back().Members.emplace_back(TypeInfo("int", "path/to/int"), "N", AccessSpecifier::AS_private); // F is in the global namespace I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, ""); I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record, - "path::to::G::G", "path/to/G"); + "path/to/G"); I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record, - "path::to::A::r::ChildStruct", "path/to/A/r"); + "path/to/A/r"); I.Children.Functions.emplace_back(); I.Children.Functions.back().Name = "OneFunction"; I.Children.Enums.emplace_back(); @@ -134,7 +131,6 @@ Path: 'path/to/A' Namespace: - Type: Namespace Name: 'A' - QualName: 'A' DefLocation: LineNumber: 10 Filename: 'test.cpp' @@ -146,7 +142,7 @@ IsTypeDef: true Members: - Type: Name: 'int' - QualName: 'int' + Path: 'path/to/int' Name: 'X' Access: Private Description: @@ -165,7 +161,7 @@ Bases: Members: - Type: Name: 'int' - QualName: 'int' + Path: 'path/to/int' Name: 'N' Access: Private ChildFunctions: @@ -182,12 +178,10 @@ Parents: VirtualParents: - Type: Record Name: 'G' - QualName: 'path::to::G::G' Path: 'path/to/G' ChildRecords: - Type: Record Name: 'ChildStruct' - QualName: 'path::to::A::r::ChildStruct' Path: 'path/to/A/r' ChildFunctions: - USR: '0000000000000000000000000000000000000000' @@ -212,9 +206,10 @@ TEST(YAMLGeneratorTest, emitFunctionYAML) { I.Access = AccessSpecifier::AS_none; - I.ReturnType = TypeInfo(Reference(EmptySID, "void", InfoType::IT_default)); - I.Params.emplace_back(TypeInfo("int"), "P"); - I.Params.emplace_back(TypeInfo("double"), "D"); + I.ReturnType = TypeInfo( + Reference(EmptySID, "void", InfoType::IT_default, "path/to/void")); + I.Params.emplace_back(TypeInfo("int", "path/to/int"), "P"); + I.Params.emplace_back(TypeInfo("double", "path/to/double"), "D"); I.Params.back().DefaultValue = "2.0 * M_PI"; I.IsMethod = true; I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); @@ -232,7 +227,6 @@ Name: 'f' Namespace: - Type: Namespace Name: 'A' - QualName: 'A' DefLocation: LineNumber: 10 Filename: 'test.cpp' @@ -243,21 +237,20 @@ IsMethod: true Parent: Type: Record Name: 'Parent' - QualName: 'Parent' Params: - Type: Name: 'int' - QualName: 'int' + Path: 'path/to/int' Name: 'P' - Type: Name: 'double' - QualName: 'double' + Path: 'path/to/double' Name: 'D' DefaultValue: '2.0 * M_PI' ReturnType: Type: Name: 'void' - QualName: 'void' + Path: 'path/to/void' ... )raw"; EXPECT_EQ(Expected, Actual.str()); @@ -291,7 +284,6 @@ Name: 'e' Namespace: - Type: Namespace Name: 'A' - QualName: 'A' DefLocation: LineNumber: 10 Filename: 'test.cpp' @@ -330,7 +322,6 @@ Scoped: true BaseType: Type: Name: 'short' - QualName: 'short' Members: - Name: 'X' Value: '-9876' @@ -358,7 +349,6 @@ USR: '0000000000000000000000000000000000000000' Name: 'MyUsing' Underlying: Name: 'int' - QualName: 'int' IsUsing: true ... )raw"; @@ -558,16 +548,13 @@ DefLocation: Params: - Type: Name: 'int' - QualName: 'int' Name: 'I' - Type: Name: 'int' - QualName: 'int' Name: 'J' ReturnType: Type: Name: 'void' - QualName: 'void' ... )raw"; |