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

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 01:38:34 PST 2024


================
@@ -3130,6 +3130,30 @@ bool Type::isStdByteType() const {
   return false;
 }
 
+const TemplateDecl *Type::getSpecializedTemplateDecl() const {
+  const Type *DesugaredType = 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 *SpecializedDecl = getSpecializedTemplateDecl();
+  if (!SpecializedDecl)
+    return false;
+  IdentifierInfo *II = SpecializedDecl->getIdentifier();
+  if (!II)
+    return false;
+  if (!SpecializedDecl->isInStdNamespace())
+    return false;
+  return II->isStr("type_identity");
----------------
cor3ntin wrote:

Might as well collapse that on a single line

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


More information about the cfe-commits mailing list