<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69847>69847</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang's abstract syntax tree did not consider the alias relationships of member variables in the union, which resulted in a loss of accuracy during CSA checking
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tianxinghe
</td>
</tr>
</table>
<pre>
For the following source code:
union u
{
int First;
int Second;
};
int main() {
int data;
data = 0;
union u n;
n.First = data;
int result = (int)(100 / n.Second);
return 0;
}
In Clang's abstract syntax tree, the member variables First and Second of the union are considered as two variables without an alias relationship. However, after generating llvm ir, they are aliases.
Clang ast:
![image](https://github.com/llvm/llvm-project/assets/26410605/a909733f-72cb-4980-bc3f-2de3a997abdb)
llvm ir:
![image](https://github.com/llvm/llvm-project/assets/26410605/0c1f66d8-72e5-4b8a-aa64-38648ad4f035)
I think this may be causing some accuracy issues on the union.
@steakhal @haoNoQ @EugeneZelenko
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VM2O4ygQfhpyKSUi-P_gQ3dnrZ3LSqu57a2Ass02hhbgzuTtVziZ6agzu9IehgPGVdTf91WBMZrJEfWsembVaYdrmn3ok0H3zbhppp30-tIPPkCaCUZvrT8bN0H0a1AEymtixRMwfmL86brDtlZnvIP1XsSa5_vfvIxLMJgQEyt-qvtKyjv9Scma02fJv5yziwWNY6JlontMIOs1JnyInoXAihPwB9WtMHAfGnfYatgMfuouxwkUV3u9w0RrXGKiY6I9cg5MDOAOt1pF92EeKK3BPSSRAbgD_IuDF4tuYqKJgDKmgCpBvLiE3yAFIiZeNvoWWiQFeMdgUFqKV-gBnb4BDX7cLl5rxJAJdtFoCqQBI6Szv7M-mzT7NdsDWoMRAllMxrs4m7cD_O7P9E4hB8cxUYCJHAVMuX2sfV_AhFtily3U5oPi4b60rS7A3B83CRNHVj2bBSdi1YmJdk7pLWa1GJgYJpPmVR6UX5gYcpTbZ_8W_N-kEhMDxkgpMjGIujzymldZ1vGuKYpx3wgl92XX8r1UxbgXmgrsugallpmZu9S-l_BrE-PqONa1bveNoGpfyhb3iHW5L9q6bFGXIy-qT4l9gTQb95r3CAteQBIoXON1bBcCVGoNqC5gYlwpgncfpB--j3LJYyJ8ndECK_mM_g__Zz79tmYa_yJL7tXfh73uO90Xuis63FF_rLum45y33W7uda1qWUssVckF1w3xthCiEdhSVbSSdqYXXBRHLo7HsirL7iBEMcqqq2TZjoKPmpWcFjT2kGE7-DDttvz7umvLZmdRko3bOyaEuo6DyE9a6DeY5TpFVnJrYoofHpJJlvr_nh7QRoPz6ccsbGg9dnzM0_MwYuYO3Nzu59mo-fYYkM5qBOvjZvyDGL2GzNbL1ydQM6lX46bdGmz_v1vqyjATwwbSPwEAAP__FArJBA">