<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99630>99630</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] nested `InitListExpr` has invalid `SourceRange`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jirislaby
</td>
</tr>
</table>
<pre>
For this code:
```c
struct B {
int Bunused;
union {
int Bi;
};
};
struct A {
struct B Ab;
};
void do_wr(struct A *a);
void fun(int i)
{
struct A a;
a = (struct A) {
.Ab.Bi = i,
};
do_wr(&a);
}
```
The inner `InitListExpr` (the second line here) has invalid `SourceRange`:
```
InitListExpr 0x56499f84bd00 <../test/nested-ILE.c:18:17, line:20:2> 'struct A'
`-InitListExpr 0x56499f84bd48 <<invalid sloc>, line:19:12> 'struct B'
|-ImplicitValueInitExpr 0x56499f84bdf8 <<invalid sloc>> 'int'
`-InitListExpr 0x56499f84bd98 <col:6, col:12> 'union B::(anonymous at ../test/nested-ILE.c:3:2)' field Field 0x56499f84b228 'Bi' 'int'
`-ImplicitCastExpr 0x56499f84bde0 <col:12> 'int' <LValueToRValue>
`-DeclRefExpr 0x56499f84bab0 <col:12> 'int' lvalue ParmVar 0x56499f84b850 'i' 'int'
```
If I do: `((InitListExpr *)0x56499f84bd48)->getSourceRange().isInvalid()`, I receive `false` (due to obvious `<invalid sloc>`).
Is this expected?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VUuP4yoT_TWVDYqFIfFj4YXzkiL14lN_o9leYVOOGRGIDM7t_vdX2OnEeUyiCBtTdc6pogqEc-pgEAtYrmC5mYnet7Yr_qhOOS2q71ll5Xexsx3xrXKkthKBl0A3QEtI6Pivx7nzXV97siKQrsYv5PJTxpNVb3qHEvjDWm-UNc8ud67qyQvSzfXb3ftUSTmBvYorqzeOZ6skkfaffztg2Q2FlQJY_sq26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