[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 12 17:53:41 PST 2025


https://github.com/tex3d commented:

This is interesting.

I wonder though what it looks like in the AST when initializing something with the result of a function call that return an aggregate that must be split up across different boundaries?  Or what about expressions with side-effects?  How does it not duplicate sub-expressions while also not creating temporary variables to capture results?

Shouldn't there be an AST test so we can verify the way it transforms the code?

```hlsl
struct Foo {
    float f1;
    float f2;
};

Foo makeFoo() {
    Foo foo = {1, 2};
    return foo;
}

struct TwoFoo {
    Foo foo1, foo2;
};

TwoFoo testSplitFoo() {
    TwoFoo twoFoo = {0, makeFoo(), 3};
    return twoFoo;
}
```

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


More information about the cfe-commits mailing list