summaryrefslogtreecommitdiff
path: root/absl/status/internal
diff options
context:
space:
mode:
Diffstat (limited to 'absl/status/internal')
-rw-r--r--absl/status/internal/status_internal.cc8
-rw-r--r--absl/status/internal/status_internal.h8
-rw-r--r--absl/status/internal/statusor_internal.h6
3 files changed, 14 insertions, 8 deletions
diff --git a/absl/status/internal/status_internal.cc b/absl/status/internal/status_internal.cc
index 2307579b..a9156754 100644
--- a/absl/status/internal/status_internal.cc
+++ b/absl/status/internal/status_internal.cc
@@ -27,6 +27,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/macros.h"
+#include "absl/base/nullability.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
#include "absl/memory/memory.h"
@@ -187,7 +188,7 @@ bool StatusRep::operator==(const StatusRep& other) const {
return true;
}
-StatusRep* StatusRep::CloneAndUnref() const {
+absl::Nonnull<StatusRep*> StatusRep::CloneAndUnref() const {
// Optimization: no need to create a clone if we already have a refcount of 1.
if (ref_.load(std::memory_order_acquire) == 1) {
// All StatusRep instances are heap allocated and mutable, therefore this
@@ -233,8 +234,9 @@ absl::StatusCode MapToLocalCode(int value) {
}
}
-std::string* MakeCheckFailString(const absl::Status* status,
- const char* prefix) {
+absl::Nonnull<std::string*> MakeCheckFailString(
+ absl::Nonnull<const absl::Status*> status,
+ absl::Nonnull<const char*> prefix) {
return new std::string(
absl::StrCat(prefix, " (",
status->ToString(StatusToStringMode::kWithEverything), ")"));
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h
index c84e626f..c9f43832 100644
--- a/absl/status/internal/status_internal.h
+++ b/absl/status/internal/status_internal.h
@@ -22,6 +22,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
+#include "absl/base/nullability.h"
#include "absl/container/inlined_vector.h"
#include "absl/strings/cord.h"
#include "absl/strings/string_view.h"
@@ -99,7 +100,7 @@ class StatusRep {
// Returns an equivalent heap allocated StatusRep with refcount 1.
//
// `this` is not safe to be used after calling as it may have been deleted.
- StatusRep* CloneAndUnref() const;
+ absl::Nonnull<StatusRep*> CloneAndUnref() const;
private:
mutable std::atomic<int32_t> ref_;
@@ -119,8 +120,9 @@ absl::StatusCode MapToLocalCode(int value);
//
// This is an internal implementation detail for Abseil logging.
ABSL_ATTRIBUTE_PURE_FUNCTION
-std::string* MakeCheckFailString(const absl::Status* status,
- const char* prefix);
+absl::Nonnull<std::string*> MakeCheckFailString(
+ absl::Nonnull<const absl::Status*> status,
+ absl::Nonnull<const char*> prefix);
} // namespace status_internal
diff --git a/absl/status/internal/statusor_internal.h b/absl/status/internal/statusor_internal.h
index 49cead7a..25c11474 100644
--- a/absl/status/internal/statusor_internal.h
+++ b/absl/status/internal/statusor_internal.h
@@ -18,6 +18,7 @@
#include <utility>
#include "absl/base/attributes.h"
+#include "absl/base/nullability.h"
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include "absl/utility/utility.h"
@@ -123,7 +124,7 @@ using IsForwardingAssignmentValid = absl::disjunction<
class Helper {
public:
// Move type-agnostic error handling to the .cc.
- static void HandleInvalidStatusCtorArg(Status*);
+ static void HandleInvalidStatusCtorArg(absl::Nonnull<Status*>);
ABSL_ATTRIBUTE_NORETURN static void Crash(const absl::Status& status);
};
@@ -131,7 +132,8 @@ class Helper {
// the constructor.
// This abstraction is here mostly for the gcc performance fix.
template <typename T, typename... Args>
-ABSL_ATTRIBUTE_NONNULL(1) void PlacementNew(void* p, Args&&... args) {
+ABSL_ATTRIBUTE_NONNULL(1)
+void PlacementNew(absl::Nonnull<void*> p, Args&&... args) {
new (p) T(std::forward<Args>(args)...);
}