[clang] [clang][dataflow] Correctly treat empty initializer lists for unions. (PR #82986)

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 05:21:48 PST 2024


================
@@ -685,9 +685,22 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
 
     // `S->inits()` contains all the initializer expressions, including the
     // ones for direct base classes.
-    auto Inits = S->inits();
+    ArrayRef<Expr *> Inits = S->inits();
     size_t InitIdx = 0;
 
+    // Unions initialized with an empty initializer list need special treatment.
----------------
martinboehme wrote:

It appears that CodeGen also appears to special-case this like we do:

https://github.com/llvm/llvm-project/blob/e08fe575d5953b6ca0d7a578c1afa00247f0a12f/clang/lib/CodeGen/CGExprAgg.cpp#L1760

And if we changed the AST so that we had an `ImplicitValueInitExpr` here, it looks as if the general case in CodeGen would do the right thing.

I'll make a note of this for myself.

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


More information about the cfe-commits mailing list