[clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 12:04:51 PDT 2023


zygoloid wrote:

Thanks for looking into this!

I wonder if it would make sense to move the checking for this warning here, to the `else` case in line 725:

https://github.com/llvm/llvm-project/blob/ac30780250875802d13450d17e6959f9e2ad3a70/clang/lib/Sema/SemaInit.cpp#L717-L734

That should remove the need to build and check the `InitializedFields` set, because you'll never need to consider a field that is partially initialized: you'll only visit fully-uninitialized fields (we'll recurse into structs that are partially initialized). You'll still need to recurse into anonymous struct and union members when deciding whether to warn, so it doesn't remove all of the complexity here, but I think that change should simplify things a bit.

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


More information about the cfe-commits mailing list