[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 3 12:19:14 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 32ffc9fdc2cd422c88c926b862adb3de726e3888 ba56fbdc3c17b973dd4dd5757cf860447ba076d3 --extensions cpp,h -- clang/include/clang/AST/ASTContext.h clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b49783176f..315850f941 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3836,8 +3836,8 @@ QualType ASTContext::getConstantArrayFromArrayParameterType(QualType Ty) const {
   assert(Ty->isArrayParameterType() && "Ty must be an array parameter type.");
   const auto *ATy = cast<ArrayParameterType>(Ty);
   return getConstantArrayType(ATy->getElementType(), ATy->getSize(),
-			      ATy->getSizeExpr(), ATy->getSizeModifier(),
-			      ATy->getIndexTypeQualifiers().getAsOpaqueValue());
+                              ATy->getSizeExpr(), ATy->getSizeModifier(),
+                              ATy->getIndexTypeQualifiers().getAsOpaqueValue());
 }
 
 QualType ASTContext::getArrayParameterType(QualType Ty) const {
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index fe578cacc6..9bfd7436b8 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4691,8 +4691,8 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
   }
 
   assert(type->isArrayParameterType() ||
-	 (type->isReferenceType() == E->isGLValue()) &&
-         "reference binding to unmaterialized r-value!");
+         (type->isReferenceType() == E->isGLValue()) &&
+             "reference binding to unmaterialized r-value!");
 
   // Add writeback for HLSLOutParamExpr.
   if (const HLSLOutArgExpr *OE = dyn_cast<HLSLOutArgExpr>(E)) {
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 89df42a837..ba1931dc4f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4428,12 +4428,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
       FromType = Context.getArrayParameterType(FromType);
       From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
                                /*BasePath=*/nullptr, CCK)
-               .get();
+                 .get();
     } else { // FromType must be ArrayParameterType
       FromType = Context.getConstantArrayFromArrayParameterType(FromType);
       From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-			       /*BasePath=*/nullptr, CCK)
-               .get();
+                               /*BasePath=*/nullptr, CCK)
+                 .get();
     }
     break;
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6dd6bdbd33..8826c0bc75 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2215,7 +2215,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
 
   bool argIsLValue = From->isGLValue();
   if (S.getLangOpts().HLSL && FromType->isConstantArrayType() &&
-             ToType->isConstantArrayType()) {
+      ToType->isConstantArrayType()) {
     // HLSL constant array parameters do not decay, so if the argument is a
     // constant array and the parameter is an ArrayParameterType we have special
     // handling here.
@@ -2236,7 +2236,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
     SCS.setAllToTypes(ToType);
     return true;
   } else if (argIsLValue && !FromType->canDecayToPointerType() &&
-      S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
+             S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
     // Lvalue-to-rvalue conversion (C++11 4.1):
     //   A glvalue (3.10) of a non-function, non-array type T can
     //   be converted to a prvalue.

``````````

</details>


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


More information about the cfe-commits mailing list