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

    <tr>
        <th>Summary</th>
        <td>
            `clang-analyzer-alpha.cplusplus.MismatchedIterator` false positive
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:static analyzer,
            false-positive
      </td>
    </tr>

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

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

<pre>
    ```cpp
#include <list>

class C
{
public:
    C(const std::list<int> &files)
        : mFiles(files)
    {
        mItNextFile = mFiles.begin();
    }

 bool func() {
        if (mItNextFile != mFiles.end()) {
 ++mItNextFile;
            return true;
        }

        return false;
    }

private:
    const std::list<int> &mFiles;
 std::list<int>::const_iterator mItNextFile;
};

static void f(C *c)
{
 while (c->func()) {}
}
```

```
<source>:13:13: warning: Iterators of different containers used where the same container is expected [clang-analyzer-alpha.cplusplus.MismatchedIterator]
   13 |         if (mItNextFile != mFiles.end()) {
      |             ^
<source>:28:5: note: Loop condition is true.  Entering loop body
   28 |     while (c->func()) {}
      |     ^
<source>:28:12: note: Calling 'C::func'
   28 |     while (c->func()) {}
      |            ^~~~~~~~~
<source>:13:13: note: Iterators of different containers used where the same container is expected
   13 | if (mItNextFile != mFiles.end()) {
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
```

https://godbolt.org/z/PjfExYP4r
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2P4jgQ_TWViwVKyoSEQw4QQBppdzXXPa2MUyEemTiyHbpnDvvbV8bJAN2zX5q2IB92Vb1Xz1WOcE6de6IK8h3k-0SMvjO2apWlF3Gl5GSarxWs0_iTwwDpFpCrXuqxIQa81sp54Icwn26lFs6xOrwUO0i3w3jSSgIPa4wxVgOW0vTOM-ebMM230b9WfYjCANet0uQAN5NLGMC37HKM8-Wb9Qg0W14--d_o1QdbBnw_eS1PdFY9YBnc-O675z6yZidjNGvHXkaTNzFVywDLp8iYPQSnvplC310Bd4C7B5877Dws-dH2zNvxzeKd17NlK7SjH9AfrLoKT3eV_03hScoY6cdmceoW6A_lyQpvLHuXTqAQH9Kt88Irya5GNawFLGsGuJVxnyZRXrooXikXwA93vWfdYkLxOpdcDP70ymtnRisp0sz4fGEvwvaqP4fHTxNnx0zLGtW2ZKn3QRkvVE_WsdFRw146ssR8R8yJC92XmXKMXgeSnhoG-U5q0Z8Xohf66zeyC6GHTizloEcX_stflbsILztqZlzI93EzMs6gqNnP1NJUFPVj8TDID--1wBL4Ng_59-ZWEOwXY4aQVqO8Mn1IK9TbkrFD78mq_sx0sAhtHqGw_A71n7brmd3fs8rwkVYttA7ggEUdSy2GLz6CxF2hP6fxj1Uzc_rAknna-p_a8ock3o_3fdJ5P7ggKB4Bj2fTnIz2S2PPgMdvgMfPX9rD6--fVzZpKt5s-EYkVGXFCotilWGWdJUgFKty3UpZYNlgnqXUFEVbpk1epJjKRFWYYp5y5MjzHLOl4OsTppsyL8ucsrWAVUoXofRS6-slYCfKuZGqjON6tUm0OJF2t-8N4q2vgM-Hx9xggAhYA-LtyFsMximvrhSm831iqxB5cRrPDlZpOLbcHcsrryl8sf5_y67TeMSyGS8Zra7eSKp8N56W0lwAjwF0ui0Ga76Q9IDHW7YO8DglfK3wrwAAAP__ozUnLw">