[clang] [clang] improve print / dump of anonymous declarations (PR #124605)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 28 15:44:11 PST 2025
mizvekov wrote:
The test case provided shows a bug in the original implementation of the analyzer anyway.
Here is the clang output for the slightly reduced repro:
```C++
struct A {
static A a;
char b;
friend bool operator==(A, A) = default;
};
bool _ = A() == A::a;
```
Original clang outputs:
```
bool operator==(A, A) noexcept = default
[B2 (ENTRY)]
Succs (1): B1
[B1]
1:
2: [B1.1].b
3: [B1.2] (ImplicitCastExpr, LValueToRValue, char)
4: [B1.3] (ImplicitCastExpr, IntegralCast, int)
5:
6: [B1.5].b
7: [B1.6] (ImplicitCastExpr, LValueToRValue, char)
8: [B1.7] (ImplicitCastExpr, IntegralCast, int)
9: [B1.4] == [B1.8]
10: return [B1.9];
Preds (1): B2
Succs (1): B0
[B0 (EXIT)]
Preds (1): B1
```
Notice how steps 1 and 5 are empty.
After my next changes to this patch, here is how it will print:
```
bool operator==(A, A) noexcept = default
[B2 (ENTRY)]
Succs (1): B1
[B1]
1: function-parameter-0-0
2: [B1.1].b
3: [B1.2] (ImplicitCastExpr, LValueToRValue, char)
4: [B1.3] (ImplicitCastExpr, IntegralCast, int)
5: function-parameter-0-1
6: [B1.5].b
7: [B1.6] (ImplicitCastExpr, LValueToRValue, char)
8: [B1.7] (ImplicitCastExpr, IntegralCast, int)
9: [B1.4] == [B1.8]
10: return [B1.9];
Preds (1): B2
Succs (1): B0
[B0 (EXIT)]
Preds (1): B1
```
At least it will print the parameter depth and indexes, but this still should be fixed in the analyzer somehow.
I still think leaving the assert was the right call, it led us to finding bugs as expected :)
https://github.com/llvm/llvm-project/pull/124605
More information about the cfe-commits
mailing list