akash-manna-sky wrote:

> We really shouldn't have an InConstantContext bit in CodeGen at all.
> 
> Anything that's actually a constant context should be evaluated by Sema, and 
> the result of that evaluation should be stored in a ConstantExpr. Anything 
> else is asking for trouble: constant evaluation has significantly different 
> rules in constant contexts, and can have weird side-effects like triggering 
> template instantiation.

Makes sense... Sema already wraps each element of a file-scope compound literal 
in a `ConstantExpr`, it just never filled in the value. I've moved the fix 
there: the element is evaluated once in Sema and the result stored in that 
wrapper, so CodeGen emits the stored value and no longer re-evaluates it. I 
dropped The CodeGen and CIR changes. This also makes the evaluator and CodeGen 
agree on the literal's contents, which resolves the FIXME in 
`static-compound-literals-reeval.cpp`.


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

Reply via email to