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

    <tr>
        <th>Summary</th>
        <td>
            Assertion error in `clang/lib/Sema/TreeTransform.h`
        </td>
    </tr>

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

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

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

<pre>
    When using a tip of tree clang built with assertion enabled on a recent add Fuchsia unit test, it triggered an assertion error in Sema with error message:

```
clang++: clang/lib/Sema/TreeTransform.h:5850: bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionTypeParams(SourceLocation, ArrayRef<ParmVarDecl *>, const QualType *, const FunctionProtoType::ExtParameterInfo *, SmallVectorImpl<QualType> &, SmallVectorImpl<ParmVarDecl *> *, Sema::ExtParameterInfoBuilder &, unsigned int *) [Derived = (anonymous namespace)::TemplateInstantiator]: Assertion `OldParm->getFunctionScopeIndex() == i' failed.


```

Full error message can be found at: https://gist.github.com/zeroomega/b4ff701b87bf15ead69b9dc54127a11a

The clang revision we used was 6537181de420c5967c427b40f26ef2cf746c2227 but we have tested some clang built in June, 2023 and the assertion error persists. So it it probably not a recent regression. The crash reproducer [reproducer.tar.gz](https://github.com/llvm/llvm-project/files/12255696/reproducer.tar.gz) is attached. The source code of unit test can be found at https://fuchsia.googlesource.com/fuchsia/+/038036813b9ab3791d48b3251297176de6a5f938/src/firmware/gigaboot/cpp/tests/network_test.cc and it matches the line number in the error message.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU9v47YT_TT0ZbCCRFn_Dj44cQTkhx_QbRNsj8WQHElsKVIgqWSzn76gbGc3mxzaAoJsisM3b2beDDEEPVqiA6tuWHXa4Ron5w_fyDs304g74dTL4feJLKxB2xEQol7ADRA9EUiDdgSxahPhWccJMATyUT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