[randstruct] Don't allow implicit forward decl to stop struct randomization
authorBill Wendling <morbo@google.com>
Mon, 6 Feb 2023 22:26:16 +0000 (14:26 -0800)
committerBill Wendling <morbo@google.com>
Mon, 6 Feb 2023 22:26:32 +0000 (14:26 -0800)
commitf85a9a6452e8f49f9768d66a86434a88a5891614
tree85cea31cd2c343927576103893bad20a39a0f2b5
parentd453d73d0d04c452e33d9d96743710dbb9ce5b09
[randstruct] Don't allow implicit forward decl to stop struct randomization

If a struct/enum type used in a record doesn't have a forward decl /
def, an implicit one is injected into the struct. This stops clang from
randomizing the structure in some situations---i.e. when the struct
contains only function pointers. So we accept forward decls so they
don't prevent randomization.

Fixes 60349

Reviewed By: MaskRay, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D143300
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/init-randomized-struct-fwd-decl.c [new file with mode: 0644]