================
@@ -421,13 +444,32 @@ BuiltinTypeMethodBuilder::addParam(StringRef Name, 
QualType Ty,
 void BuiltinTypeMethodBuilder::createDecl() {
   assert(Method == nullptr && "Method or constructor is already created");
 
-  // create method or constructor type
+  // create function prototype
   ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
   SmallVector<QualType> ParamTypes;
-  for (Param &MP : Params)
-    ParamTypes.emplace_back(MP.Ty);
+  SmallVector<FunctionType::ExtParameterInfo> ParamExtInfos(Params.size());
+  uint32_t ArgIndex = 0;
+  bool IsTemplate = DeclBuilder.Template != nullptr;
+  bool UseParamExtInfo = false;
+  for (Param &MP : Params) {
+    QualType Ty = MP.Ty;
+    if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
+      UseParamExtInfo = true;
+      ParamExtInfos[ArgIndex].withABI(
+          convertParamModifierToParamABI(MP.Modifier));
+      // Only update types on inout and out parameters for non-templated
+      // methods. Templated types will have their inout/out parameters
+      // converted to references during template instantiation.
+      if (!IsTemplate)
+        Ty = getInoutParameterType(AST, Ty);
+    }
+    ParamTypes.emplace_back(Ty);
+    ++ArgIndex;
+  }
----------------
llvm-beanz wrote:

Instead of doing this on the params here, could put the attributes on the 
ParmVarDecls in the loop over Params below?

At a minimum that would ensure that the AST for these functions matches the AST 
for user-written code, but it may also remove the need for the 
`convertParamModifierToParamABI` function since you'll have a created 
`ParameterABI` attribute in the AST.

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

Reply via email to