[clang] [clang] Fix CTAD not work for function-type and array-type arguments. (PR #78159)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 06:26:25 PST 2024


================
@@ -2587,15 +2587,17 @@ struct ConvertConstructorToDeductionGuideTransform {
                           : ParamTy->isRValueReferenceType() ? VK_XValue
                                                              : VK_PRValue);
     }
-
-    ParmVarDecl *NewParam = ParmVarDecl::Create(SemaRef.Context, DC,
-                                                OldParam->getInnerLocStart(),
-                                                OldParam->getLocation(),
-                                                OldParam->getIdentifier(),
-                                                NewDI->getType(),
-                                                NewDI,
-                                                OldParam->getStorageClass(),
-                                                NewDefArg.get());
+    // Handle arrays and functions decay.
+    auto NewType = NewDI->getType();
+    if (NewType->isArrayType())
+      NewType = SemaRef.Context.getArrayDecayedType(NewType);
+    else if (NewType->isFunctionType())
+      NewType = SemaRef.Context.getPointerType(NewType);
----------------
cor3ntin wrote:

I think we can just use `SemaRef.getDecayedType(NewDI->getType())`, it covers both case

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


More information about the cfe-commits mailing list