summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2024-05-23 13:07:39 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-05-23 13:08:21 -0700
commita7d70c872aaf5bfa8efcdb2814e914a7eabbe7d5 (patch)
tree18265173f233350391d74505e2e68a8a6548ef0a /absl
parent9e095d746f915339579798677a141a384543403e (diff)
Add ABSL_INTERNAL_ATTRIBUTE_VIEW and ABSL_INTERNAL_ATTRIBUTE_OWNER attributes to Abseil.
This will enable diagnoses similar to those enabled by ABSL_ATTRIBUTE_LIFETIME_BOUND. See the following links for details: https://reviews.llvm.org/D64448 https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html PiperOrigin-RevId: 636650605 Change-Id: Iab3a768d57775863addcf0a7c773551ee8f424c6
Diffstat (limited to 'absl')
-rw-r--r--absl/base/attributes.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index a6c40a76..e781995e 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -821,6 +821,32 @@
#define ABSL_ATTRIBUTE_LIFETIME_BOUND
#endif
+// ABSL_INTERNAL_ATTRIBUTE_VIEW indicates that a type acts like a view i.e. a
+// raw (non-owning) pointer. This enables diagnoses similar to those enabled by
+// ABSL_ATTRIBUTE_LIFETIME_BOUND.
+//
+// See the following links for details:
+// https://reviews.llvm.org/D64448
+// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
+#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Pointer)
+#define ABSL_INTERNAL_ATTRIBUTE_VIEW [[gsl::Pointer]]
+#else
+#define ABSL_INTERNAL_ATTRIBUTE_VIEW
+#endif
+
+// ABSL_INTERNAL_ATTRIBUTE_OWNER indicates that a type acts like a smart
+// (owning) pointer. This enables diagnoses similar to those enabled by
+// ABSL_ATTRIBUTE_LIFETIME_BOUND.
+//
+// See the following links for details:
+// https://reviews.llvm.org/D64448
+// https://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html
+#if ABSL_HAVE_CPP_ATTRIBUTE(gsl::Owner)
+#define ABSL_INTERNAL_ATTRIBUTE_OWNER [[gsl::Owner]]
+#else
+#define ABSL_INTERNAL_ATTRIBUTE_OWNER
+#endif
+
// ABSL_ATTRIBUTE_TRIVIAL_ABI
// Indicates that a type is "trivially relocatable" -- meaning it can be
// relocated without invoking the constructor/destructor, using a form of move