[PATCH] D44093: [BUILTINS] structure pretty printer

Paul Semel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 10 10:22:49 PDT 2018


paulsemel added a comment.

In https://reviews.llvm.org/D44093#1063122, @arichardson wrote:

> I'm also often restricted to using printf for debugging so this looks really useful!
>
> However, before committing this I feel like the test should also verify that the format strings that are generated are sensible.
>
> Also what should happens when you have enum members in your struct or maybe even C++ pointers to members?


So, for the moment, we are only handling basic types. That said, for the enum in C, we will print according to the type of the enum.
In the future versions, I really want to be able to print the name of the enum so that the output is more relevent.
Anyway, the rule I followed for the moment is : if I don't recognize the type, I print it as an address.



================
Comment at: test/Sema/builtin-dump-struct.c:42
+  __builtin_dump_struct(&a, goodfunc2);
+}
----------------
arichardson wrote:
> I think there should also be a test here that we get an error when the struct contains bitfields instead of crashing/generating nonsense in CodeGen.
Do you really think that I should throw an error just because there is a bitfield ?
I was thinking about just accepting the fact that the bitfield outputs are not correct but permit the user to pretty print the remaining part of the structure.
What do you think ?


Repository:
  rC Clang

https://reviews.llvm.org/D44093





More information about the cfe-commits mailing list