<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58483>58483</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang doesn't emit DWARF line table entries for inlined calls
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          brettw
      </td>
    </tr>
</table>

<pre>
    Clang does not emit line table entries for the calling function's line when a call is inlined.

When I try to debug this code compiled with `clang++ -O2 -g inlined.cc`
```
 1
 2 #include <stdio.h>
 3
 4 #include <memory>
 5 #include <string>
 6
 7 int main() {
 8   printf("Hello\n");
 9
10   auto pointer = std::make_unique<std::string>("test object");
11
12   printf("World %s\n", pointer->c_str());
13
14   return 0;
15 }
```

I am unable to set a breakpoint on line 10. Both GDB and LLDB slide the breakpoint down to line 12 if a break on line 10 is requested. The reason is that Clang has emitted no line table entry referencing line 10, blaming all of that code on the inlined make_unique.

This is with:
  Debian clang version 14.0.6-2
  Target: x86_64-pc-linux-gnu
  Thread model: posix
  InstalledDir: /usr/bin

The line table for the generated code is (the source file is file index 0 and 26, other files are library headers)
```
Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000001170      7      0      0   0             0  is_stmt
0x0000000000001174      8      3      0   0             0  is_stmt prologue_end  <-- First printf on line 8
0x0000000000001180   1065     30     11   0             0  is_stmt
0x000000000000118d    241     51      9   0             0  is_stmt
0x0000000000001191    200     25      9   0             0  is_stmt
0x000000000000119e    431     33      2   0             0  is_stmt
0x00000000000011a9    229     26      9   0             0  is_stmt
0x00000000000011b1    354      7      2   0             0  is_stmt
0x00000000000011b5     12      3      0   0             0  is_stmt  <-- Second printf on line 12
0x00000000000011c6    234     28      9   0             0  is_stmt
0x00000000000011c9    274     26      9   0             0  is_stmt
0x00000000000011cc    285      6      9   0             0  is_stmt
0x00000000000011ce    158      2      4   0             0  is_stmt
0x00000000000011d3     95      2     11   0             0  is_stmt
0x00000000000011db     15      1      0   0             0  is_stmt  <-- Function end on line 15
0x00000000000011e5     15      1      0   0             0  is_stmt end_sequence
```

Also tested with very recent:
  Fuchsia clang version 16.0.0 (https://llvm.googlesource.com/llvm-project a93d03310e2c02fa5e24544df4706650f85788f7)
  Target: x86_64-unknown-linux-gnu
with similar results.

GCC emits line table entries for this code. It does this by emitting an address entry for that line with a size of 0 bytes. Both GDB and LLDB are happy with this. Here is a snippet of GCC's line table (using `-O2 -g`):

```
...
0x00000000000010cd      8      9      1   0             0 
0x00000000000010d2     10      3      1   0             0  is_stmt  <-- Line 10 reference with 0 bytes.
0x00000000000010d2   1064      5      2   0             0  is_stmt
0x00000000000010d2   1065     30      2   0             0 
0x00000000000010dc     12      9      1   0             0 
0x00000000000010e3    241     51      3   0             0 
...
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydV0uP4jgQ_jXhUiJynAfhwIGGZaalllbaGWmOLccxITvBZmNnunt__ZYfQJqBmW1QhCGu-urtKleqflusOiYbqJXQIJUBsW8NdK0UYFjVCRDS9C3ubVUPZieAsw53G9gOkptWyYjOtKd_2QkJzBFAq6GV9m0dR2QdkaX__mZJHsH0b2AU1KIaGgRFYq5qhFb7Q9uJGl5as4OoINyqFtEHfGD6J4Vpc0LlHPcDNP7wj_sLSVgpRDRtJe8GxI7SlTZ1q-JdlP4RCNKwZheEe7FX_duZLv8JqEcPnPeLsM5QOwN71qJTyojOIZo9hK0SAA7IZbZui34WXaeifIWUFCmj9Eg492tCkIEN6KSDQi7Ro9w1oAVRusRnz76L50G2_wzCG-ZfnxVzQozQBlT1t-DmQkwSfJTQC72-qb6r0dxcn5RbHVWYIjB_Rhneund4wZVJhni9MEMvgZx30YGz9dVg-e9HYHsYpMs3NFkLg3lU9YJ9d6JBSZ9hCYnhQWFufFo_AJM1PD3hD921GBebmyOWWr1Ii-X5KLTbI-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