[libc-commits] [libc] [libc] add basic lifetime annotations for support data structures (PR #145933)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Oct 15 09:46:08 PDT 2025
================
@@ -91,4 +91,28 @@ LIBC_THREAD_MODE_EXTERNAL.
#define LIBC_NO_SANITIZE_OOB_ACCESS
#endif
+#if __has_attribute(lifetimebound)
+#define LIBC_LIFETIMEBOUND [[clang::lifetimebound]]
+#else
+#define LIBC_LIFETIMEBOUND
+#endif
+
+#if __has_attribute(lifetime_capture_by)
+#define LIBC_LIFETIME_CAPTURE_BY(X) [[clang::lifetime_capture_by(X)]]
+#else
+#define LIBC_LIFETIME_CAPTURE_BY(X)
+#endif
+
+#if defined(__clang__)
+#define LIBC_GSL_POINTER [[gsl::Pointer]]
+#else
+#define LIBC_GSL_POINTER
+#endif
+
+#if defined(__clang__)
+#define LIBC_GSL_OWNER [[gsl::Owner]]
+#else
+#define LIBC_GSL_OWNER
+#endif
----------------
michaelrj-google wrote:
if you want people to use these you should add comments to this file either explaining what they mean or linking to the clang docs on what they mean.
https://github.com/llvm/llvm-project/pull/145933
More information about the libc-commits
mailing list