aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
diff options
context:
space:
mode:
authorBrett Wilson <brettw@gmail.com>2022-12-07 10:26:04 -0800
committerBrett Wilson <brettw@gmail.com>2022-12-08 08:02:02 -0800
commit4a68babd9973f043fd3e40f159fbb990880606a6 (patch)
treee6579f1987b03aa880f0a21da6c0bc37cb39326b /clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
parentea4be70cea8509520db8638bb17bcd7b5d8d60ac (diff)
downloadllvm-4a68babd9973f043fd3e40f159fbb990880606a6.zip
llvm-4a68babd9973f043fd3e40f159fbb990880606a6.tar.gz
llvm-4a68babd9973f043fd3e40f159fbb990880606a6.tar.bz2
[clang-doc] Add template support.
Reads template information from the AST and adds template parameters and specialization information to the corresponding clang-doc structures. Add a "QualName" to the Reference struct which includes the full qualified type name. The Reference object represents a link in the HTML/MD generators so is based on the unqualified name. But this does not encode C-V qualifiers or template information that decorate the name. The new QualName member encodes all of this information and also makes it easier for the generators or downsteam YAML consumers to generate the full name (before they had to process the "Path"). In test code that was changed, remove made-up paths to built-in types like "int". In addition to slightnly cleaning up the code, these types do not have paths in real execution, and generating incorrect references to nonexistant data may complicate future changes in the generators. Convert llvm::Optional to std::optional (YAML library requires this for the new usage, and this makes everything consistent according to the llvm::Optional -> std::optional transition). Differential Revision: https://reviews.llvm.org/D139154
Diffstat (limited to 'clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp')
-rw-r--r--clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
index d912253..51412591 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -44,9 +44,10 @@ TEST(HTMLGeneratorTest, emitNamespaceHTML) {
I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
I.Children.Namespaces.emplace_back(EmptySID, "ChildNamespace",
- InfoType::IT_namespace, "Namespace");
+ InfoType::IT_namespace,
+ "Namespace::ChildNamespace", "Namespace");
I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
- "Namespace");
+ "Namespace::ChildStruct", "Namespace");
I.Children.Functions.emplace_back();
I.Children.Functions.back().Access = AccessSpecifier::AS_none;
I.Children.Functions.back().Name = "OneFunction";
@@ -152,14 +153,13 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
SmallString<16> PathTo;
llvm::sys::path::native("path/to", PathTo);
- I.Members.emplace_back(TypeInfo("int", "X/Y"), "X",
- AccessSpecifier::AS_private);
+ I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private);
I.TagType = TagTypeKind::TTK_Class;
- I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
+ I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "F", PathTo);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
- "X/Y/Z/r");
+ "X::Y::Z::r::ChildStruct", "X/Y/Z/r");
I.Children.Functions.emplace_back();
I.Children.Functions.back().Name = "OneFunction";
I.Children.Enums.emplace_back();
@@ -195,11 +195,7 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
</p>
<h2 id="Members">Members</h2>
<ul>
- <li>
- private
- <a href="../../../X/Y/int.html">int</a>
- X
- </li>
+ <li>private int X</li>
</ul>
<h2 id="Records">Records</h2>
<ul>
@@ -277,8 +273,8 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) {
SmallString<16> PathTo;
llvm::sys::path::native("path/to", PathTo);
- I.ReturnType =
- TypeInfo(Reference(EmptySID, "float", InfoType::IT_default, PathTo));
+ I.ReturnType = TypeInfo(
+ Reference(EmptySID, "float", InfoType::IT_default, "float", PathTo));
I.Params.emplace_back(TypeInfo("int", PathTo), "P");
I.IsMethod = true;
I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);