Issue |
97964
|
Summary |
clang-tidy: readability-redundant-smartptr-get does not remove `->`
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
e-kwsm
|
Prepare `/tmp/a.cpp`:
```cpp
#include <memory>
#include <vector>
int main() {
std::vector<std::shared_ptr<int>> v;
auto f = [](int) {};
for (auto i = v.begin(); i != v.end(); ++i) {
f(*i->get());
}
}
```
and `/tmp/compile_commands.json`:
```json
[ { "directory": "/tmp", "command": "clang++ -std=c++11 -c -o a.o a.cpp", "file": "a.cpp", "output": "a.o" } ]
```
Then
```console
$ clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 18.1.8
Optimized build.
$ clang-tidy '--checks=-*,readability-redundant-smartptr-get' --fix a.cpp
1 warning generated.
a.cpp:8:8: warning: redundant get() call on smart pointer [readability-redundant-smartptr-get]
8 | f(*i->get());
| ^~~~~~~~
| *i->
a.cpp:8:8: note: FIX-IT applied suggested code changes
clang-tidy applied 1 of 1 suggested fixes.
```
gives
```cpp
f(**i->);
```
which must be
```cpp
f(**i);
```
<https://godbolt.org/z/nrd51vWKz>
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs