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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] string::npos triggers readability-suspicious-call-argument
        </td>
    </tr>

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

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

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

<pre>
    Passing `std::string::npos` as a second arg to `std::string::replace()`  triggers "looks like it might be swapped" warning, because of the similarity of `npos` to `__pos`, which is the first arg.
```cpp
#include <string>

void f(std::string& s, std::size_t offset) {
 s.replace(offset, std::string::npos, "something");
}
```

 a.cc:4:7: warning: 1st argument 'offset' (passed to '__pos') looks like it might be swapped with the 2nd, 'npos' (passed to '__n1') [readability-suspicious-call-argument]

Just to let you know about such a case. I don't know if it's a reason to tweak the similarity heuristics.

ver. 19.1.1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVN2OszYQfRpzMwqCIfxdcJFv00jtVd9gZewB_K2DkcdslD59ZUi626itKiF-bJ8z5xyPkcxmnIk6Uf4Q5TmRa5ic727up777pHf63v0e18wjiCrjoEVxEsWJgzfzuL_Pi2NRZSAZJDApN2uQfoTg_hXiabFSkcBGYBuxELwZR_IMAtE698FgzQeBCXA14xSgJ-CbXBbSAhFu0s-RDN-gJyVXJnADhImAzdVY6U24xxFRZU91u5r39_0zIm-TURMY3nCD8Ryi7FRkZ5Gd4prtUsvyGMHCzMqumkAUb083vzwmt_unMxoGgc2raayAY8mvcfMHvQdww8AUBLYg6h87B3D6lc5z_jvyNXl8i5mxu1KYtloYMy0edKI-vxj6LhhkqpQoTkdRnGpRnP4KtjhBvuexXmkOILB-aqlBYLNIZtJbqFjvoWIdffz33sHNhGnLG2e9K693E__EOucPUlH-8CS17I014X7glRejjFv5oKS1h6dKUZ6_m_tt5RC5LAW4uxU-ZncD2bs1AK9qAglKMqXwK2g3C6zDvsIMYKLN2M2eJLs5koQbyY_XDpto9YaDUZz-rQ3Ip5C3aZ7mie4K3RatTKjLa2wKbPIKk6kbjqrAqunbRmFVV6TrgTRRWWlZIhZFYjrM8JhnWZ23WYuYYqU0tU1RVsMRm1qJY0ZXaWxq7ec1dX5MDPNKXZ7nR8wSK3uyvB1rRGXlPB6C0ffYHuU58V1EHfp1ZHHMrOHAXzzBBLv9EL7ByjO8dt7Xmf0_m5Os3nZTCAtHBrwIvIwmTGufKncVeInVH4_D4t1PUkHgZbPEAi8PV58d_hkAAP__9sZ3xw">