Fznamznon wrote:

> Why does this help with initializing things in consteval functions?

It seems once codegen meets an odr use of the variable, it doesn't emit the 
initializer, only the global variable itself. Then while emitting some 
function's body it meets the variable declaration, and if it was a static 
variable it adds the initializer via `AddInitializerToStaticVarDecl`. consteval 
function bodies are never handled by CodeGen, hence missing initializers. This 
patch makes sure they won't be missing.

> Initializers can be self-referential, so doing this eagerly might be 
> problematic.

Even if a variable is usable in constant expressions?

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

Reply via email to