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

    <tr>
        <th>Summary</th>
        <td>
            TOT changes break parsing of some CXXMethodDecl parameters
        </td>
    </tr>

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

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

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

<pre>
    We use `clang::ASTConsumer` to parse the declarations of C++ methods, to determine their parameters. Our code works in release branches 11 to 15 of LLVM/Clang, but something at the top-of-tree has broken it.

Consider the following C++ code fragment:

```
namespace fur {
  // alias for type defined elsewhere
  using Quat = MQuaternion;

  class Isometry {
  public:
    Isometry(const Quat& r);
  };
}
```

We parse this code using an `ASTFrontendAction` and examine the resulting `CXXRecordDecl` and its parameters. Using the release/15.x branch, a dump of the parameter looks like this:

```
LValueReferenceType 0x2d55130 'const fur::Quat &'
`-QualType 0x2d55111 'const fur::Quat' const
  `-TypedefType 0x2d55110 'fur::Quat' sugar
    |-TypeAlias 0x2d55088 'Quat'
    `-UsingType 0x2d55050 'Autodesk::Maya::OpenMaya20220000::MQuaternion' sugar
      |-UsingShadow 0x1e73290 'MQuaternion'
      `-RecordType 0x1e22b00 'class Autodesk::Maya::OpenMaya20220000::MQuaternion'
        `-CXXRecord 0x2d4f5d8 'MQuaternion'
```

Its type is `const fur::Quat &`, as we would expect. But using top-of-tree, the dump is different:

```
LValueReferenceType 0x1adf240 'const Quat &'
`-QualType 0x1adf211 'const Quat' const
  `-ElaboratedType 0x1adf210 'Quat' sugar
    `-TypedefType 0x1adf1f0 'fur::Quat' sugar
      |-TypeAlias 0x1adf140 'Quat'
      `-ElaboratedType 0x1adf100 'MQuaternion' sugar
        `-UsingType 0x1adf0d0 'Autodesk::Maya::OpenMaya20220000::MQuaternion' sugar
          |-UsingShadow 0xbbe940 'MQuaternion'
          `-RecordType 0xb6e1b0 'class Autodesk::Maya::OpenMaya20220000::MQuaternion'
            `-CXXRecord 0x1ad8f28 'MQuaternion'
```

An `ElaboratedType` has insinuated itself in there, and the type `const Quat &` is now missing its namespace.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1Vt9v4jgQ_mvCi1XkmATCQx6AbqWVWlW329vdVyeegK8mRraztP_9zThAg6DbO602iiCJ55uf33hcWfVafgfWeWDJlNdGtutkssB78fVpZVvfbcHhAguW7aRDqbABpgAFnQwaBZht2CoRS7zZFsLGKp-IFckrCOC2uo0Y7Qgvt_TNj9lj51htFbC9dc-e6ZY5MCBRf-VkW2_AszQlJWlOBu7vvz0k4m4V3UPtVReYt2ROt2smQ_Qq2N2NbW6CA2Ab6VGTfYaW6TBO-G3CF_0vBaUVuAhprDF2TzqOIUSnGifXW2gDZWIAxTwc7vjaYjR-J2uUx2iS2bL_zBh6ijeTRqMXjUVTrztKWoO5UAyMh_0GHBzFO08O_NVhGMnklj3QE7gWk5tMlkP7jGHavWefY-judWhz11VG1yeHGV5HsUQUNQYdoolETJlLxPykGt2d3b4Zwudrsfa_SJQjCbTvU9U7L1tiD1Lmztk2QKsWNZGDiCNbDPlFHnmAdfadCQTC1dWPH1-gtk7dIqOO0jr4M678HU302MgRTG6aj18OVCE-SKa67Y6YQmInMDPWIruMfu5d_nU9779J08EXaLA2bQ1PVDT-IlSepxOORZ31WcRi9x3SV0xMceWk7wY_miESWXwdiV9Z_HwqA6IJiTw5UxBNX0B9t5burdbJbBXBi8i5HsqLgqAHxEAWDcWcDszwPJpZdAGL6p97Ww_yVfZPjzto6U1wITheh_UBUy9d6p2Khr5upLJ7NJXCbCLm0dQ5-AyG_vWsODiYghAV70sQG-B33Bxa6m2dSBhzkTW5Kt5z8GpXfEa-xg7HnqA99B2WIIiY6tmedr3OUFvsoA5jtsTdrO-jwRYWN1Haa4nYqFnpJhLzg03pOolTqRqRDUj8EXcjYMjddyn7ycjK4iwAdQblA-pdkPWC6YR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