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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy readability-redundant-string-cstr check fails to handle calls via overloaded operator->
        </td>
    </tr>

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

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

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

<pre>
    Running `clang-tidy --checks="-*,readability-redundant-string-cstr"` on:
```C++
#include <string>
#include <vector>

void it(std::vector<std::string>::const_iterator i)
{
  std::string tmp;
  tmp = i->c_str();
}
```
yields:
```
/home/mac/git/llvm-project/build/../bug.cpp:7:9: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
  tmp = i->c_str();
        ^~~~~~~~~~
        *i->
```
which means that the code is "fixed" to incorrectly say:
```C++
  tmp = *i->();
```
rather than the expected:
```C++
  tmp = *i;
```
This appears to be due to the overloaded `operator->` meaning that https://github.com/llvm/llvm-project/blob/b66ca91fe6f91edde10510571dec5e31e2dbcfe2/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp#L53 ends up with `Text` containing `i->` rather than just the expected `i`.

My https://github.com/llvm/llvm-project/commit/967c904de29386944885ddd1f36f2b47e341069f adds a reproduction recipe to the existing redundant-string-cstr.cpp test.

It would be straightforward to add to code to strip off any trailing `->` as text, but I'm hoping that there is a better way to address this.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVUuP2zgM_jXKRUhgy--DD2nSAQrsXrq9F7JEx2ply5DkZPLvl1Iek5mdYnYCxTItmvxIfqQ7I8_t92Wa1HSgpEyE5tNh7ZU80_VaDCB-O5LtCWNrwraE7SxwyTullT-vLchlknzya-ctvr8WuKMqmqFmItmWJHuSbFG8rB1hX8K6PGWZmoReJFCS7S4GSPb1vcMjCG_sy2G8Ho2SV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