about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--absl/base/attributes.h14
-rw-r--r--absl/synchronization/BUILD.bazel3
-rw-r--r--absl/types/optional.h3
3 files changed, 19 insertions, 1 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 3662f0fe7826..cc933bbaaee8 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -494,6 +494,20 @@
 #define ABSL_XRAY_LOG_ARGS(N)
 #endif
 
+// ABSL_ATTRIBUTE_REINITIALIZES
+//
+// Indicates that a member function reinitializes the entire object to a known
+// state, independent of the previous state of the object.
+//
+// The clang-tidy check bugprone-use-after-move allows member functions marked
+// with this attribute to be called on objects that have been moved from;
+// without the attribute, this would result in a use-after-move warning.
+#if ABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes)
+#define ABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
+#else
+#define ABSL_ATTRIBUTE_REINITIALIZES
+#endif
+
 // -----------------------------------------------------------------------------
 // Variable Attributes
 // -----------------------------------------------------------------------------
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel
index 3ee9e5a0425d..4f6a70740c2e 100644
--- a/absl/synchronization/BUILD.bazel
+++ b/absl/synchronization/BUILD.bazel
@@ -138,6 +138,9 @@ cc_library(
     name = "thread_pool",
     testonly = 1,
     hdrs = ["internal/thread_pool.h"],
+    visibility = [
+        "//absl:__subpackages__",
+    ],
     deps = [
         ":synchronization",
         "//absl/base:core_headers",
diff --git a/absl/types/optional.h b/absl/types/optional.h
index 79475e3ea3b3..14210018815c 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -59,6 +59,7 @@ using std::nullopt;
 #include <type_traits>
 #include <utility>
 
+#include "absl/base/attributes.h"
 #include "absl/memory/memory.h"
 #include "absl/meta/type_traits.h"
 #include "absl/types/bad_optional_access.h"
@@ -700,7 +701,7 @@ class optional : private optional_internal::optional_data<T>,
   // optional::reset()
   //
   // Destroys the inner `T` value of an `absl::optional` if one is present.
-  void reset() noexcept { this->destruct(); }
+  ABSL_ATTRIBUTE_REINITIALIZES void reset() noexcept { this->destruct(); }
 
   // optional::emplace()
   //