<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62090>62090</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clangd] Language server gets stuck parsing comments with # in asm files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Ferdi265
</td>
</tr>
</table>
<pre>
When parsing `.S` assembler files that contain comments starting with `#` , clangd gets stuck in `clang::syntax::TokenCollector::Builder::build()` at 100% CPU usage.
This would be an invalid preprocessing directive in a `.c` file, but is accepted in `.S` files as just another comment syntax by the preprocessor. Somehow this trips up the clangd parser and it gets stuck forever.
Example that doesn't hang:
```S
.intel_syntax
main:
#define comment
mov rax, 0
ret
```
Example that hangs:
```S
.intel_syntax
main:
# test comment
mov rax, 0
ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycU01v4zgM_TXyhaghy7ETH3zox-a0hwXaxR4XssTYamXJkOi0_fcDWcmkM8BcCgSxSTya7z2SMkYzOsSeNQ-seSrkSpMP_RGDNqJtisHrz_6_CR0sMkTjRmAtL59Zy0HGiPNgMcDJWIxAkyRQ3pE0DpSfZ3QUIZIMlOreDU2pmIk6VTPxCMpKN2oYccOt6g2MS5Atz-p7Vt_HT0fyI7-_-Dd0j95aVORDzj2sxmq8BEMKmDgw0W0ECSrOmWjg8Z9_YY1yxJLxJ8bv8__LZCK8-9VqGBCkA-PO0hoNS8AleIVxE6xNQEXmjImd3PSr9PmkOqkYVgITQSqFC6G-aMgeZWdkhNc1EkjnacJwNQeyOBg-gSb80tWHEp79jJN_B0okKZglwrpsuItraR4YQDoNhr56ePIBzxh-kfrXh5wXi3lG2mN0TOwJpovPGdny_HvOcWkcof3_MoEtNUvjbnhRazwZh1c9OQ0AMPszBPmR3OG3bED6rdMfKSZi8dbpW_xSSyZqIIz0fYqF7mvd1Z0ssK_aQ1Vz0bR1MfW62-_UXneyatq9ELJqUerhtKsOHQ7idChML7io-a4SlRCdqMuGV4Pgaui6Sqtur9mO4yyNLa09z6UPY2FiXLFvBe94YeWANl7vMvQJdDesY2Q7bk2keCsjQ3a74LwarHmCv6UbVzkiRAxnDF_343rIP080X6aot_2Oc17aYg22n4iWbQziyMRxNDStQ6n8zMQxNb887pbgX1ERE8dNQGTiuGn4EQAA__9Caltt">