[clang] [Clang][Sema] Print more static_assert exprs (PR #74852)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 18 07:45:39 PST 2023


sethp wrote:

Thanks for the feedback! I've definitely found it helpful trying to puzzle out why one of my static_asserts is failing, though it's certainly a far less complete solution than the document @tahonermann shared. 

The output from `printPretty` will definitely fall apart for a complex structure (especially one with e.g. multiple bases, or lots of similar fields). Still, this change seems like an overall improvement to me: it's still quite possible to cut a complex struct comparison up into multiple `static_assert`s. Right now I feel more or less compelled to cut every comparison down to asserts on built-in types, and this output was intended to raise that floor up to "a struct with a handful of fields and an `operator==`." 

That said, I'm receiving approximately $0 from Big `printPretty` lobbying groups, so I'm happy to walk the structure however we feel `ConvertAPValueToString` ought to do the conversion. I do quite like how `clangd` does its inline initializer hints, so maybe something like:

```
Expression evaluates to '{x: 1, y: 2} == {x: 3, y: 4}'
```

for the original example, or for a `int[2]`:

```
Expression evaluates to '{[0]=1, [1]=2} == ...'
```

What do you think?

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


More information about the cfe-commits mailing list