[PATCH] D124221: Add new builtin __builtin_reflect_struct.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 21 18:00:07 PDT 2022


rsmith added a comment.

I'm not entirely sure whether I want to pursue this -- I'd prefer to have only a single mechanism that works well in both C and C++, rather than this (which is flexible but not really usable in C) and `__builtin_dump_struct` (which is extremely inflexible but works well for C) -- but I've not found a good way to expose this functionality that provides good support for both use cases yet. Thoughts on that are welcome.

This came from wanting to write up how I would have like to have seen `__builtin_dump_struct` be implemented. Note in particular that all of the work is done in `Sema` with proper semantic checking, rather than in CodeGen, which avoids the problems that `__builtin_dump_struct` has with converting arguments to the right type, provides a lot more flexibility in the function argument, and supports constant evaluation for free.

This is somewhat WIP: access checking is not done consistently (I'm not sure whether we should ignore access control or properly enforce it; the derived-to-base conversions currently enforce it and the field accesses ignore it, which is certainly not the right answer), and the changes to tame an over-aggressive  `-Wunused-value` warning on `PseudoObjectExpr`s aren't quite right yet, leading to test failures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124221/new/

https://reviews.llvm.org/D124221



More information about the cfe-commits mailing list