[clang-tools-extra] [libc] clang-tidy: readability-redundant-smartptr-get does not remove -> (#97964) (PR #98757)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 10:22:50 PDT 2024
================
@@ -235,3 +276,13 @@ void Negative() {
if (MACRO(x) == nullptr)
;
}
+
+void test_redundant_get() {
+ std::vector<std::shared_ptr<int>> v;
+ auto f = [](int) {};
+ for (auto i = v.begin(); i != v.end(); ++i) {
+ f(*i->get());
----------------
akshaykumars614 wrote:
I tried something like this but I am getting error
#include <memory>
#include <vector>
struct Inner {
int getValue() const { return 42; }
};
struct Example {
Inner inner;
Inner* get() { return &inner; }
};
void test_redundant_get() {
std::vector<std::shared_ptr<int>> v;
auto f = [](int) {};
for (auto i = v.begin(); i != v.end(); ++i) {
f(**i);
}
}
void test_redundant_get_with_member() {
std::vector<std::shared_ptr<Example>> v;
auto f = [](int) {};
for (auto i = v.begin(); i != v.end(); ++i) {
f(*i->get()->getValue());
}
}
/home/akumar/llvm/a.cpp:29:18: error: no member named 'getValue' in 'Example' [clang-diagnostic-error]
29 | f(*i->get()->getValue());
| ~~~~~~~~ ^
I am unable to get what wrong I am doing here
https://github.com/llvm/llvm-project/pull/98757
More information about the cfe-commits
mailing list