[clang-tools-extra] [clang-doc] fix names of conversions for template parameters (PR #140856)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Tue May 20 23:57:47 PDT 2025
https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/140856
Fixes #59812
The names of conversion functions of template type parameters were being emitted as "type-parameter-N-M". Now we check if the conversion type is a TemplateTypeParmType and reconstruct the source name.
>From e25581d28ecda89fe4e550da71e668b6ae749804 Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Tue, 20 May 2025 23:26:02 -0700
Subject: [PATCH] [clang-doc] fix conversion names of dependent types
Fixes #59812
The names of conversion functions of template type parameters were
being emitted as "type-parameter-N-M". Now we check if the conversion
type is a TemplateTypeParmType and reconstruct the source name.
---
clang-tools-extra/clang-doc/Serialize.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 18db427b5239e..585a46112d43d 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -525,7 +525,13 @@ template <typename T>
static void populateInfo(Info &I, const T *D, const FullComment *C,
bool &IsInAnonymousNamespace) {
I.USR = getUSRForDecl(D);
- I.Name = D->getNameAsString();
+ auto ConversionDecl = dyn_cast_or_null<CXXConversionDecl>(D);
+ if (ConversionDecl && ConversionDecl->getConversionType()
+ .getTypePtr()
+ ->isTemplateTypeParmType())
+ I.Name = "operator " + ConversionDecl->getConversionType().getAsString();
+ else
+ I.Name = D->getNameAsString();
populateParentNamespaces(I.Namespace, D, IsInAnonymousNamespace);
if (C) {
I.Description.emplace_back();
More information about the cfe-commits
mailing list