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

    <tr>
        <th>Summary</th>
        <td>
            [clang][diagnostics] `-Wunreachable-code` prints incorrect source range if a constructor has a default value set to a builtin
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    Originally reported in https://github.com/llvm/llvm-project/pull/91879#issuecomment-2136251656

After https://github.com/llvm/llvm-project/pull/91879, unreachable calls to constructors with default parameters set to builtins would underline the builtin as the source range instead of the call to the constructor - e.g.

```cpp
struct A {
  explicit A(int = __builtin_LINE());
};

int h(int a) {
  return 3;
 A();
}
```

used to produce the diagnostic
```
<source>:7:3: error: code will never be executed [-Werror,-Wunreachable-code]
    7 |   A();
      | ^~~
```

but now produces the diagnostic
```<source>:2:20: error: code will never be executed [-Werror,-Wunreachable-code]
    2 | explicit A(int = __builtin_LINE());
      | ^~~~~~~~~~~~~~~~
```

godbolt: https://godbolt.org/z/6TEdrx55d
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lM1u4zYQx59mdBnYkEhRsg46KHEMFCjaS4E9BhQ1lljQpMCPJLuHffZCUrxx0sUWbbEETdMczgz_Q_onQ9CjJWpB3IE4ZjLFyflWGmm_TNIVWe-Gz-3vXo_aSmM-o6fZ-UgDaotTjHMA3gE7ATuNOk6p3yt3AXYy5un6tZu9-5NUBHaakzHATk1xqBtgXIeQSLnLhWzcsYJXTBSVqCA_Qt5tY3eO5P9vontM1pNUk-wNoZLGBIwOlbMh-qSi8wGfdZxwoLNMJuIsvbxQJB8wUFz29kmbqG3AZ5fMgMkO5I22hHGiqxFlWH8Gl7wi9NKOhNqGSHJAd15tS_Il3jp_y487pP24v1UOVb51Nc_byrYZO4T6bltBpJfZaKUjdsAO2kYEfsTHx9cTPf76y28PwA7AmqXzVzeoj2_zdVw8p9cIElhzm8JTTN4i_-ay5voY7_2Zb2OnQMMiefZuSGqr2KDlaF2IWn3fkd9vRQT-ALyrgXcceIfkvfPLRLmB8Fkbg5aeyGNPSC-k0vIwQdztPm072f3u083V7xY3EMerMsQaob5H_JsiXNtiA_Hw9esP1PUponXPV3XhH-S9F8aWT_5TlLH19P_peXwQ_679oBKjG3pn4iLiw_91M-ydH4GdvgA7VX88DP5FiCEbWj40vJEZtUVd1HnBhCizqVW1auShqgdJRaNEKVhF1UGyuq4KVjaHTLcsZ2UuWFM0Qohyfyip4cVBNmXFz-JcQZnTRWqzX9Cw5M5W3LQNr5nIjOzJhJV6jCkj7Qi8e7u2AIwtOPTtCpY-jQHK3OgQw1u8qKNZwbn5iyOIu9sQ4ohQ5d-5pyrH2WsbA2qrnPek4gdonFG-w8MkA8pveHqSJtGVTPKKnyx50_5rUq5FCQsr17o8teyvAAAA__8Vjdxh">