[llvm] [libc] [clang] [flang] [clang-tools-extra] [compiler-rt] [libcxx] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 16:02:30 PST 2023


bwendling wrote:

@efriedma-quic, @nickdesaulniers, @rapidsna:

This is the latest version of this patch. I believe it's ready to submit. I _really_ tried to implement @efriedma-quic's idea, but there were too corner cases that made it much trickier than first imagined. I know that it's not impossible to implement it, but the further I went along the more I realized that the infrastructure just isn't sufficient to deal with it. I would *much* rather use `EmitLValueForField`, but it's not able to handle fields deeper than the current record level. A comment in the method even admits that it can't handle anonymous structs and unions.

It would be beneficial to rework `EmitLValueForField` to handle arbitrarily deep `FieldDecls`, but that's frankly beyond the scope of this patch.

This patch takes advantage of the fact that the Clang front-end appends the "source element type" to the GEPs it generates. So it's therefore possible to find the pointer to the correct struct base.

PTAL.

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


More information about the cfe-commits mailing list