-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No dangling warnings on gsl::pointer-type function parameter with the lifetimebound attribute #100549
Comments
@llvm/issue-subscribers-clang-frontend Author: Haojian Wu (hokein)
These are real cases, it would be nice to capture them in clang.
Case1:
Case2:
|
These two cases can be captured with The simplified version: https://godbolt.org/z/fE1WKexo7 |
One option is to add the lifetime attribute to libcxx. The other option is to teach the gsl-specific code path ( |
@Xazax-hun @usx95 thoughts? |
There are pros a cons to annotate the library vs injecting annotations on the fly. Annotating I think if we want Clang to be as useful as possible, we'd need to inject these annotations into the standard library implementations, something similar to APINotes. I suspect that APINotes are still not ready, so in the meantime I am not opposed to special casing this in the warning. But I think all those special casing should go away once we can reliably inject annotations. I think the injection/inference of annotations, and the checking logic being separate is the cleanest possible design here. |
I feel gsl-analysis and lifetimebound are somewhat parallel analyses, and they could be more coherent. It makes sense to me to make gsl-analysis respect |
Agree, and APINotes seems like a good fit.
If I understand you correctly, by special casing, do you mean we implicitly attach the
I have a similar feeling about this. One of the consequences is:
This is similar to the issue #93386. |
Yes.
I see a potential way out of this. Is it possible to describe the semantics of GSL annotations in terms of |
FWIW, this precise case came up in Chromium over the weekend. Even a stopgap of annotating constructors in libc++ would help us, since we use libc++ by default. I agree that it's not a perfect solution, but it would be preferable (for us) to doing nothing until the compiler introspects harder. |
These are real cases, it would be nice to capture them in clang.
Case1:
Case2:
The text was updated successfully, but these errors were encountered: