<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120870>120870</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
diagnostics: clang loses provenance of inline asm when issuing diagnostics
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
lf-
</td>
</tr>
</table>
<pre>
```
$ cat test.c
asm ("foo");
int main(void) {
}
$ clang test.c
<inline asm>:1:1: error: invalid instruction mnemonic 'foo'
1 | foo
| ^
1 error generated.
```
When issuing diagnostics, clang loses where the inline asm is. It should issue a hint of where it starts in the source file or something like that. This issue was encountered while hunting down a diagnostic in production code:
```
<inline asm>:2:41: error: expected '%<type>' or "<type>"
2 | .pushsection ".debug_gdb_scripts", "MS",@progbits,1
| ^
<inline asm>:102:12: error: .popsection without corresponding .pushsection
102 | .popsection
| ^
```
If this happens in CI for a weird platform (which, if you're having a bad day, of course it is), it necessitates preprocessing the file and hopefully finding where this thing came from, which may require dismantling a build system to get access to even do so; fun for all ages. n.b. the above is probably another bug, but I will figure out what it is and file it separately.
```
$ clang --version
clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/im1yhwr0p1j7r5mi47cyn4sq3wmhzkzf-cl
ang-18.1.8/bin
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0VU1v4zgM_TXKhYhhy06dHHzIpBOghz3tAHssZIu2OJUljz7iZn79Qo47TbDdIEGsD5LvkY-08J4Gg9iw3Te2e96IGJR1je63m9bKa8Oe8vWbHxmvoBMBAvqQdSw_Cj8C43vGeW8t45zxAyu_pZv5kUyAUZBhfH-xJBk_AKuXs_r5w5cWZvj0xsoTGU0GQfiRld9ZeSzWH6Bz1qUHMhehSQIZH1zsAlkDo8HRGuqA8XoBUrP8CABQAKtPkLZua1jWbPed5cfi5hMGNOhEQJklCPds8-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