<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJytVU2P2zYQ_TXyZSBBkuW1fdBhs4GBnFogAXKmyJHFLEUK_LDr_voOKdleO02BogUMmRTJNzPvvaE6Iy7td4Qz0x68gclizs04SYXwlr8ZgeBMsByhp1fuaYuArK4HZAKtoxEEJ_UR_ICQc16Bmbw0GiYVHIxoj3FxDMrLSV1hI-IR6YQFqQncaITXr99StKx-o11wRuBMEzYSMvPAHNBU6il46I0FRhBGxW3MIgg8oTJTDHXPRsmOK0aT19-_FFn5OStf5-dXgpd-ADcypcCj83OdMTQB2YsfIsbZ2HcHP0Ja1imxO3hvlDLnOCNWRqaFy9YLfPZSznETHTmO0ucTHyDvR5fjHx61I4Ic5N-1yT_Ey_vOMv6OPhc4UXqbqoaRSV1wyM08Ys4T-v8fJifgPIqFtziRvl9Fnp_17tuApM-VAFKHqyAw8cOEkNEHTMHVWbMxXNQsykoeiRsna0TgyTKcjFdk9f5jlE-kt-zjGW8vdECSDyY6w6jSBeHBqqYHmj6jRu1msrhljrIu4EtWb0fQhqwVlSRXR5cbKvwZMx7uKI14gvzCvI_B59zvfWODBsetnHzcb4KPTp0ZuXoGrSXnjugcI6KJsvT27j9a0jFlyoV15oSLaYllkM4FoozzYN1s3s7QY66JtI1SQ1UXZVEl4KqhYRkziSGWbIibdGrZT4K5pRoUDw3yGzGY2os2dEEqP4f82FBPQZeulbTTBCWgQ_q5q3Q8vRPmJ9Kcx2nGTk2-YD7k8sp9IIUuvzibejS25y3UvJoM_1HGWP3f-A0cTmiZR3UpIJntWoJjJxIJlEnEeWtCp_ChoLlh0m2wXJPzpfaQ_-3KYfoCA6oJyAMxbUaIpFS8zJKtZ4lv9I2BTBatjlxSeuJmBqbfY6tRh52Y5mTt6iHc5lMXjrnFyVhf_CmnbPOZOnXwfko3VH2g35EYD9TdZqSJUqfrX07k_EBODj4szj_sqnq9rdc0eoK9tulKtGuxX-_ZigU_GNsegn6_UHF6Faxq_3XgREOMvGnKarsaWt697Jqu6TpeNkyU6w1nu3633_F1U1U97leKdahcS5XT10jjeWaSxlT66r9nINu6rONvXVVVuSa7b7f7vmxemqbaiqbqs6ZEuiNVEXEKY48r2yZIYszRopLOu_sic04eNWJKmDL00its58Y6EG10cYvrNQXnAfXtK_rwDU6eJmX_ofn3q1RKm-r4C1vUsoM>54017</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang Frontend crashes when merging pre-compiled file (version 12.0.1 and 14.0.0)
        </td>
    </tr>

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

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

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

<pre>
    We want to pre-compile C-Code source files to pre-compiled "headers" using the -cc1 option plus merging multiple sources together into one AST file, so we can use that as an input for a tool we are developing using the libclang API.

So with small test files, everything works just fine, using the following commands:
`clang -cc1 -emit-pch -fms-extensions -Wno-everything -fbracket-depth 512 main.c -o main.ast`
`clang -cc1 -emit-pch -fms-extensions -Wno-everything -fbracket-depth 512 -ast-merge main.ast lib.c -o main.ast`

(These commands include the additional compile options we use on the production code.)

But if we try this approach on the source files of our production code, clang crashes. I'm not allowed to post the source files, but I'll attach the pre-compile run script, output including the error message and the test files mentioned above.
The issue occurs with both clang version 12.0.1 and 14.0.0, the output of both versions is attached.

Our tool is built with libclang API version 12.0.1, so it would be best if we could do the pre-compile step with that version.

Actually the pre-compile step works fine if we compile every source file of the production code seperately. But it would save a lot of trouble if we could merge the files together.


So any help or workaround for this issue would be much appreciated.
Thanks in advance!

[bug-report.zip](https://github.com/llvm/llvm-project/files/8123723/bug-report.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVcuO4zYQ_Br70pAhyZ71zEGH2VkY2FMC7AJ7pqiWxR2KFPiw43x9ipQfYycbIEAAQyZFsrq7qppqbXdqfjAdhQkUL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