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

    <tr>
        <th>Summary</th>
        <td>
            clangd in MSVC mode crashes when indexing a C source file which defines assert macro
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clangd,
            crash-on-valid
      </td>
    </tr>

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

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

<pre>
    In MSVC compat mode, a simple C source code like this causes clangd to make an illegal hash map insertion, leading to a crash that can be observed with an assertions enabled build:
```
#define assert
```
Produces:
```
Assertion failed: !KeyInfoT::isEqual(Val, EmptyKey) && !KeyInfoT::isEqual(Val, TombstoneKey) && "Empty/Tombstone value shouldn't be inserted into map!"
```

The problem here is that we are not checking for invalid source locations when inserting symbols into the symbol -> include file map, which is a situation that occurs with synthesized symbols.

In this repro, the assert definition triggers a workaround (https://github.com/llvm/llvm-project/commit/8da090381d567d0ec555840f6b2a651d2997e4b3) where a `static_assert` macro is also implicitly defined.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVNGq4zYQ_Rr5ZbjBlmPHfvDDbfYGLkuh0Mu-FlkaW9PIkivJSbNfX2Q7u6VsoYWgWEJzZuacoxEh0GgRO1b9xDif6OsNr-7GOGfVp0wsUTvfPU-z3qlH927h51-_nEG6aRYRJqeQ8TMICDTNBuEMwS1eIkinEAxdEaKmAFIsAQNII-yoIDqYxBVBWCBjcBQGtAgaJjED2YA-krMJ16BQZMcUIED6dCdqEUEKCz2C6wP6Gyq4U9QJTYQ9OABa0RtU0C9kFCtfWf6J5a-szvfftuWlwoEs7pE_vPSLd2qRGP4N5PWZFAZBBlMyYLz4jI93O7iPFFa-Unj7YxGG8eZLWs_wNs3x8RkfjLfAeM14_R-CPtzUh-gs_jOQr3CMX77dgJswC0LQbjHKMn6KibGNXVRAdhVhZrxIev-QnHX90Aizd73BCTR6BAqbBncE4RGsiyA1ymvSaXAeyN6EIfU0gnFSbIrcNdqnvHaE8Jh6Z8JWSdS4H8ALK9-ArDSLQhjI4FbmGe6apE7pk9visqJupTgpFx82F4SHjRoDfUX1THH4ez_vdnOkx9m7BJtSb-rD6gXacD2NI_qU7O78VXi3WAWMNzrGebUCvzB-GSnqpT9INzF-Meb2_HuZvfsdZWT8It00UfpolMjbvGwKVdUnlaOsqqo55kPdc1FXheJte8JjXyZh7yvVAlidhygiyd92g9Y5TEJ6t_JggoP07khSNI-tfFSHTHWlastWZNgVp5yXZV2XVaa7qh5kUyBiUwxFe2zaWqoC66Et86pv1TGjjue8LHhR8LI4FdXhlLfHvBUoe4lcNi075jgJMofU5MH5MaMQFuxOVVFUmRE9mrCPk-2tJ3Pxc9qm1_vi7Mvqjn3G-G4lq1_GwI65oRDDd-RI0WC3jwzaB0-aONskwG-OUvhnMpT4Pn1W22x-2UgJT4lX8rLFm-5_C7l2Ghi_rM3-FQAA__-ffrW0">