[clang] [LifetimeSafety] Add warning for member functions returning field origins (PR #229784)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 10:01:01 PDT 2026
Xazax-hun wrote:
Having an exploratory tool is useful, but I am wondering if we have sufficient information to make this determination.
For example:
```
class Vector {
int* m_ptr;
...
int* data() { return m_ptr; }
};
class Span {
int* m_ptr;
...
int* data() { return m_ptr; }
};
```
`Span` and `Vector` here looks identical when we only look at the fields and the body of the `data` function. But they are very different in that `Vector` owns the data pointed by `m_ptr` while `Span` does not.
Is the plan to manually distinguish between these cases? Unfortunately, many types can own some data and be a view for others, so a classification on the type level might not solve this.
https://github.com/llvm/llvm-project/pull/229784
More information about the cfe-commits
mailing list