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

    <tr>
        <th>Summary</th>
        <td>
            [abi] method parameter mangled as a substitution does not demangle correctly
        </td>
    </tr>

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

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

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

<pre>
    While fiddling with the LLVM demangler, I noticed that in the following example 

```
template <typename T>
struct Bar{};

template <typename K>
struct Foo {
  template <typename T, template<typename U> typename S>
  void method(S<T> t, S<K> k);
};

void s() {
 Foo<int> k;
   Bar<int> i;
   Bar<bool> b;
   k.method(b, i);
}
```

the call `k.method(b, i)` is mangled as `_ZN3FooIiE6methodIb3BarEEvT0_IT_ES3_IiE`, which appears right (`Foo<int>::method<bool, Bar>(Bar<bool>, Bar<int>)`).
However, running the demangler

```
llvm-cxxfilt -n _ZN3FooIiE6methodIb3BarEEvT0_IT_ES3_IiE
```

produces `void Foo<int>::method<bool, Bar>(Bar<bool>, bool<int>)`.

`bool<int>` is obviously wrong and seems to stem from the `S3_` substitution.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVFFvqzgT_TXDy6gR2IHAAw9JmuiLvrv3pd270r5EBgbwXoORbZL2368MbJr2ttJKK0VJzPGMzzk-jLBWNj1RDvEOGPshnfg-amAM4sdAjK7VJl8eBoWuXvM_WqkIa1lVSvYNXqVr0bWE3779-A0r6kTfKDLA9njCXjtZUoWuFQ5lP-2rtVL66kvpRXSDIoTwEcLt8p2Ey2daOuoGJRwh8L17HagXHeEz8MMMW2fG0uFOGNjsYPMIfHff7NPq_3-sPmqNvnx6hvjFkWx_Q-6B34Ef8LZ6uvVGvGhZYUeu1RWw9An4_nna6zv5leeBP4Flb6R_ETD1sMBSYNkdx6PWwPeyd3MLfuM-OXFD5K9IobXyUHEP_VzdaBaenfxI6rObWRxuCUuhFEISftomCVFanENRobB-4_nP7_yo9UkekrniVPCdMIfD5Tk8n57Phyd-PsmDP4rt8drKskUxDCSMRSOb1qF3JAnvbQC-Bb5dCCw62X5WfQCWvpN_Q_4pnogCy1azqv_pK13mDJux731WvdC3cH8dWKUu3UP58lJL5fChx3-r9WuLB6OrsaTJuSkP_0n2_Ped7tUHOe-3zBeoi4vUo1WveDW6b1D0FVqizqLTaB11WBvdTS5BEj7xs6-zY2GddKOTul8FVc6rjGcioDzasDhLsvVmHbR5nDBOaV1GRbGhNInLukrTZJNsiNflWkSBzFnI1mEWhVEUb-L1qqjjMo4qLoiimkQK65A6IdXKm7_SpgmktSPlUZiGYRYoUZCyy3wrlegb4Nva6N5RX_lBx_bA2HZ3WoaeyadLLMbGwjpU0jr71tlJp6ZZKQoJ8ePyguMgjOjIkbmPunjnAFaarJ-ItxxhqY2h0qnXYDQqb50brL9QdgR2bKRrx2JV6g7Y0R-__DwMRv9FpQN2nFRaYMdF6CVnfwcAAP__yOS7Cg">