================
@@ -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:

struct Inner {
  int a;
  int *getValue()  { return &a; }
};

struct Example {
  Inner inner;
  Inner* get() { return &inner; }
  int *getValue()  { return inner.getValue(); }
};

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()); // No redundancy here
  }
}

but cannot reproduce the redundant get() warning 




https://github.com/llvm/llvm-project/pull/98757
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to