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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Unexpected behavior for cleaning redundant includes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Clang-format 11.0 have unexpected behavior for cleaning redundant includes.

Assuming my _src/MyProject/MySubLibrary/MySubClass.cpp_ source file redundant includes are:
```cpp
#include "MyProject/MyLibrary/MyClass.h"
#include "MyProject/MyLibrary/MyClass.h"
#include "MyProject/MySubLibrary/MySubClass.h"
#include "MyProject/MySubLibrary/MySubClass.h"
```

Clang-format will clean includes as follows:
```cpp
#include "MyProject/MySubLibrary/MySubClass.h"

#include "MyProject/MyLibrary/MyClass.h"
#include "MyProject/MySubLibrary/MySubClass.h"
```

However, the expected result should be:
```cpp
#include "MyProject/MySubLibrary/MySubClass.h"

#include "MyProject/MyLibrary/MyClass.h"
```

The redundant related header is correctly moved first but also remains in other includes list.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNlEuL2zAQgH-NfRnWKHJsJwcfthuWHlootD0vsjyxVGQp6JE0_75jJ9nNQhba0tKCsPWY5zcjda4_tg9G2OFu6_woIiwWBQMl9gjJ4vcdyog9dEg72nkgIZAGhdV2AI99sr2wEbSVJvUYioxtMnZ_-t6HkMZJbjzCU_Ay448fj5-8-0Y25_nn1H3QnRf-eFlSJCEUcrd7guCSlwhbbfCGIxAes_LsKKvZaZDieYeXZ0nIOH_t9drlyZ8imb-n91aWf0z7kv01-1clPWhjTlW74heolsa4Q_hNjD8R2L9EegvKe3fAPfqMP0BUCM_d7TEkEyEol8zU6_8rkVs5fVHX18OjEVNGCkWPHnQA6bwn4-YIo9vTyVb7EKFLEYQJjhRGoW2gvgBHTPxLgxgdYpH3bdmvy7XIo44G26x6J686K6s28PXXX4k8edOqGHdz7_FHGoOOKnWFdCMtjNlffne7ZzianhMMNKkqXvNctWzJBGJd16u-luuyFlyglHzbiFXDecdzIzo0YQqaGFo8wGxi4lltct1yxjmr2HLBF5RiUbJtUzZdz5arpqGtbMkmOKaY4iicH3LfziF1aQh0OAEKL4dUKz1YnBlN9kWKypEGUVfaikWZz97bOfofoTm_aQ">