[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 04:08:21 PDT 2023


steakhal wrote:

> But I have to point out that this patch doesn't address the fact that `const void* Data` is not friendly to debuggers, especially with type information encoded in another member. So even with this patch applied, someone would still have to write (and maintain) a custom formatter on debugger side to display `Data` correctly.

That's correct. I'll think about how to resolve that as well.

> If you refactor `const void* Data` to be a `llvm::PointerUnion`, then it will be picked up automatically (`PointerUnion` is a popular type, so I've already written a formatter for it.) Together with removing `BaseBits` from `Kind` and making the latter non-packed, `SVal` will have a debugger-friendly layout.

I've considered this but I found the number of alternatives too large to make it feasible. Consider that we have 11 possible SValKinds, which would require 4 bits to encode. Requiring all `Data` pointers to be aligned as such seems rough - although not impossible.

> That said, debugger-friendliness is probably not among top priorities, so I'm not going to block this patch, if this is the direction you and reviewers want to take.

I'd say it's one baby step in that direction, but not the end of the journey. How about looking at this like that?


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


More information about the cfe-commits mailing list