[clang] [RFC] Initial implementation of P2719 (PR #113510)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 7 00:20:43 PST 2025


================
@@ -3128,6 +3128,26 @@ bool Type::isStdByteType() const {
   return false;
 }
 
+static const TemplateDecl *getSpecializedTemplateType(const Type *T) {
+  const Type *DesugaredType = T->getUnqualifiedDesugaredType();
+  if (const auto *Specialization =
+          DesugaredType->getAs<TemplateSpecializationType>())
+    return Specialization->getTemplateName().getAsTemplateDecl();
+  if (const auto *Record = DesugaredType->getAsCXXRecordDecl()) {
+    if (const auto *CTS = dyn_cast<ClassTemplateSpecializationDecl>(Record))
+      return CTS->getSpecializedTemplate();
+  }
+  return nullptr;
+}
+
+bool Type::isTypeIdentitySpecialization() const {
+  const TemplateDecl *STDecl = getSpecializedTemplateType(this);
+  if (!STDecl)
+    return false;
+  IdentifierInfo *II = STDecl->getIdentifier();
+  return II && STDecl->isInStdNamespace() && II->isStr("type_identity");
----------------
cor3ntin wrote:

@ojhunt ping

https://github.com/llvm/llvm-project/pull/113510


More information about the cfe-commits mailing list