[all-commits] [llvm/llvm-project] 47d5e9: [clang-tidy] readability-redundant-smartptr-get: d...
FabianWolff via All-commits
all-commits at lists.llvm.org
Tue May 27 03:06:29 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 47d5e94acb92ce4ec5040e95e167ba471d080244
https://github.com/llvm/llvm-project/commit/47d5e94acb92ce4ec5040e95e167ba471d080244
Author: FabianWolff <16052130+FabianWolff at users.noreply.github.com>
Date: 2025-05-27 (Tue, 27 May 2025)
Changed paths:
M clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
M clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
M clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp
Log Message:
-----------
[clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (#141092)
Currently we generate an incorrect suggestion for shared/unique pointers
to arrays; for instance ([Godbolt](https://godbolt.org/z/Tens1reGP)):
```c++
#include <memory>
void test_shared_ptr_to_array() {
std::shared_ptr<int[]> i;
auto s = sizeof(*i.get());
}
```
```
<source>:5:20: warning: redundant get() call on smart pointer [readability-redundant-smartptr-get]
5 | auto s = sizeof(*i.get());
| ^~~~~~~
| i
1 warning generated.
```
`sizeof(*i)` is incorrect, though, because the array specialization of
`std::shared/unique_ptr` does not have an `operator*()`. Therefore I
have disabled this check for smart pointers to arrays for now; future
work could, of course, improve on this by suggesting, say,
`sizeof(i[0])` in the above example.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list