[PATCH] D158296: [clang] Diagnose overly complex Record in __builtin_dump_struct

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 14:24:00 PDT 2023


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:732-733
+    int RDKind = RD->isClass() ? 0 : (RD->isStruct() ? 1 : 2);
+    S.Diag(PtrArg->getBeginLoc(), diag::err_builtin_dump_struct_too_complex)
+        << RDKind << RD->getName();
+    return ExprError();
----------------
aaron.ballman wrote:
> This will correctly handle diagnosing a gigantic anonymous struct.
Producing an error here seems likely to eventually cause problems in practice for some users: people are using `__builtin_dump_struct` in generic code for reflection purposes, not just for debugging, and this will cause us to start rejecting complex generic code.

Instead of rejecting, can we produce a tree of `PseudoObjectExpr`s if we have too many steps to store in a single expression?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158296



More information about the cfe-commits mailing list