[libcxx-commits] [libcxx] Add [[clang::lifetimebound]] to numerous functions in libc++ include headers (PR #112751)
Haojian Wu via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 23 03:26:21 PDT 2024
hokein wrote:
> I think the basic_string_view and span recognition in Clang is probably going too far. For the other functions, we want to recognize them as builtins anyway for other reasons -- we really do treat them as being built-in -- and generally we apply attributes to functions that we treat as built-in that describe the built-in semantics.
Is the implicit annotation on `basic_string_view` and `span` constructors a concern? They aren't clang built-ins, but I think the difference is largely implementation-specific -- something that regular users wouldn't typically notice. From the user's perspective (or when examining the AST), the observable behavior remains consistent: Clang implicitly adds the lifetimebound attribute to some STL functions.
Adding the `lifetimebound` annotation to `basic_string_view` and `span` doesn’t seem to degrade the behavior (we also already implicitly add `gsl::Owner/Pointer` annotations to many STL types).
> . @hokein Could we move the inference of those attributes from being hardcoded in clang to the library?
As @Xazax-hun mentioned, the primary motivation is to allow Clang to detect dangling issues across different standard library implementations. APINotes seems like a promising solution for this, but we are not there yet.
https://github.com/llvm/llvm-project/pull/112751
More information about the libcxx-commits
mailing list