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

    <tr>
        <th>Summary</th>
        <td>
            clang-cl /showIncludes reports wrong filename for symlinked files
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    This can come up in distributed build systems with content-addressed filesystems, where identical files (often empty files) end up hard-linked to the same file.

Consider:

```
$ touch /tmp/foo.h
$ ln /tmp/foo.h /tmp/bar.h
$ cat > /tmp/a.cc
#include "/tmp/foo.h"
#include "/tmp/bar.h"
void f();
$ clang-cl -c /tmp/a.cc -showIncludes
Note: including file: /tmp/foo.h
Note: including file: /tmp/foo.h
```

The second include line should refer to `bar.h`.

This is a problem for systems which rely on the output of `/showIncludes` to discover all compilation inputs.

Interestingly, the `-MD` option does not seem to have this problem:

```
$ clang -MD -c /tmp/a.cc && cat a.d     
a.o: /tmp/a.cc /tmp/foo.h /tmp/bar.h
```

This all seems related to the discussion in https://reviews.llvm.org/D135220#3862893 about `FileManager` merging files based on inode.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVMuO2yAU_Rp7g2LZ4DjxwouZSSPNYrqaH8BwHdNisAAnSr--FztpJumoo0aICO77nGNaK8_Ne688EdwQYQcg00iUIVL54FQ7BZCknZSWxJ99gMGTkwo9epoAJqy4lA68R6dOabi4JPSFnHpwQJREJyW4XswkoVvbYSCBYQzn5TKhNQEjY92eO7nSyvzEfMGS0APxHFuKflmS75L8adlfrPGY2yXs6eN1UuWXtRxpiWkm0WPdfRhG3Dtrs_5m1ebBdDu23H30FDyQhH272XkmxNXMlBF6koBW-lAKL_7ltFS5Oh2tQiARJMQkYc8fqmtuDiuhyUrcd0BWvren1yWzXwK-2wAIDFnqKXOY8Ys3n8Hwf96PCM_7e-QJUBKSXGdEEvGutxMKx0EHLvKJYcu8VZ7dx6P-cHEyOttqGEhn3U1vvUIGHegzsWbWhJ3COAViu5gR-7uDoMpjKZSvsEcsy7WOsh6V5kFhvDIY6u_Kv6KUUcQBZ9fnqN1YA_Os3nYxmx3nQGlRv8YGnBQbxBI9PwK6Yt-Xrr8W40wjwbx_85jQCtcsM55JEn9LHM_sHRkX769F-zlTEWaEJA7hI6g83L61CNrk_QIT6UMYfZyJ7nE5OCo4-Uzr45BZd8CrXcHWlCIBjG0ruq0Z4S1SE6Hbo4TeuOEH_EQRwgHc4aosT1oe34u5iJWQpdAUVbVh-abe0FQ2TNas5mlQQUPzR_gPNGPro3UB1eHsJbGZX4pZOMPlDZnrpZPTzf0wB3zCpjZDXeAhTnT5WyGTP0AEPCrvp_g27dfbDa3SvuGUVZWgrIayFrRad8AF35a8bTcbVrJ1qnkL2jfJ-jlZ71LV0JzSosiLguVVQbOizKu6azuxrruyhDIpcxi40n8QTV0z99BOB49GjQ_wDe6UIy8HA3DNz6fQW9f8GhDCIZ27beZWfwOXxc7W">