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

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 13:39:24 PDT 2025


================
@@ -3134,6 +3134,31 @@ bool Type::isStdByteType() const {
   return false;
 }
 
+bool Type::isDestroyingDeleteT() const {
+  auto *RD = getAsCXXRecordDecl();
+  return RD && RD->isInStdNamespace() && RD->getIdentifier() &&
+         RD->getIdentifier()->isStr("destroying_delete_t");
+}
+
+TemplateDecl *Type::getSpecializedTemplateDecl() const {
+  auto UnderlyingType = getCanonicalTypeInternal();
+  if (auto *TST = UnderlyingType->getAs<TemplateSpecializationType>())
+    return TST->getTemplateName().getAsTemplateDecl();
+  if (auto *RT = UnderlyingType->getAsCXXRecordDecl()) {
+    if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RT))
+      return CTSD->getSpecializedTemplate();
+  }
+  return nullptr;
+}
+
+bool Type::isTypeIdentitySpecialization() const {
+  const TemplateDecl *STDecl = getSpecializedTemplateDecl();
+  if (!STDecl)
+    return false;
+  IdentifierInfo *II = STDecl->getIdentifier();
+  return STDecl->isInStdNamespace() && II->isStr("type_identity");
+}
+
----------------
cor3ntin wrote:

Never mind, at this point, the identifier name would have been expanded, so we actually don't need to mess with the preprocessor. 


So this is fine as it is (I still question whether it is useful to have these function types they are only useful in a few places

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


More information about the cfe-commits mailing list