================
@@ -836,9 +836,29 @@ struct ConvertConstructorToDeductionGuideTransform {
       NewTSI =
           SemaRef.CheckPackExpansion(NewTSI, PackTL.getEllipsisLoc(),
                                      PackTL.getTypePtr()->getNumExpansions());
-    } else
+    } else {
+      // When transforming outer patterns, InjectedClassNameType may not be
+      // substituted by SubstType because TreeTransform does not always
+      // reach TransformTagType for nested InjectedClassNameType. Expand it
+      // to TemplateSpecializationType first so substitution can proceed.
+      if (TransformingOuterPatterns) {
+        QualType OldType = OldTSI->getType().getNonReferenceType();
+        if (const auto *ICNT = dyn_cast<InjectedClassNameType>(OldType)) {
+          QualType Expanded =
+              ICNT->getDecl()->getCanonicalTemplateSpecializationType(
+                  SemaRef.Context);
+          // Rebuild the type with the expanded form
+          if (OldTSI->getType()->isLValueReferenceType())
+            Expanded = SemaRef.Context.getLValueReferenceType(Expanded);
+          else if (OldTSI->getType()->isRValueReferenceType())
+            Expanded = SemaRef.Context.getRValueReferenceType(Expanded);
+          OldTSI = SemaRef.Context.getTrivialTypeSourceInfo(
+              Expanded, OldParam->getLocation());
+        }
+      }
----------------
mizvekov wrote:

This approach is not feasible to handle an InjectedClassNameType nested in 
other ways. For example, as part of PointerType, FunctionType, and others.

Can you elaborate why the InjectedClassType is not handled in TreeTransform 
here?
Fixing that seems the correct approach.

https://github.com/llvm/llvm-project/pull/207644
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to