[clang] [HLSL] Allow arrays to be returned by value in HLSL (PR #127896)
Ashley Coleman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 11:59:04 PST 2025
================
@@ -20681,7 +20681,8 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
const FunctionType *FnType = CalleeType->castAs<FunctionType>();
// Verify that this is a legal result type of a function.
- if (DestType->isArrayType() || DestType->isFunctionType()) {
+ if ((DestType->isArrayType() && !S.getLangOpts().HLSL) ||
----------------
V-FEXrt wrote:
nit: Its probably a good idea to make a small helper function like
```
// HLSL allows arrays to be returned while C++ doesn't
static inline isReturnableArray(T, S) {
return T->isArrayType() && S.getLangOpts().HLSL;
}
````
That way there is a tiny bit of "built in" documentation so someone in the future isn't confused but the extra HLSL check here
https://github.com/llvm/llvm-project/pull/127896
More information about the cfe-commits
mailing list