llvm-beanz wrote:

> > How does it not duplicate sub-expressions while also not creating temporary 
> > variables to capture results?
> 
> The way I thought of to comprehensively solve this in a clear general way was 
> to:
> 
> * create a new temporary with an anonymous struct type containing the exact 
> sequence of expression types from the initializer
> * initialize that with a flat initializer list containing the original 
> expressions
> * then refer to that temporary in expressions in a new rewritten initializer 
> list matching the target type layout.
> 
> Or perhaps that can be wrapped in a helper function instead.

I think the simpler approach is to wrap any expression that can possibly 
side-effect in an `OpaqueValueExpr`. That's how we handle side-effecting 
`inout` arguments. It allows us to emit the expression once during codegen to a 
temporary that we can then refer to multiple times because the OVE will appear 
in the AST in multiple initializer list arguments.

https://github.com/llvm/llvm-project/pull/123141
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to