Issue 140473
Summary [clang-tidy] "bugprone-return-const-ref-from-parameter" - should consider `*this` as a parameter
Labels clang-tidy
Assignees
Reporter denzor200
    As I suppose this check is expected to show warning in `A::getThis` method:
```
struct A {
  const A& getThis() const{ return *this; };
};
```
But it didn't. Logically I don't see any difference between `A::getThis` method and `getThis` regular function like this:
```
const A& getThis(const A& a) { return a; };
```
But the alalizer thinks that there is a difference! And show warning only for `getThis` regular function.
The warning should also be provided for  `A::getThis` method because the known lifetime issue is also actual for it:
```
const auto& a = A().getThis();
// dangling `a`
```

The full snippet here: https://godbolt.org/z/xb669s6f3

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to