[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

Ilia Kuklin via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 07:56:34 PST 2024


kuilpd wrote:

> Not that this shouldn't be fixed, just weighing of the amount of complexity added here versus the benefit.

I don't really know how useful it is in general to know the actual promotion type of the enum, I guess only for using enum values in expressions without explicit casting.

> Also, is this promotion-type something that can be encoded in DWARF? GCC generates the same DWARF as Clang here. 

>From what I could tell there is nothing in the DWARF spec that allows to hold a promotion type of an enum. We could just use some undocumented field, but then it wouldn't work with GCC binaries.

> My question is: if the promotion type can be computed from the information in dwarf (can it always?), and clang already has code to compute it (not from DWARF, but from.. clang AST I guess), can we refactor that code somehow so that it is usable from lldb as well?

It can be computed if all the enum values are present in DWARF. I thought about reusing the code from Sema as well, but it uses different interface to iterate through every value, and does other analysis along the way which is not needed during debugging anymore. Plus the patch allows to remove some of the erroneous analysis in [TypeSystemClang.cpp](https://github.com/llvm/llvm-project/pull/115005/files#diff-3a759ae917207e962f79e48fa280277099a587c11bc1f1385e64000c03d6b6a2)


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


More information about the cfe-commits mailing list