[clang] [flang] [clang][flang] Add support for -finit-local-zero (PR #159788)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 22 00:17:09 PDT 2025


================
@@ -384,6 +384,159 @@ class TypeInfoConverter {
   llvm::SmallSetVector<Fortran::semantics::SymbolRef, 32> seen;
 };
 
+// Helper class to encapsulate utilities related to emission of implicit
+// assignments. `Implicit` here implies the assignment does not
+// exist in the Fortran source, but is implicit through definition
+// of one or more flagsets (like -finit-* family of flags).
+// General purpose usage of these utilities outside the
+// scope detailed here is discouraged, and is probably wrong.
+class ImplicitAssignmentGenerator {
----------------
jeanPerier wrote:

Why do you need to create `parser::` node to create the assignments?

You could simply work at the FIR level and generate hlfir.assign.

You can get the zero values using builder.createZeroValue for numerical and logical (using the element type from getFortranElementType).

For characters, you can should be able to use fir::factory::CharacterExprHelper::createSingletonFromCode()

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


More information about the cfe-commits mailing list