[clang] [HLSL] Update type for `out` arguments only for dependent params types (PR #163832)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 16 12:19:08 PDT 2025


================
@@ -765,10 +765,18 @@ static bool isRelevantAttr(Sema &S, const Decl *D, const Attr *A) {
 
 static void instantiateDependentHLSLParamModifierAttr(
     Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
-    const HLSLParamModifierAttr *Attr, Decl *New) {
-  ParmVarDecl *P = cast<ParmVarDecl>(New);
-  P->addAttr(Attr->clone(S.getASTContext()));
-  P->setType(S.HLSL().getInoutParameterType(P->getType()));
+    const HLSLParamModifierAttr *Attr, const Decl *Old, Decl *New) {
+  ParmVarDecl *NewParm = cast<ParmVarDecl>(New);
+  NewParm->addAttr(Attr->clone(S.getASTContext()));
+
+  const Type *OldParmTy = cast<ParmVarDecl>(Old)->getType().getTypePtr();
+  if (OldParmTy->isDependentType())
+    NewParm->setType(S.HLSL().getInoutParameterType(NewParm->getType()));
----------------
tex3d wrote:

Ok, I did find a precedent for modifying the type under `instantiateDependentModeAttr`, so maybe this is fine. It was just unexpected to me that we might modify the type under this path.

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


More information about the cfe-commits mailing list