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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Crash with modernize-use-integer-sign-comparison
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    Running clang-tidy with -checks='-*,modernize-use-integer-sign-comparison' and '-std=c++20' (or above) on the code 

```
struct A
{
  unsigned size() const;
};

struct B
{
  A a;

  bool foo(const A& a2) const { return (int)a2.size() == size();  }
  int size() const { return (int)a.size(); }
};
```

triggers an assertion: `clang-tidy: /tmp/LLVM/llvm-project/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp:123: virtual void clang::tidy::modernize::UseIntegerSignComparisonCheck::check(const clang::ast_matchers::MatchFinder::MatchResult&): Assertion 'SignedCastExpression' failed.`

This was introduced in the last two weeks, so I suspect this is due to the fix for #127471 .

@RiverDave , @vbvictor : Could you please have a look?

[Stacktrace.txt](https://github.com/user-attachments/files/20712795/Stacktrace.txt)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVFGv4jgP_TXmxQK1bkvLQx8KfJVGmnm599t5XYXUtNlbEpS43Hvn169SWGB3VqOVKkEc-9g-PrEKwfSWuYZiC8V-oSYZnK-_v7DRA4-yOLjus36ZrDW2Rz0q2y_FdJ_4bmTApR5YvwXI9kDlEqgB2p1cx96aH7ycAi-NFe7ZL2OWpXans_ImOAtUorIdxrAgHWR7DbQF2lISr4Aq51Ed3IWBNugsysCoXccISRO_dXL7kiaIn7TgbC63kDSIk5276jCYHwxURRDtbBDItrPb_vbnHr19im5Q3a8RD86NeHQOqJohsAFao6I7JkK5Rc8yeRsLN1aANopWT7kjQdn-qRrItoixjJjBWPmp0H8HXf0d4Qrw6OaJFEga8abv2QdUFlUI7MU4C1mDsE4eg5wN1MrpDNR-_fr9G1A7jpfT8uzdH6wFqL05OzeGJX-IVw9bBKD2PnKg9rfAX64zfzW93d0nvotKWenzGbImpSymvRgvkxrx4kx3lRZkDWTNrSzImgfwfPwl9tVlFuR9VE-gKsjvJyV6YB-ulm_x1BrbsX8yvHCYRgFazxw32PzFXNTq66yqnQryv4-z5xDMVcpHZUbuVnfq_z-YgO8qxNF6102aOzRXEY8qCMq7w3fmtwC0w-DwC4YpnFkLSow0AbuJUdwccTQfeHQegbKUyrxMcXV7BHnyYi7s9-rCGJEgTy6Hi9ESvbMGd24aO_x0E55HVoFxiJ4KR-feIGtvKMX2VZR-E680r-RDoNgDVYPIeSaKWqC2NzJMh5V2J6B2CuyXSkTp4cRWAlB7NCPHX0rKlMpNAdT-A5Q2i67Ouk22UQuu0zLflHmx3lSLoU7TQ5Ula513narKsqj0QZVVUq2TvMgPm2RhakqoSNYppWuq0mql07zUZbHOKCmOGR8hT_ikzLiKyl053y9MCBPXaZ5tqFyM6sBjmFcc0bNyKa48X896P0x9gDwZTZDwwBEj47wcn8KKPe68CsN1B_6nfbeY_Fj_gtKY7-eHNzcRab31canpzwAAAP__SEbI0A">