Issue 144509
Summary `modernize-use-trailing-return-type` might show incorrect/imprecise type in fix-it hint for lamdba with iterator
Labels bug, enhancement, clang-tidy
Assignees
Reporter firewave
    ```cpp
#include <algorithm>
#include <vector>

void f()
{
    auto it = [](const std::vector<int>& v) {
        return v.cbegin();
    };

    auto it2 = [](const std::vector<int>& v) {
        return std::find_if(v.cbegin(), v.cend(), [](int i) -> bool {
            return i == 0;
        });
 };
}
```

```
<source>:6:15: warning: use a trailing return type for this lambda [modernize-use-trailing-return-type]
    6 |     auto it = [](const std::vector<int>& v) {
      |               ^
      | -> const_iterator
<source>:10:16: warning: use a trailing return type for this lambda [modernize-use-trailing-return-type]
   10 |     auto it2 = [](const std::vector<int>& v) {
      |                ^
      | -> __gnu_cxx::__normal_iterator<const int *, std::vector<int>>
```

It should be suggesting `std::vector<int>::const_iterator` in both cases.

The second case might also happen for other types.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to