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

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 09:19:35 PST 2024


sethp wrote:

In playing around with this some more, I found it was pretty effective for me to have an intializer-like expression (as in [e769f15](https://github.com/llvm/llvm-project/pull/74852/commits/e769f158c8ee001e95299ce4c83e5250e2a8f963) ), because then I could copy/paste the output from clang directly into a `static_assert()` in the source file and start cutting it down interactively with clangd's guidance and my editor identifying common subexpressions:

```c++
// evaluates to 'A{0, {0, 3, 4}, 5} == A{1, {2, 3, 4}, 5}' ->
static_assert(A{0, {0, 3, 4}, 5} == A{1, {2, 3, 4}, 5}); // ->
static_assert(A{0, {0}, 5} == A{1, {2}, 5}); // ->
static_assert(A{0, {0}} == A{1, {2}});
```

gets me to a minimal "diff" of the complex struct plus some nice paths to the different elements:

![image](https://github.com/llvm/llvm-project/assets/241129/3abe2c1b-1a19-4b3a-9fc6-32029c25ab40)

I could reproduce that in the textual output, but I worry that'd be too noisy without the dimming/color text effects.

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


More information about the cfe-commits mailing list