diff --git a/absl/base/call_once.h b/absl/base/call_once.h index bd4b6572..7bfd9161 100644 --- a/absl/base/call_once.h +++ b/absl/base/call_once.h @@ -49,8 +49,8 @@ ABSL_NAMESPACE_BEGIN class once_flag; namespace base_internal { -absl::Nonnull*> ControlWord( - absl::Nonnull flag); +std::atomic* absl_nonnull ControlWord( + absl::once_flag* absl_nonnull flag); } // namespace base_internal // call_once() @@ -93,8 +93,8 @@ class once_flag { once_flag& operator=(const once_flag&) = delete; private: - friend absl::Nonnull*> base_internal::ControlWord( - absl::Nonnull flag); + friend std::atomic* absl_nonnull base_internal::ControlWord( + once_flag* absl_nonnull flag); std::atomic control_; }; @@ -108,7 +108,7 @@ namespace base_internal { // Like call_once, but uses KERNEL_ONLY scheduling. Intended to be used to // initialize entities used by the scheduler implementation. template -void LowLevelCallOnce(absl::Nonnull flag, Callable&& fn, +void LowLevelCallOnce(absl::once_flag* absl_nonnull flag, Callable&& fn, Args&&... args); // Disables scheduling while on stack when scheduling mode is non-cooperative. @@ -150,7 +150,7 @@ enum { template void - CallOnceImpl(absl::Nonnull*> control, + CallOnceImpl(std::atomic* absl_nonnull control, base_internal::SchedulingMode scheduling_mode, Callable&& fn, Args&&... args) { #ifndef NDEBUG @@ -190,13 +190,13 @@ template } // else *control is already kOnceDone } -inline absl::Nonnull*> ControlWord( - absl::Nonnull flag) { +inline std::atomic* absl_nonnull ControlWord( + once_flag* absl_nonnull flag) { return &flag->control_; } template -void LowLevelCallOnce(absl::Nonnull flag, Callable&& fn, +void LowLevelCallOnce(absl::once_flag* absl_nonnull flag, Callable&& fn, Args&&... args) { std::atomic* once = base_internal::ControlWord(flag); uint32_t s = once->load(std::memory_order_acquire); diff --git a/absl/base/internal/endian.h b/absl/base/internal/endian.h index e1a67f58..fb38f602 100644 --- a/absl/base/internal/endian.h +++ b/absl/base/internal/endian.h @@ -157,27 +157,27 @@ inline int64_t ToHost(int64_t x) { } // Functions to do unaligned loads and stores in little-endian order. -inline uint16_t Load16(absl::Nonnull p) { +inline uint16_t Load16(const void* absl_nonnull p) { return ToHost16(ABSL_INTERNAL_UNALIGNED_LOAD16(p)); } -inline void Store16(absl::Nonnull p, uint16_t v) { +inline void Store16(void* absl_nonnull p, uint16_t v) { ABSL_INTERNAL_UNALIGNED_STORE16(p, FromHost16(v)); } -inline uint32_t Load32(absl::Nonnull p) { +inline uint32_t Load32(const void* absl_nonnull p) { return ToHost32(ABSL_INTERNAL_UNALIGNED_LOAD32(p)); } -inline void Store32(absl::Nonnull p, uint32_t v) { +inline void Store32(void* absl_nonnull p, uint32_t v) { ABSL_INTERNAL_UNALIGNED_STORE32(p, FromHost32(v)); } -inline uint64_t Load64(absl::Nonnull p) { +inline uint64_t Load64(const void* absl_nonnull p) { return ToHost64(ABSL_INTERNAL_UNALIGNED_LOAD64(p)); } -inline void Store64(absl::Nonnull p, uint64_t v) { +inline void Store64(void* absl_nonnull p, uint64_t v) { ABSL_INTERNAL_UNALIGNED_STORE64(p, FromHost64(v)); } @@ -247,27 +247,27 @@ inline int64_t ToHost(int64_t x) { } // Functions to do unaligned loads and stores in big-endian order. -inline uint16_t Load16(absl::Nonnull p) { +inline uint16_t Load16(const void* absl_nonnull p) { return ToHost16(ABSL_INTERNAL_UNALIGNED_LOAD16(p)); } -inline void Store16(absl::Nonnull p, uint16_t v) { +inline void Store16(void* absl_nonnull p, uint16_t v) { ABSL_INTERNAL_UNALIGNED_STORE16(p, FromHost16(v)); } -inline uint32_t Load32(absl::Nonnull p) { +inline uint32_t Load32(const void* absl_nonnull p) { return ToHost32(ABSL_INTERNAL_UNALIGNED_LOAD32(p)); } -inline void Store32(absl::Nonnullp, uint32_t v) { +inline void Store32(void* absl_nonnull p, uint32_t v) { ABSL_INTERNAL_UNALIGNED_STORE32(p, FromHost32(v)); } -inline uint64_t Load64(absl::Nonnull p) { +inline uint64_t Load64(const void* absl_nonnull p) { return ToHost64(ABSL_INTERNAL_UNALIGNED_LOAD64(p)); } -inline void Store64(absl::Nonnull p, uint64_t v) { +inline void Store64(void* absl_nonnull p, uint64_t v) { ABSL_INTERNAL_UNALIGNED_STORE64(p, FromHost64(v)); } diff --git a/absl/base/internal/unaligned_access.h b/absl/base/internal/unaligned_access.h index 4fea4574..3f5dd6f9 100644 --- a/absl/base/internal/unaligned_access.h +++ b/absl/base/internal/unaligned_access.h @@ -36,33 +36,33 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal { -inline uint16_t UnalignedLoad16(absl::Nonnull p) { +inline uint16_t UnalignedLoad16(const void* absl_nonnull p) { uint16_t t; memcpy(&t, p, sizeof t); return t; } -inline uint32_t UnalignedLoad32(absl::Nonnull p) { +inline uint32_t UnalignedLoad32(const void* absl_nonnull p) { uint32_t t; memcpy(&t, p, sizeof t); return t; } -inline uint64_t UnalignedLoad64(absl::Nonnull p) { +inline uint64_t UnalignedLoad64(const void* absl_nonnull p) { uint64_t t; memcpy(&t, p, sizeof t); return t; } -inline void UnalignedStore16(absl::Nonnull p, uint16_t v) { +inline void UnalignedStore16(void* absl_nonnull p, uint16_t v) { memcpy(p, &v, sizeof v); } -inline void UnalignedStore32(absl::Nonnull p, uint32_t v) { +inline void UnalignedStore32(void* absl_nonnull p, uint32_t v) { memcpy(p, &v, sizeof v); } -inline void UnalignedStore64(absl::Nonnull p, uint64_t v) { +inline void UnalignedStore64(void* absl_nonnull p, uint64_t v) { memcpy(p, &v, sizeof v); } diff --git a/absl/base/no_destructor.h b/absl/base/no_destructor.h index 2478d691..9d960ee3 100644 --- a/absl/base/no_destructor.h +++ b/absl/base/no_destructor.h @@ -135,11 +135,11 @@ class NoDestructor { // Pretend to be a smart pointer to T with deep constness. // Never returns a null pointer. T& operator*() { return *get(); } - absl::Nonnull operator->() { return get(); } - absl::Nonnull get() { return impl_.get(); } + T* absl_nonnull operator->() { return get(); } + T* absl_nonnull get() { return impl_.get(); } const T& operator*() const { return *get(); } - absl::Nonnull operator->() const { return get(); } - absl::Nonnull get() const { return impl_.get(); } + const T* absl_nonnull operator->() const { return get(); } + const T* absl_nonnull get() const { return impl_.get(); } private: class DirectImpl { @@ -147,8 +147,8 @@ class NoDestructor { template explicit constexpr DirectImpl(Args&&... args) : value_(std::forward(args)...) {} - absl::Nonnull get() const { return &value_; } - absl::Nonnull get() { return &value_; } + const T* absl_nonnull get() const { return &value_; } + T* absl_nonnull get() { return &value_; } private: T value_; @@ -160,10 +160,10 @@ class NoDestructor { explicit PlacementImpl(Args&&... args) { new (&space_) T(std::forward(args)...); } - absl::Nonnull get() const { + const T* absl_nonnull get() const { return std::launder(reinterpret_cast(&space_)); } - absl::Nonnull get() { + T* absl_nonnull get() { return std::launder(reinterpret_cast(&space_)); } diff --git a/absl/debugging/internal/decode_rust_punycode.cc b/absl/debugging/internal/decode_rust_punycode.cc index 43b46bf9..6652dc22 100644 --- a/absl/debugging/internal/decode_rust_punycode.cc +++ b/absl/debugging/internal/decode_rust_punycode.cc @@ -172,7 +172,7 @@ bool ScanNextDelta(const char*& punycode_begin, const char* const punycode_end, } // namespace -absl::Nullable DecodeRustPunycode(DecodeRustPunycodeOptions options) { +char* absl_nullable DecodeRustPunycode(DecodeRustPunycodeOptions options) { const char* punycode_begin = options.punycode_begin; const char* const punycode_end = options.punycode_end; char* const out_begin = options.out_begin; diff --git a/absl/debugging/internal/decode_rust_punycode.h b/absl/debugging/internal/decode_rust_punycode.h index 0ae53ff3..b1b1c97f 100644 --- a/absl/debugging/internal/decode_rust_punycode.h +++ b/absl/debugging/internal/decode_rust_punycode.h @@ -46,7 +46,7 @@ struct DecodeRustPunycodeOptions { // DecodeRustPunycode is async-signal-safe with bounded runtime and a small // stack footprint, making it suitable for use in demangling Rust symbol names // from a signal handler. -absl::Nullable DecodeRustPunycode(DecodeRustPunycodeOptions options); +char* absl_nullable DecodeRustPunycode(DecodeRustPunycodeOptions options); } // namespace debugging_internal ABSL_NAMESPACE_END diff --git a/absl/log/internal/check_op.cc b/absl/log/internal/check_op.cc index bda8c095..23db63bf 100644 --- a/absl/log/internal/check_op.cc +++ b/absl/log/internal/check_op.cc @@ -36,8 +36,8 @@ ABSL_NAMESPACE_BEGIN namespace log_internal { #define ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(x) \ - template absl::Nonnull MakeCheckOpString( \ - x, x, absl::Nonnull) + template const char* absl_nonnull MakeCheckOpString( \ + x, x, const char* absl_nonnull) ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(bool); ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(int64_t); ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(uint64_t); @@ -54,7 +54,7 @@ ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING(const void*); #undef ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING CheckOpMessageBuilder::CheckOpMessageBuilder( - absl::Nonnull exprtext) { + const char* absl_nonnull exprtext) { stream_ << exprtext << " ("; } @@ -63,7 +63,7 @@ std::ostream& CheckOpMessageBuilder::ForVar2() { return stream_; } -absl::Nonnull CheckOpMessageBuilder::NewString() { +const char* absl_nonnull CheckOpMessageBuilder::NewString() { stream_ << ")"; // There's no need to free this string since the process is crashing. return absl::IgnoreLeak(new std::string(std::move(stream_).str()))->c_str(); @@ -103,9 +103,9 @@ void MakeCheckOpValueString(std::ostream& os, const void* p) { // Helper functions for string comparisons. #define DEFINE_CHECK_STROP_IMPL(name, func, expected) \ - absl::Nullable Check##func##expected##Impl( \ - absl::Nullable s1, absl::Nullable s2, \ - absl::Nonnull exprtext) { \ + const char* absl_nullable Check##func##expected##Impl( \ + const char* absl_nullable s1, const char* absl_nullable s2, \ + const char* absl_nonnull exprtext) { \ bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \ if (equal == expected) { \ return nullptr; \ diff --git a/absl/log/internal/check_op.h b/absl/log/internal/check_op.h index 8d7ade44..d609c0ee 100644 --- a/absl/log/internal/check_op.h +++ b/absl/log/internal/check_op.h @@ -64,49 +64,48 @@ #endif #define ABSL_LOG_INTERNAL_CHECK_OP(name, op, val1, val1_text, val2, val2_text) \ - while (absl::Nullable absl_log_internal_check_op_result \ - [[maybe_unused]] = \ - ::absl::log_internal::name##Impl( \ - ::absl::log_internal::GetReferenceableValue(val1), \ - ::absl::log_internal::GetReferenceableValue(val2), \ - ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \ - val1_text " " #op " " val2_text))) \ + while (const char* absl_nullable absl_log_internal_check_op_result \ + [[maybe_unused]] = ::absl::log_internal::name##Impl( \ + ::absl::log_internal::GetReferenceableValue(val1), \ + ::absl::log_internal::GetReferenceableValue(val2), \ + ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val1_text " " #op \ + " " val2_text))) \ ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast>( \ + ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast( \ absl_log_internal_check_op_result)) \ .InternalStream() -#define ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val1_text, val2, \ - val2_text) \ - while (absl::Nullable absl_log_internal_qcheck_op_result = \ - ::absl::log_internal::name##Impl( \ - ::absl::log_internal::GetReferenceableValue(val1), \ - ::absl::log_internal::GetReferenceableValue(val2), \ - ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \ - val1_text " " #op " " val2_text))) \ - ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast>( \ - absl_log_internal_qcheck_op_result)) \ +#define ABSL_LOG_INTERNAL_QCHECK_OP(name, op, val1, val1_text, val2, \ + val2_text) \ + while (const char* absl_nullable absl_log_internal_qcheck_op_result = \ + ::absl::log_internal::name##Impl( \ + ::absl::log_internal::GetReferenceableValue(val1), \ + ::absl::log_internal::GetReferenceableValue(val2), \ + ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL( \ + val1_text " " #op " " val2_text))) \ + ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \ + ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast( \ + absl_log_internal_qcheck_op_result)) \ .InternalStream() #define ABSL_LOG_INTERNAL_CHECK_STROP(func, op, expected, s1, s1_text, s2, \ s2_text) \ - while (absl::Nullable absl_log_internal_check_strop_result = \ + while (const char* absl_nullable absl_log_internal_check_strop_result = \ ::absl::log_internal::Check##func##expected##Impl( \ (s1), (s2), \ ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \ " " s2_text))) \ ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast>( \ + ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast( \ absl_log_internal_check_strop_result)) \ .InternalStream() #define ABSL_LOG_INTERNAL_QCHECK_STROP(func, op, expected, s1, s1_text, s2, \ s2_text) \ - while (absl::Nullable absl_log_internal_qcheck_strop_result = \ + while (const char* absl_nullable absl_log_internal_qcheck_strop_result = \ ::absl::log_internal::Check##func##expected##Impl( \ (s1), (s2), \ ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(s1_text " " #op \ " " s2_text))) \ ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast>( \ + ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast( \ absl_log_internal_qcheck_strop_result)) \ .InternalStream() @@ -134,41 +133,41 @@ // string literal and abort without doing any streaming. We don't need to // strip the call to stringify the non-ok `Status` as long as we don't log it; // dropping the `Status`'s message text is out of scope. -#define ABSL_LOG_INTERNAL_CHECK_OK(val, val_text) \ - for (::std::pair, \ - absl::Nullable> \ - absl_log_internal_check_ok_goo; \ - absl_log_internal_check_ok_goo.first = \ - ::absl::log_internal::AsStatus(val), \ - absl_log_internal_check_ok_goo.second = \ - ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok()) \ - ? nullptr \ - : ::absl::status_internal::MakeCheckFailString( \ - absl_log_internal_check_ok_goo.first, \ - ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \ - " is OK")), \ - !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());) \ - ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast>( \ - absl_log_internal_check_ok_goo.second)) \ +#define ABSL_LOG_INTERNAL_CHECK_OK(val, val_text) \ + for (::std::pair \ + absl_log_internal_check_ok_goo; \ + absl_log_internal_check_ok_goo.first = \ + ::absl::log_internal::AsStatus(val), \ + absl_log_internal_check_ok_goo.second = \ + ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok()) \ + ? nullptr \ + : ::absl::status_internal::MakeCheckFailString( \ + absl_log_internal_check_ok_goo.first, \ + ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \ + " is OK")), \ + !ABSL_PREDICT_TRUE(absl_log_internal_check_ok_goo.first->ok());) \ + ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, true) \ + ABSL_LOG_INTERNAL_CHECK(absl::implicit_cast( \ + absl_log_internal_check_ok_goo.second)) \ .InternalStream() -#define ABSL_LOG_INTERNAL_QCHECK_OK(val, val_text) \ - for (::std::pair, \ - absl::Nullable> \ - absl_log_internal_qcheck_ok_goo; \ - absl_log_internal_qcheck_ok_goo.first = \ - ::absl::log_internal::AsStatus(val), \ - absl_log_internal_qcheck_ok_goo.second = \ - ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok()) \ - ? nullptr \ - : ::absl::status_internal::MakeCheckFailString( \ - absl_log_internal_qcheck_ok_goo.first, \ - ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \ - " is OK")), \ - !ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok());) \ - ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \ - ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast>( \ - absl_log_internal_qcheck_ok_goo.second)) \ +#define ABSL_LOG_INTERNAL_QCHECK_OK(val, val_text) \ + for (::std::pair \ + absl_log_internal_qcheck_ok_goo; \ + absl_log_internal_qcheck_ok_goo.first = \ + ::absl::log_internal::AsStatus(val), \ + absl_log_internal_qcheck_ok_goo.second = \ + ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok()) \ + ? nullptr \ + : ::absl::status_internal::MakeCheckFailString( \ + absl_log_internal_qcheck_ok_goo.first, \ + ABSL_LOG_INTERNAL_STRIP_STRING_LITERAL(val_text \ + " is OK")), \ + !ABSL_PREDICT_TRUE(absl_log_internal_qcheck_ok_goo.first->ok());) \ + ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, true) \ + ABSL_LOG_INTERNAL_QCHECK(absl::implicit_cast( \ + absl_log_internal_qcheck_ok_goo.second)) \ .InternalStream() namespace absl { @@ -179,9 +178,8 @@ template class StatusOr; namespace status_internal { -ABSL_ATTRIBUTE_PURE_FUNCTION absl::Nonnull MakeCheckFailString( - absl::Nonnull status, - absl::Nonnull prefix); +ABSL_ATTRIBUTE_PURE_FUNCTION const char* absl_nonnull MakeCheckFailString( + const absl::Status* absl_nonnull status, const char* absl_nonnull prefix); } // namespace status_internal namespace log_internal { @@ -189,11 +187,11 @@ namespace log_internal { // Convert a Status or a StatusOr to its underlying status value. // // (This implementation does not require a dep on absl::Status to work.) -inline absl::Nonnull AsStatus(const absl::Status& s) { +inline const absl::Status* absl_nonnull AsStatus(const absl::Status& s) { return &s; } template -absl::Nonnull AsStatus(const absl::StatusOr& s) { +const absl::Status* absl_nonnull AsStatus(const absl::StatusOr& s) { return &s.status(); } @@ -202,14 +200,14 @@ absl::Nonnull AsStatus(const absl::StatusOr& s) { class CheckOpMessageBuilder final { public: // Inserts `exprtext` and ` (` to the stream. - explicit CheckOpMessageBuilder(absl::Nonnull exprtext); + explicit CheckOpMessageBuilder(const char* absl_nonnull exprtext); ~CheckOpMessageBuilder() = default; // For inserting the first variable. std::ostream& ForVar1() { return stream_; } // For inserting the second variable (adds an intermediate ` vs. `). std::ostream& ForVar2(); // Get the result (inserts the closing `)`). - absl::Nonnull NewString(); + const char* absl_nonnull NewString(); private: std::ostringstream stream_; @@ -352,12 +350,12 @@ using CheckOpStreamType = decltype(detect_specialization::Detect(0)); // Build the error message string. Specify no inlining for code size. template -ABSL_ATTRIBUTE_RETURNS_NONNULL absl::Nonnull MakeCheckOpString( - T1 v1, T2 v2, absl::Nonnull exprtext) ABSL_ATTRIBUTE_NOINLINE; +ABSL_ATTRIBUTE_RETURNS_NONNULL const char* absl_nonnull MakeCheckOpString( + T1 v1, T2 v2, const char* absl_nonnull exprtext) ABSL_ATTRIBUTE_NOINLINE; template -absl::Nonnull MakeCheckOpString( - T1 v1, T2 v2, absl::Nonnull exprtext) { +const char* absl_nonnull MakeCheckOpString(T1 v1, T2 v2, + const char* absl_nonnull exprtext) { CheckOpMessageBuilder comb(exprtext); MakeCheckOpValueString(comb.ForVar1(), v1); MakeCheckOpValueString(comb.ForVar2(), v2); @@ -367,8 +365,8 @@ absl::Nonnull MakeCheckOpString( // Add a few commonly used instantiations as extern to reduce size of objects // files. #define ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(x) \ - extern template absl::Nonnull MakeCheckOpString( \ - x, x, absl::Nonnull) + extern template const char* absl_nonnull MakeCheckOpString( \ + x, x, const char* absl_nonnull) ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(bool); ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(int64_t); ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(uint64_t); @@ -404,8 +402,8 @@ ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const void*); // type. #define ABSL_LOG_INTERNAL_CHECK_OP_IMPL(name, op) \ template \ - inline constexpr absl::Nullable name##Impl( \ - const T1& v1, const T2& v2, absl::Nonnull exprtext) { \ + inline constexpr const char* absl_nullable name##Impl( \ + const T1& v1, const T2& v2, const char* absl_nonnull exprtext) { \ using U1 = CheckOpStreamType; \ using U2 = CheckOpStreamType; \ return ABSL_PREDICT_TRUE(v1 op v2) \ @@ -413,8 +411,8 @@ ABSL_LOG_INTERNAL_DEFINE_MAKE_CHECK_OP_STRING_EXTERN(const void*); : ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT(U1, U2, U1(v1), \ U2(v2), exprtext); \ } \ - inline constexpr absl::Nullable name##Impl( \ - int v1, int v2, absl::Nonnull exprtext) { \ + inline constexpr const char* absl_nullable name##Impl( \ + int v1, int v2, const char* absl_nonnull exprtext) { \ return name##Impl(v1, v2, exprtext); \ } @@ -427,18 +425,18 @@ ABSL_LOG_INTERNAL_CHECK_OP_IMPL(Check_GT, >) #undef ABSL_LOG_INTERNAL_CHECK_OP_IMPL_RESULT #undef ABSL_LOG_INTERNAL_CHECK_OP_IMPL -absl::Nullable CheckstrcmptrueImpl( - absl::Nullable s1, absl::Nullable s2, - absl::Nonnull exprtext); -absl::Nullable CheckstrcmpfalseImpl( - absl::Nullable s1, absl::Nullable s2, - absl::Nonnull exprtext); -absl::Nullable CheckstrcasecmptrueImpl( - absl::Nullable s1, absl::Nullable s2, - absl::Nonnull exprtext); -absl::Nullable CheckstrcasecmpfalseImpl( - absl::Nullable s1, absl::Nullable s2, - absl::Nonnull exprtext); +const char* absl_nullable CheckstrcmptrueImpl( + const char* absl_nullable s1, const char* absl_nullable s2, + const char* absl_nonnull exprtext); +const char* absl_nullable CheckstrcmpfalseImpl( + const char* absl_nullable s1, const char* absl_nullable s2, + const char* absl_nonnull exprtext); +const char* absl_nullable CheckstrcasecmptrueImpl( + const char* absl_nullable s1, const char* absl_nullable s2, + const char* absl_nonnull exprtext); +const char* absl_nullable CheckstrcasecmpfalseImpl( + const char* absl_nullable s1, const char* absl_nullable s2, + const char* absl_nonnull exprtext); // `CHECK_EQ` and friends want to pass their arguments by reference, however // this winds up exposing lots of cases where people have defined and diff --git a/absl/log/internal/log_message.cc b/absl/log/internal/log_message.cc index 8dc5722a..aaaaf035 100644 --- a/absl/log/internal/log_message.cc +++ b/absl/log/internal/log_message.cc @@ -147,7 +147,7 @@ void WriteToStream(const char* data, void* os) { } // namespace struct LogMessage::LogMessageData final { - LogMessageData(absl::Nonnull file, int line, + LogMessageData(const char* absl_nonnull file, int line, absl::LogSeverity severity, absl::Time timestamp); LogMessageData(const LogMessageData&) = delete; LogMessageData& operator=(const LogMessageData&) = delete; @@ -163,7 +163,7 @@ struct LogMessage::LogMessageData final { bool is_perror; // Extra `LogSink`s to log to, in addition to `global_sinks`. - absl::InlinedVector, 16> extra_sinks; + absl::InlinedVector extra_sinks; // If true, log to `extra_sinks` but not to `global_sinks` or hardcoded // non-sink targets (e.g. stderr, log files). bool extra_sinks_only; @@ -199,7 +199,7 @@ struct LogMessage::LogMessageData final { void FinalizeEncodingAndFormat(); }; -LogMessage::LogMessageData::LogMessageData(absl::Nonnull file, +LogMessage::LogMessageData::LogMessageData(const char* absl_nonnull file, int line, absl::LogSeverity severity, absl::Time timestamp) : extra_sinks_only(false), manipulated(nullptr) { @@ -270,7 +270,7 @@ void LogMessage::LogMessageData::FinalizeEncodingAndFormat() { absl::MakeSpan(string_buf).subspan(0, chars_written); } -LogMessage::LogMessage(absl::Nonnull file, int line, +LogMessage::LogMessage(const char* absl_nonnull file, int line, absl::LogSeverity severity) : data_(absl::make_unique(file, line, severity, absl::Now())) { @@ -284,11 +284,11 @@ LogMessage::LogMessage(absl::Nonnull file, int line, LogBacktraceIfNeeded(); } -LogMessage::LogMessage(absl::Nonnull file, int line, InfoTag) +LogMessage::LogMessage(const char* absl_nonnull file, int line, InfoTag) : LogMessage(file, line, absl::LogSeverity::kInfo) {} -LogMessage::LogMessage(absl::Nonnull file, int line, WarningTag) +LogMessage::LogMessage(const char* absl_nonnull file, int line, WarningTag) : LogMessage(file, line, absl::LogSeverity::kWarning) {} -LogMessage::LogMessage(absl::Nonnull file, int line, ErrorTag) +LogMessage::LogMessage(const char* absl_nonnull file, int line, ErrorTag) : LogMessage(file, line, absl::LogSeverity::kError) {} // This cannot go in the header since LogMessageData is defined in this file. @@ -343,13 +343,13 @@ LogMessage& LogMessage::WithPerror() { return *this; } -LogMessage& LogMessage::ToSinkAlso(absl::Nonnull sink) { +LogMessage& LogMessage::ToSinkAlso(absl::LogSink* absl_nonnull sink) { ABSL_INTERNAL_CHECK(sink, "null LogSink*"); data_->extra_sinks.push_back(sink); return *this; } -LogMessage& LogMessage::ToSinkOnly(absl::Nonnull sink) { +LogMessage& LogMessage::ToSinkOnly(absl::LogSink* absl_nonnull sink) { ABSL_INTERNAL_CHECK(sink, "null LogSink*"); data_->extra_sinks.clear(); data_->extra_sinks.push_back(sink); @@ -673,11 +673,11 @@ void LogMessage::CopyToEncodedBufferWithStructuredProtoField( #pragma warning(disable : 4722) #endif -LogMessageFatal::LogMessageFatal(absl::Nonnull file, int line) +LogMessageFatal::LogMessageFatal(const char* absl_nonnull file, int line) : LogMessage(file, line, absl::LogSeverity::kFatal) {} -LogMessageFatal::LogMessageFatal(absl::Nonnull file, int line, - absl::Nonnull failure_msg) +LogMessageFatal::LogMessageFatal(const char* absl_nonnull file, int line, + const char* absl_nonnull failure_msg) : LogMessage(file, line, absl::LogSeverity::kFatal) { *this << "Check failed: " << failure_msg << " "; } @@ -686,7 +686,7 @@ LogMessageFatal::~LogMessageFatal() { FailWithoutStackTrace(); } -LogMessageDebugFatal::LogMessageDebugFatal(absl::Nonnull file, +LogMessageDebugFatal::LogMessageDebugFatal(const char* absl_nonnull file, int line) : LogMessage(file, line, absl::LogSeverity::kFatal) {} @@ -695,7 +695,7 @@ LogMessageDebugFatal::~LogMessageDebugFatal() { } LogMessageQuietlyDebugFatal::LogMessageQuietlyDebugFatal( - absl::Nonnull file, int line) + const char* absl_nonnull file, int line) : LogMessage(file, line, absl::LogSeverity::kFatal) { SetFailQuietly(); } @@ -704,15 +704,15 @@ LogMessageQuietlyDebugFatal::~LogMessageQuietlyDebugFatal() { FailQuietly(); } -LogMessageQuietlyFatal::LogMessageQuietlyFatal(absl::Nonnull file, +LogMessageQuietlyFatal::LogMessageQuietlyFatal(const char* absl_nonnull file, int line) : LogMessage(file, line, absl::LogSeverity::kFatal) { SetFailQuietly(); } LogMessageQuietlyFatal::LogMessageQuietlyFatal( - absl::Nonnull file, int line, - absl::Nonnull failure_msg) + const char* absl_nonnull file, int line, + const char* absl_nonnull failure_msg) : LogMessageQuietlyFatal(file, line) { *this << "Check failed: " << failure_msg << " "; } diff --git a/absl/log/internal/log_message.h b/absl/log/internal/log_message.h index 8acc4a15..de9fb8f4 100644 --- a/absl/log/internal/log_message.h +++ b/absl/log/internal/log_message.h @@ -62,15 +62,15 @@ class LogMessage { struct ErrorTag {}; // Used for `LOG`. - LogMessage(absl::Nonnull file, int line, + LogMessage(const char* absl_nonnull file, int line, absl::LogSeverity severity) ABSL_ATTRIBUTE_COLD; // These constructors are slightly smaller/faster to call; the severity is // curried into the function pointer. - LogMessage(absl::Nonnull file, int line, + LogMessage(const char* absl_nonnull file, int line, InfoTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE; - LogMessage(absl::Nonnull file, int line, + LogMessage(const char* absl_nonnull file, int line, WarningTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE; - LogMessage(absl::Nonnull file, int line, + LogMessage(const char* absl_nonnull file, int line, ErrorTag) ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE; LogMessage(const LogMessage&) = delete; LogMessage& operator=(const LogMessage&) = delete; @@ -102,9 +102,9 @@ class LogMessage { LogMessage& WithPerror(); // Sends this message to `*sink` in addition to whatever other sinks it would // otherwise have been sent to. - LogMessage& ToSinkAlso(absl::Nonnull sink); + LogMessage& ToSinkAlso(absl::LogSink* absl_nonnull sink); // Sends this message to `*sink` and no others. - LogMessage& ToSinkOnly(absl::Nonnull sink); + LogMessage& ToSinkOnly(absl::LogSink* absl_nonnull sink); // Don't call this method from outside this library. LogMessage& InternalStream() { return *this; } @@ -141,10 +141,10 @@ class LogMessage { LogMessage& operator<<(unsigned long long v) { return operator<< (v); } - LogMessage& operator<<(absl::Nullable v) { + LogMessage& operator<<(void* absl_nullable v) { return operator<< (v); } - LogMessage& operator<<(absl::Nullable v) { + LogMessage& operator<<(const void* absl_nullable v) { return operator<< (v); } LogMessage& operator<<(float v) { return operator<< (v); } @@ -271,7 +271,7 @@ class LogMessage { // We keep the data in a separate struct so that each instance of `LogMessage` // uses less stack space. - absl::Nonnull> data_; + absl_nonnull std::unique_ptr data_; }; // Helper class so that `AbslStringify()` can modify the LogMessage. @@ -289,7 +289,7 @@ class StringifySink final { } // For types that implement `AbslStringify` using `absl::Format()`. - friend void AbslFormatFlush(absl::Nonnull sink, + friend void AbslFormatFlush(StringifySink* absl_nonnull sink, absl::string_view v) { sink->Append(v); } @@ -341,9 +341,9 @@ extern template LogMessage& LogMessage::operator<<(const unsigned long& v); extern template LogMessage& LogMessage::operator<<(const long long& v); extern template LogMessage& LogMessage::operator<<(const unsigned long long& v); extern template LogMessage& LogMessage::operator<<( - absl::Nullable const& v); + void* absl_nullable const& v); extern template LogMessage& LogMessage::operator<<( - absl::Nullable const& v); + const void* absl_nullable const& v); extern template LogMessage& LogMessage::operator<<(const float& v); extern template LogMessage& LogMessage::operator<<(const double& v); extern template LogMessage& LogMessage::operator<<(const bool& v); @@ -364,10 +364,9 @@ extern template void LogMessage::CopyToEncodedBuffer< // message. class LogMessageFatal final : public LogMessage { public: - LogMessageFatal(absl::Nonnull file, - int line) ABSL_ATTRIBUTE_COLD; - LogMessageFatal(absl::Nonnull file, int line, - absl::Nonnull failure_msg) ABSL_ATTRIBUTE_COLD; + LogMessageFatal(const char* absl_nonnull file, int line) ABSL_ATTRIBUTE_COLD; + LogMessageFatal(const char* absl_nonnull file, int line, + const char* absl_nonnull failure_msg) ABSL_ATTRIBUTE_COLD; [[noreturn]] ~LogMessageFatal(); }; @@ -376,7 +375,7 @@ class LogMessageFatal final : public LogMessage { // for DLOG(FATAL) variants. class LogMessageDebugFatal final : public LogMessage { public: - LogMessageDebugFatal(absl::Nonnull file, + LogMessageDebugFatal(const char* absl_nonnull file, int line) ABSL_ATTRIBUTE_COLD; ~LogMessageDebugFatal(); }; @@ -386,7 +385,7 @@ class LogMessageQuietlyDebugFatal final : public LogMessage { // DLOG(QFATAL) calls this instead of LogMessageQuietlyFatal to make sure the // destructor is not [[noreturn]] even if this is always FATAL as this is only // invoked when DLOG() is enabled. - LogMessageQuietlyDebugFatal(absl::Nonnull file, + LogMessageQuietlyDebugFatal(const char* absl_nonnull file, int line) ABSL_ATTRIBUTE_COLD; ~LogMessageQuietlyDebugFatal(); }; @@ -394,10 +393,10 @@ class LogMessageQuietlyDebugFatal final : public LogMessage { // Used for LOG(QFATAL) to make sure it's properly understood as [[noreturn]]. class LogMessageQuietlyFatal final : public LogMessage { public: - LogMessageQuietlyFatal(absl::Nonnull file, + LogMessageQuietlyFatal(const char* absl_nonnull file, int line) ABSL_ATTRIBUTE_COLD; - LogMessageQuietlyFatal(absl::Nonnull file, int line, - absl::Nonnull failure_msg) + LogMessageQuietlyFatal(const char* absl_nonnull file, int line, + const char* absl_nonnull failure_msg) ABSL_ATTRIBUTE_COLD; [[noreturn]] ~LogMessageQuietlyFatal(); }; diff --git a/absl/log/log_sink_registry.h b/absl/log/log_sink_registry.h index 3aa3bf67..a3fa9a3d 100644 --- a/absl/log/log_sink_registry.h +++ b/absl/log/log_sink_registry.h @@ -44,10 +44,10 @@ ABSL_NAMESPACE_BEGIN // sink instead which writes them to `stderr`. // // Do not call these inside `absl::LogSink::Send`. -inline void AddLogSink(absl::Nonnull sink) { +inline void AddLogSink(absl::LogSink* absl_nonnull sink) { log_internal::AddLogSink(sink); } -inline void RemoveLogSink(absl::Nonnull sink) { +inline void RemoveLogSink(absl::LogSink* absl_nonnull sink) { log_internal::RemoveLogSink(sink); } diff --git a/absl/status/internal/status_internal.cc b/absl/status/internal/status_internal.cc index 99bf8fac..98841890 100644 --- a/absl/status/internal/status_internal.cc +++ b/absl/status/internal/status_internal.cc @@ -189,7 +189,7 @@ bool StatusRep::operator==(const StatusRep& other) const { return true; } -absl::Nonnull StatusRep::CloneAndUnref() const { +StatusRep* absl_nonnull 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 @@ -235,9 +235,8 @@ absl::StatusCode MapToLocalCode(int value) { } } -absl::Nonnull MakeCheckFailString( - absl::Nonnull status, - absl::Nonnull prefix) { +const char* absl_nonnull MakeCheckFailString( + const absl::Status* absl_nonnull status, const char* absl_nonnull prefix) { // There's no need to free this string since the process is crashing. return absl::IgnoreLeak( new std::string(absl::StrCat( diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h index fe335b0b..45b90f36 100644 --- a/absl/status/internal/status_internal.h +++ b/absl/status/internal/status_internal.h @@ -100,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. - absl::Nonnull CloneAndUnref() const; + StatusRep* absl_nonnull CloneAndUnref() const; private: mutable std::atomic ref_; @@ -120,9 +120,8 @@ absl::StatusCode MapToLocalCode(int value); // // This is an internal implementation detail for Abseil logging. ABSL_ATTRIBUTE_PURE_FUNCTION -absl::Nonnull MakeCheckFailString( - absl::Nonnull status, - absl::Nonnull prefix); +const char* absl_nonnull MakeCheckFailString( + const absl::Status* absl_nonnull status, const char* absl_nonnull prefix); } // namespace status_internal diff --git a/absl/status/internal/statusor_internal.h b/absl/status/internal/statusor_internal.h index 67603156..ca7c5502 100644 --- a/absl/status/internal/statusor_internal.h +++ b/absl/status/internal/statusor_internal.h @@ -185,7 +185,7 @@ using IsStatusOrAssignmentValid = absl::conjunction< class Helper { public: // Move type-agnostic error handling to the .cc. - static void HandleInvalidStatusCtorArg(absl::Nonnull); + static void HandleInvalidStatusCtorArg(Status* absl_nonnull); [[noreturn]] static void Crash(const absl::Status& status); }; @@ -194,7 +194,7 @@ class Helper { // This abstraction is here mostly for the gcc performance fix. template ABSL_ATTRIBUTE_NONNULL(1) -void PlacementNew(absl::Nonnull p, Args&&... args) { +void PlacementNew(void* absl_nonnull p, Args&&... args) { new (p) T(std::forward(args)...); } diff --git a/absl/status/status.cc b/absl/status/status.cc index 72a25260..963dab67 100644 --- a/absl/status/status.cc +++ b/absl/status/status.cc @@ -91,12 +91,12 @@ std::ostream& operator<<(std::ostream& os, StatusCode code) { return os << StatusCodeToString(code); } -absl::Nonnull Status::EmptyString() { +const std::string* absl_nonnull Status::EmptyString() { static const absl::NoDestructor kEmpty; return kEmpty.get(); } -absl::Nonnull Status::MovedFromString() { +const std::string* absl_nonnull Status::MovedFromString() { static const absl::NoDestructor kMovedFrom(kMovedFromString); return kMovedFrom.get(); } @@ -108,7 +108,7 @@ Status::Status(absl::StatusCode code, absl::string_view msg) } } -absl::Nonnull Status::PrepareToModify( +status_internal::StatusRep* absl_nonnull Status::PrepareToModify( uintptr_t rep) { if (IsInlined(rep)) { return new status_internal::StatusRep(InlinedRepToCode(rep), @@ -406,7 +406,7 @@ Status ErrnoToStatus(int error_number, absl::string_view message) { MessageForErrnoToStatus(error_number, message)); } -absl::Nonnull StatusMessageAsCStr(const Status& status) { +const char* absl_nonnull StatusMessageAsCStr(const Status& status) { // As an internal implementation detail, we guarantee that if status.message() // is non-empty, then the resulting string_view is null terminated. auto sv_message = status.message(); diff --git a/absl/status/status.h b/absl/status/status.h index 02fd2964..45168225 100644 --- a/absl/status/status.h +++ b/absl/status/status.h @@ -623,15 +623,15 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final { // REQUIRES: !ok() // Ensures rep is not inlined or shared with any other Status. - static absl::Nonnull PrepareToModify( + static status_internal::StatusRep* absl_nonnull PrepareToModify( uintptr_t rep); // MSVC 14.0 limitation requires the const. static constexpr const char kMovedFromString[] = "Status accessed after move."; - static absl::Nonnull EmptyString(); - static absl::Nonnull MovedFromString(); + static const std::string* absl_nonnull EmptyString(); + static const std::string* absl_nonnull MovedFromString(); // Returns whether rep contains an inlined representation. // See rep_ for details. @@ -649,8 +649,8 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final { // Converts between StatusRep* and the external uintptr_t representation used // by rep_. See rep_ for details. - static uintptr_t PointerToRep(absl::Nonnull r); - static absl::Nonnull RepToPointer( + static uintptr_t PointerToRep(status_internal::StatusRep* absl_nonnull r); + static const status_internal::StatusRep* absl_nonnull RepToPointer( uintptr_t r); static std::string ToStringSlow(uintptr_t rep, StatusToStringMode mode); @@ -902,14 +902,14 @@ constexpr uintptr_t Status::MovedFromRep() { return CodeToInlinedRep(absl::StatusCode::kInternal) | 2; } -inline absl::Nonnull Status::RepToPointer( +inline const status_internal::StatusRep* absl_nonnull Status::RepToPointer( uintptr_t rep) { assert(!IsInlined(rep)); return reinterpret_cast(rep); } inline uintptr_t Status::PointerToRep( - absl::Nonnull rep) { + status_internal::StatusRep* absl_nonnull rep) { return reinterpret_cast(rep); } @@ -934,7 +934,7 @@ inline Status CancelledError() { return Status(absl::StatusCode::kCancelled); } // If the status's message is empty, the empty string is returned. // // StatusMessageAsCStr exists for C support. Use `status.message()` in C++. -absl::Nonnull StatusMessageAsCStr( +const char* absl_nonnull StatusMessageAsCStr( const Status& status ABSL_ATTRIBUTE_LIFETIME_BOUND); ABSL_NAMESPACE_END diff --git a/absl/status/statusor.cc b/absl/status/statusor.cc index 7e6b334c..d8f66a64 100644 --- a/absl/status/statusor.cc +++ b/absl/status/statusor.cc @@ -55,7 +55,7 @@ BadStatusOrAccess& BadStatusOrAccess::operator=(BadStatusOrAccess&& other) { BadStatusOrAccess::BadStatusOrAccess(BadStatusOrAccess&& other) : status_(std::move(other.status_)) {} -absl::Nonnull BadStatusOrAccess::what() const noexcept { +const char* absl_nonnull BadStatusOrAccess::what() const noexcept { InitWhat(); return what_.c_str(); } @@ -70,7 +70,7 @@ void BadStatusOrAccess::InitWhat() const { namespace internal_statusor { -void Helper::HandleInvalidStatusCtorArg(absl::Nonnull status) { +void Helper::HandleInvalidStatusCtorArg(absl::Status* absl_nonnull status) { const char* kMessage = "An OK status is not a valid constructor argument to StatusOr"; #ifdef NDEBUG diff --git a/absl/status/statusor.h b/absl/status/statusor.h index 322d448b..5257af0e 100644 --- a/absl/status/statusor.h +++ b/absl/status/statusor.h @@ -93,7 +93,7 @@ class BadStatusOrAccess : public std::exception { // // The pointer of this string is guaranteed to be valid until any non-const // function is invoked on the exception object. - absl::Nonnull what() const noexcept override; + const char* absl_nonnull what() const noexcept override; // BadStatusOrAccess::status() // @@ -756,13 +756,13 @@ T&& StatusOr::operator*() && { } template -absl::Nonnull StatusOr::operator->() const { +const T* absl_nonnull StatusOr::operator->() const { this->EnsureOk(); return &this->data_; } template -absl::Nonnull StatusOr::operator->() { +T* absl_nonnull StatusOr::operator->() { this->EnsureOk(); return &this->data_; } diff --git a/absl/strings/ascii.cc b/absl/strings/ascii.cc index d15e4249..4cd9ff94 100644 --- a/absl/strings/ascii.cc +++ b/absl/strings/ascii.cc @@ -183,8 +183,8 @@ constexpr bool AsciiInAZRangeNaive(unsigned char c) { } template -constexpr void AsciiStrCaseFoldImpl(absl::Nonnull dst, - absl::Nullable src, +constexpr void AsciiStrCaseFoldImpl(char* absl_nonnull dst, + const char* absl_nullable src, size_t size) { // The upper- and lowercase versions of ASCII characters differ by only 1 bit. // When we need to flip the case, we can xor with this bit to achieve the @@ -211,18 +211,18 @@ constexpr void AsciiStrCaseFoldImpl(absl::Nonnull dst, // strings it's not important). // `src` may be null iff `size` is zero. template -constexpr void AsciiStrCaseFold(absl::Nonnull dst, - absl::Nullable src, size_t size) { +constexpr void AsciiStrCaseFold(char* absl_nonnull dst, + const char* absl_nullable src, size_t size) { size < 16 ? AsciiStrCaseFoldImpl(dst, src, size) : AsciiStrCaseFoldImpl(dst, src, size); } -void AsciiStrToLower(absl::Nonnull dst, absl::Nullable src, +void AsciiStrToLower(char* absl_nonnull dst, const char* absl_nullable src, size_t n) { return AsciiStrCaseFold(dst, src, n); } -void AsciiStrToUpper(absl::Nonnull dst, absl::Nullable src, +void AsciiStrToUpper(char* absl_nonnull dst, const char* absl_nullable src, size_t n) { return AsciiStrCaseFold(dst, src, n); } @@ -253,17 +253,17 @@ static_assert(ValidateAsciiCasefold() == 0, "error in case conversion"); } // namespace ascii_internal -void AsciiStrToLower(absl::Nonnull s) { +void AsciiStrToLower(std::string* absl_nonnull s) { char* p = &(*s)[0]; return ascii_internal::AsciiStrCaseFold(p, p, s->size()); } -void AsciiStrToUpper(absl::Nonnull s) { +void AsciiStrToUpper(std::string* absl_nonnull s) { char* p = &(*s)[0]; return ascii_internal::AsciiStrCaseFold(p, p, s->size()); } -void RemoveExtraAsciiWhitespace(absl::Nonnull str) { +void RemoveExtraAsciiWhitespace(std::string* absl_nonnull str) { auto stripped = StripAsciiWhitespace(*str); if (stripped.empty()) { diff --git a/absl/strings/ascii.h b/absl/strings/ascii.h index bf60baeb..ca0747e5 100644 --- a/absl/strings/ascii.h +++ b/absl/strings/ascii.h @@ -76,10 +76,10 @@ ABSL_DLL extern const char kToUpper[256]; // Declaration for the array of characters to lower-case characters. ABSL_DLL extern const char kToLower[256]; -void AsciiStrToLower(absl::Nonnull dst, absl::Nullable src, +void AsciiStrToLower(char* absl_nonnull dst, const char* absl_nullable src, size_t n); -void AsciiStrToUpper(absl::Nonnull dst, absl::Nullable src, +void AsciiStrToUpper(char* absl_nonnull dst, const char* absl_nullable src, size_t n); } // namespace ascii_internal @@ -185,7 +185,7 @@ inline char ascii_tolower(unsigned char c) { } // Converts the characters in `s` to lowercase, changing the contents of `s`. -void AsciiStrToLower(absl::Nonnull s); +void AsciiStrToLower(std::string* absl_nonnull s); // Creates a lowercase string from a given absl::string_view. [[nodiscard]] inline std::string AsciiStrToLower(absl::string_view s) { @@ -214,7 +214,7 @@ inline char ascii_toupper(unsigned char c) { } // Converts the characters in `s` to uppercase, changing the contents of `s`. -void AsciiStrToUpper(absl::Nonnull s); +void AsciiStrToUpper(std::string* absl_nonnull s); // Creates an uppercase string from a given absl::string_view. [[nodiscard]] inline std::string AsciiStrToUpper(absl::string_view s) { @@ -243,7 +243,7 @@ template } // Strips in place whitespace from the beginning of the given string. -inline void StripLeadingAsciiWhitespace(absl::Nonnull str) { +inline void StripLeadingAsciiWhitespace(std::string* absl_nonnull str) { auto it = std::find_if_not(str->begin(), str->end(), absl::ascii_isspace); str->erase(str->begin(), it); } @@ -257,7 +257,7 @@ inline void StripLeadingAsciiWhitespace(absl::Nonnull str) { } // Strips in place whitespace from the end of the given string -inline void StripTrailingAsciiWhitespace(absl::Nonnull str) { +inline void StripTrailingAsciiWhitespace(std::string* absl_nonnull str) { auto it = std::find_if_not(str->rbegin(), str->rend(), absl::ascii_isspace); str->erase(static_cast(str->rend() - it)); } @@ -270,13 +270,13 @@ inline void StripTrailingAsciiWhitespace(absl::Nonnull str) { } // Strips in place whitespace from both ends of the given string -inline void StripAsciiWhitespace(absl::Nonnull str) { +inline void StripAsciiWhitespace(std::string* absl_nonnull str) { StripTrailingAsciiWhitespace(str); StripLeadingAsciiWhitespace(str); } // Removes leading, trailing, and consecutive internal whitespace. -void RemoveExtraAsciiWhitespace(absl::Nonnull str); +void RemoveExtraAsciiWhitespace(std::string* absl_nonnull str); ABSL_NAMESPACE_END } // namespace absl diff --git a/absl/strings/charconv.cc b/absl/strings/charconv.cc index 681eb93b..6f367739 100644 --- a/absl/strings/charconv.cc +++ b/absl/strings/charconv.cc @@ -120,7 +120,7 @@ struct FloatTraits { // Parsing a smaller N will produce something finite. static constexpr int kEiselLemireMaxExclusiveExp10 = 309; - static double MakeNan(absl::Nonnull tagp) { + static double MakeNan(const char* absl_nonnull tagp) { #if ABSL_HAVE_BUILTIN(__builtin_nan) // Use __builtin_nan() if available since it has a fix for // https://bugs.llvm.org/show_bug.cgi?id=37778 @@ -193,7 +193,7 @@ struct FloatTraits { static constexpr int kEiselLemireMinInclusiveExp10 = -46 - 18; static constexpr int kEiselLemireMaxExclusiveExp10 = 39; - static float MakeNan(absl::Nonnull tagp) { + static float MakeNan(const char* absl_nonnull tagp) { #if ABSL_HAVE_BUILTIN(__builtin_nanf) // Use __builtin_nanf() if available since it has a fix for // https://bugs.llvm.org/show_bug.cgi?id=37778 @@ -345,7 +345,7 @@ int NormalizedShiftSize(int mantissa_width, int binary_exponent) { // `value` must be wider than the requested bit width. // // Returns the number of bits shifted. -int TruncateToBitWidth(int bit_width, absl::Nonnull value) { +int TruncateToBitWidth(int bit_width, uint128* absl_nonnull value) { const int current_bit_width = BitWidth(*value); const int shift = current_bit_width - bit_width; *value >>= shift; @@ -357,7 +357,7 @@ int TruncateToBitWidth(int bit_width, absl::Nonnull value) { // the appropriate double, and returns true. template bool HandleEdgeCase(const strings_internal::ParsedFloat& input, bool negative, - absl::Nonnull value) { + FloatType* absl_nonnull value) { if (input.type == strings_internal::FloatType::kNan) { // A bug in gcc would cause the compiler to optimize away the buffer we are // building below. Declaring the buffer volatile avoids the issue, and has @@ -403,8 +403,8 @@ bool HandleEdgeCase(const strings_internal::ParsedFloat& input, bool negative, // number is stored in *value. template void EncodeResult(const CalculatedFloat& calculated, bool negative, - absl::Nonnull result, - absl::Nonnull value) { + absl::from_chars_result* absl_nonnull result, + FloatType* absl_nonnull value) { if (calculated.exponent == kOverflow) { result->ec = std::errc::result_out_of_range; *value = negative ? -std::numeric_limits::max() @@ -450,7 +450,7 @@ void EncodeResult(const CalculatedFloat& calculated, bool negative, // Zero and negative values of `shift` are accepted, in which case the word is // shifted left, as necessary. uint64_t ShiftRightAndRound(uint128 value, int shift, bool input_exact, - absl::Nonnull output_exact) { + bool* absl_nonnull output_exact) { if (shift <= 0) { *output_exact = input_exact; return static_cast(value << -shift); @@ -684,8 +684,7 @@ CalculatedFloat CalculateFromParsedDecimal( // this function returns false) is both fast and correct. template bool EiselLemire(const strings_internal::ParsedFloat& input, bool negative, - absl::Nonnull value, - absl::Nonnull ec) { + FloatType* absl_nonnull value, std::errc* absl_nonnull ec) { uint64_t man = input.mantissa; int exp10 = input.exponent; if (exp10 < FloatTraits::kEiselLemireMinInclusiveExp10) { @@ -858,9 +857,9 @@ bool EiselLemire(const strings_internal::ParsedFloat& input, bool negative, } template -from_chars_result FromCharsImpl(absl::Nonnull first, - absl::Nonnull last, - FloatType& value, chars_format fmt_flags) { +from_chars_result FromCharsImpl(const char* absl_nonnull first, + const char* absl_nonnull last, FloatType& value, + chars_format fmt_flags) { from_chars_result result; result.ptr = first; // overwritten on successful parse result.ec = std::errc(); @@ -945,14 +944,14 @@ from_chars_result FromCharsImpl(absl::Nonnull first, } } // namespace -from_chars_result from_chars(absl::Nonnull first, - absl::Nonnull last, double& value, +from_chars_result from_chars(const char* absl_nonnull first, + const char* absl_nonnull last, double& value, chars_format fmt) { return FromCharsImpl(first, last, value, fmt); } -from_chars_result from_chars(absl::Nonnull first, - absl::Nonnull last, float& value, +from_chars_result from_chars(const char* absl_nonnull first, + const char* absl_nonnull last, float& value, chars_format fmt) { return FromCharsImpl(first, last, value, fmt); } diff --git a/absl/strings/charconv.h b/absl/strings/charconv.h index be250902..e5733f8c 100644 --- a/absl/strings/charconv.h +++ b/absl/strings/charconv.h @@ -45,7 +45,7 @@ enum class chars_format { // characters that were successfully parsed. If none was found, `ptr` is set // to the `first` argument to from_chars. struct from_chars_result { - absl::Nonnull ptr; + const char* absl_nonnull ptr; std::errc ec; }; @@ -77,13 +77,13 @@ struct from_chars_result { // format that strtod() accepts, except that a "0x" prefix is NOT matched. // (In particular, in `hex` mode, the input "0xff" results in the largest // matching pattern "0".) -absl::from_chars_result from_chars(absl::Nonnull first, - absl::Nonnull last, +absl::from_chars_result from_chars(const char* absl_nonnull first, + const char* absl_nonnull last, double& value, // NOLINT chars_format fmt = chars_format::general); -absl::from_chars_result from_chars(absl::Nonnull first, - absl::Nonnull last, +absl::from_chars_result from_chars(const char* absl_nonnull first, + const char* absl_nonnull last, float& value, // NOLINT chars_format fmt = chars_format::general); diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc index 287458a8..e53f914d 100644 --- a/absl/strings/cord.cc +++ b/absl/strings/cord.cc @@ -75,21 +75,19 @@ using ::absl::cord_internal::kMinFlatLength; using ::absl::cord_internal::kInlinedVectorSize; using ::absl::cord_internal::kMaxBytesToCopy; -static void DumpNode(absl::Nonnull nonnull_rep, bool include_data, - absl::Nonnull os, int indent = 0); -static bool VerifyNode(absl::Nonnull root, - absl::Nonnull start_node); +static void DumpNode(CordRep* absl_nonnull nonnull_rep, bool include_data, + std::ostream* absl_nonnull os, int indent = 0); +static bool VerifyNode(CordRep* absl_nonnull root, + CordRep* absl_nonnull start_node); -static inline absl::Nullable VerifyTree( - absl::Nullable node) { +static inline CordRep* absl_nullable VerifyTree(CordRep* absl_nullable node) { assert(node == nullptr || VerifyNode(node, node)); static_cast(&VerifyNode); return node; } -static absl::Nonnull CreateFlat(absl::Nonnull data, - size_t length, - size_t alloc_hint) { +static CordRepFlat* absl_nonnull CreateFlat(const char* absl_nonnull data, + size_t length, size_t alloc_hint) { CordRepFlat* flat = CordRepFlat::New(length + alloc_hint); flat->length = length; memcpy(flat->Data(), data, length); @@ -98,8 +96,8 @@ static absl::Nonnull CreateFlat(absl::Nonnull data, // Creates a new flat or Btree out of the specified array. // The returned node has a refcount of 1. -static absl::Nonnull NewBtree(absl::Nonnull data, - size_t length, size_t alloc_hint) { +static CordRep* absl_nonnull NewBtree(const char* absl_nonnull data, + size_t length, size_t alloc_hint) { if (length <= kMaxFlatLength) { return CreateFlat(data, length, alloc_hint); } @@ -112,8 +110,8 @@ static absl::Nonnull NewBtree(absl::Nonnull data, // Create a new tree out of the specified array. // The returned node has a refcount of 1. -static absl::Nullable NewTree(absl::Nullable data, - size_t length, size_t alloc_hint) { +static CordRep* absl_nullable NewTree(const char* absl_nullable data, + size_t length, size_t alloc_hint) { if (length == 0) return nullptr; return NewBtree(data, length, alloc_hint); } @@ -121,7 +119,7 @@ static absl::Nullable NewTree(absl::Nullable data, namespace cord_internal { void InitializeCordRepExternal(absl::string_view data, - absl::Nonnull rep) { + CordRepExternal* absl_nonnull rep) { assert(!data.empty()); rep->length = data.size(); rep->tag = EXTERNAL; @@ -135,7 +133,7 @@ void InitializeCordRepExternal(absl::string_view data, // and not wasteful, we move the string into an external cord rep, preserving // the already allocated string contents. // Requires the provided string length to be larger than `kMaxInline`. -static absl::Nonnull CordRepFromString(std::string&& src) { +static CordRep* absl_nonnull CordRepFromString(std::string&& src) { assert(src.length() > cord_internal::kMaxInline); if ( // String is short: copy data to avoid external block overhead. @@ -163,13 +161,12 @@ static absl::Nonnull CordRepFromString(std::string&& src) { // -------------------------------------------------------------------- // Cord::InlineRep functions -inline void Cord::InlineRep::set_data(absl::Nonnull data, - size_t n) { +inline void Cord::InlineRep::set_data(const char* absl_nonnull data, size_t n) { static_assert(kMaxInline == 15, "set_data is hard-coded for a length of 15"); data_.set_inline_data(data, n); } -inline absl::Nonnull Cord::InlineRep::set_data(size_t n) { +inline char* absl_nonnull Cord::InlineRep::set_data(size_t n) { assert(n <= kMaxInline); ResetToEmpty(); set_inline_size(n); @@ -193,13 +190,13 @@ inline void Cord::InlineRep::remove_prefix(size_t n) { // Returns `rep` converted into a CordRepBtree. // Directly returns `rep` if `rep` is already a CordRepBtree. -static absl::Nonnull ForceBtree(CordRep* rep) { +static CordRepBtree* absl_nonnull ForceBtree(CordRep* rep) { return rep->IsBtree() ? rep->btree() : CordRepBtree::Create(cord_internal::RemoveCrcNode(rep)); } -void Cord::InlineRep::AppendTreeToInlined(absl::Nonnull tree, +void Cord::InlineRep::AppendTreeToInlined(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(!is_tree()); if (!data_.is_empty()) { @@ -209,7 +206,7 @@ void Cord::InlineRep::AppendTreeToInlined(absl::Nonnull tree, EmplaceTree(tree, method); } -void Cord::InlineRep::AppendTreeToTree(absl::Nonnull tree, +void Cord::InlineRep::AppendTreeToTree(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(is_tree()); const CordzUpdateScope scope(data_.cordz_info(), method); @@ -217,7 +214,7 @@ void Cord::InlineRep::AppendTreeToTree(absl::Nonnull tree, SetTree(tree, scope); } -void Cord::InlineRep::AppendTree(absl::Nonnull tree, +void Cord::InlineRep::AppendTree(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(tree != nullptr); assert(tree->length != 0); @@ -229,7 +226,7 @@ void Cord::InlineRep::AppendTree(absl::Nonnull tree, } } -void Cord::InlineRep::PrependTreeToInlined(absl::Nonnull tree, +void Cord::InlineRep::PrependTreeToInlined(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(!is_tree()); if (!data_.is_empty()) { @@ -239,7 +236,7 @@ void Cord::InlineRep::PrependTreeToInlined(absl::Nonnull tree, EmplaceTree(tree, method); } -void Cord::InlineRep::PrependTreeToTree(absl::Nonnull tree, +void Cord::InlineRep::PrependTreeToTree(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(is_tree()); const CordzUpdateScope scope(data_.cordz_info(), method); @@ -247,7 +244,7 @@ void Cord::InlineRep::PrependTreeToTree(absl::Nonnull tree, SetTree(tree, scope); } -void Cord::InlineRep::PrependTree(absl::Nonnull tree, +void Cord::InlineRep::PrependTree(CordRep* absl_nonnull tree, MethodIdentifier method) { assert(tree != nullptr); assert(tree->length != 0); @@ -263,9 +260,10 @@ void Cord::InlineRep::PrependTree(absl::Nonnull tree, // suitable leaf is found, the function will update the length field for all // nodes to account for the size increase. The append region address will be // written to region and the actual size increase will be written to size. -static inline bool PrepareAppendRegion( - absl::Nonnull root, absl::Nonnull*> region, - absl::Nonnull size, size_t max_length) { +static inline bool PrepareAppendRegion(CordRep* absl_nonnull root, + char* absl_nullable* absl_nonnull region, + size_t* absl_nonnull size, + size_t max_length) { if (root->IsBtree() && root->refcount.IsOne()) { Span span = root->btree()->GetAppendBuffer(max_length); if (!span.empty()) { @@ -468,11 +466,11 @@ void Cord::InlineRep::AppendArray(absl::string_view src, CommitTree(root, rep, scope, method); } -inline absl::Nonnull Cord::TakeRep() const& { +inline CordRep* absl_nonnull Cord::TakeRep() const& { return CordRep::Ref(contents_.tree()); } -inline absl::Nonnull Cord::TakeRep() && { +inline CordRep* absl_nonnull Cord::TakeRep() && { CordRep* rep = contents_.tree(); contents_.clear(); return rep; @@ -530,7 +528,7 @@ inline void Cord::AppendImpl(C&& src) { contents_.AppendTree(rep, CordzUpdateTracker::kAppendCord); } -static CordRep::ExtractResult ExtractAppendBuffer(absl::Nonnull rep, +static CordRep::ExtractResult ExtractAppendBuffer(CordRep* absl_nonnull rep, size_t min_capacity) { switch (rep->tag) { case cord_internal::BTREE: @@ -777,9 +775,9 @@ int ClampResult(int memcmp_res) { return static_cast(memcmp_res > 0) - static_cast(memcmp_res < 0); } -int CompareChunks(absl::Nonnull lhs, - absl::Nonnull rhs, - absl::Nonnull size_to_compare) { +int CompareChunks(absl::string_view* absl_nonnull lhs, + absl::string_view* absl_nonnull rhs, + size_t* absl_nonnull size_to_compare) { size_t compared_size = std::min(lhs->size(), rhs->size()); assert(*size_to_compare >= compared_size); *size_to_compare -= compared_size; @@ -877,7 +875,7 @@ void Cord::SetExpectedChecksum(uint32_t crc) { SetCrcCordState(std::move(state)); } -absl::Nullable Cord::MaybeGetCrcCordState() +const crc_internal::CrcCordState* absl_nullable Cord::MaybeGetCrcCordState() const { if (!contents_.is_tree() || !contents_.tree()->IsCrc()) { return nullptr; @@ -895,8 +893,8 @@ absl::optional Cord::ExpectedChecksum() const { inline int Cord::CompareSlowPath(absl::string_view rhs, size_t compared_size, size_t size_to_compare) const { - auto advance = [](absl::Nonnull it, - absl::Nonnull chunk) { + auto advance = [](Cord::ChunkIterator* absl_nonnull it, + absl::string_view* absl_nonnull chunk) { if (!chunk->empty()) return true; ++*it; if (it->bytes_remaining_ == 0) return false; @@ -926,8 +924,8 @@ inline int Cord::CompareSlowPath(absl::string_view rhs, size_t compared_size, inline int Cord::CompareSlowPath(const Cord& rhs, size_t compared_size, size_t size_to_compare) const { - auto advance = [](absl::Nonnull it, - absl::Nonnull chunk) { + auto advance = [](Cord::ChunkIterator* absl_nonnull it, + absl::string_view* absl_nonnull chunk) { if (!chunk->empty()) return true; ++*it; if (it->bytes_remaining_ == 0) return false; @@ -1051,7 +1049,7 @@ Cord::operator std::string() const { return s; } -void CopyCordToString(const Cord& src, absl::Nonnull dst) { +void CopyCordToString(const Cord& src, std::string* absl_nonnull dst) { if (!src.contents_.is_tree()) { src.contents_.CopyTo(dst); } else { @@ -1060,7 +1058,7 @@ void CopyCordToString(const Cord& src, absl::Nonnull dst) { } } -void AppendCordToString(const Cord& src, absl::Nonnull dst) { +void AppendCordToString(const Cord& src, std::string* absl_nonnull dst) { const size_t cur_dst_size = dst->size(); const size_t new_dst_size = cur_dst_size + src.size(); absl::strings_internal::STLStringResizeUninitializedAmortized(dst, @@ -1069,7 +1067,7 @@ void AppendCordToString(const Cord& src, absl::Nonnull dst) { src.CopyToArrayImpl(append_ptr); } -void Cord::CopyToArraySlowPath(absl::Nonnull dst) const { +void Cord::CopyToArraySlowPath(char* absl_nonnull dst) const { assert(contents_.is_tree()); absl::string_view fragment; if (GetFlatAux(contents_.tree(), &fragment) && !fragment.empty()) { @@ -1395,8 +1393,8 @@ absl::string_view Cord::FlattenSlowPath() { return absl::string_view(new_buffer, total_size); } -/* static */ bool Cord::GetFlatAux(absl::Nonnull rep, - absl::Nonnull fragment) { +/* static */ bool Cord::GetFlatAux(CordRep* absl_nonnull rep, + absl::string_view* absl_nonnull fragment) { assert(rep != nullptr); if (rep->length == 0) { *fragment = absl::string_view(); @@ -1430,7 +1428,7 @@ absl::string_view Cord::FlattenSlowPath() { } /* static */ void Cord::ForEachChunkAux( - absl::Nonnull rep, + absl::cord_internal::CordRep* absl_nonnull rep, absl::FunctionRef callback) { assert(rep != nullptr); if (rep->length == 0) return; @@ -1455,8 +1453,8 @@ absl::string_view Cord::FlattenSlowPath() { } } -static void DumpNode(absl::Nonnull nonnull_rep, bool include_data, - absl::Nonnull os, int indent) { +static void DumpNode(CordRep* absl_nonnull nonnull_rep, bool include_data, + std::ostream* absl_nonnull os, int indent) { CordRep* rep = nonnull_rep; const int kIndentStep = 1; for (;;) { @@ -1502,17 +1500,17 @@ static void DumpNode(absl::Nonnull nonnull_rep, bool include_data, } } -static std::string ReportError(absl::Nonnull root, - absl::Nonnull node) { +static std::string ReportError(CordRep* absl_nonnull root, + CordRep* absl_nonnull node) { std::ostringstream buf; buf << "Error at node " << node << " in:"; DumpNode(root, true, &buf); return buf.str(); } -static bool VerifyNode(absl::Nonnull root, - absl::Nonnull start_node) { - absl::InlinedVector, 2> worklist; +static bool VerifyNode(CordRep* absl_nonnull root, + CordRep* absl_nonnull start_node) { + absl::InlinedVector worklist; worklist.push_back(start_node); do { CordRep* node = worklist.back(); diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 1f8aafb5..961ff00f 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -102,8 +102,8 @@ class Cord; class CordTestPeer; template Cord MakeCordFromExternal(absl::string_view, Releaser&&); -void CopyCordToString(const Cord& src, absl::Nonnull dst); -void AppendCordToString(const Cord& src, absl::Nonnull dst); +void CopyCordToString(const Cord& src, std::string* absl_nonnull dst); +void AppendCordToString(const Cord& src, std::string* absl_nonnull dst); // Cord memory accounting modes enum class CordMemoryAccounting { @@ -417,8 +417,7 @@ class Cord { // guarantee that pointers previously returned by `dst->data()` remain valid // even if `*dst` had enough capacity to hold `src`. If `*dst` is a new // object, prefer to simply use the conversion operator to `std::string`. - friend void CopyCordToString(const Cord& src, - absl::Nonnull dst); + friend void CopyCordToString(const Cord& src, std::string* absl_nonnull dst); // AppendCordToString() // @@ -430,7 +429,7 @@ class Cord { // `dst->data()`. If `*dst` is a new object, prefer to simply use the // conversion operator to `std::string`. friend void AppendCordToString(const Cord& src, - absl::Nonnull dst); + std::string* absl_nonnull dst); class CharIterator; @@ -467,7 +466,7 @@ class Cord { using iterator_category = std::input_iterator_tag; using value_type = absl::string_view; using difference_type = ptrdiff_t; - using pointer = absl::Nonnull; + using pointer = const value_type* absl_nonnull; using reference = value_type; ChunkIterator() = default; @@ -488,13 +487,13 @@ class Cord { using CordRepBtreeReader = absl::cord_internal::CordRepBtreeReader; // Constructs a `begin()` iterator from `tree`. - explicit ChunkIterator(absl::Nonnull tree); + explicit ChunkIterator(cord_internal::CordRep* absl_nonnull tree); // Constructs a `begin()` iterator from `cord`. - explicit ChunkIterator(absl::Nonnull cord); + explicit ChunkIterator(const Cord* absl_nonnull cord); // Initializes this instance from a tree. Invoked by constructors. - void InitTree(absl::Nonnull tree); + void InitTree(cord_internal::CordRep* absl_nonnull tree); // Removes `n` bytes from `current_chunk_`. Expects `n` to be smaller than // `current_chunk_.size()`. @@ -512,7 +511,7 @@ class Cord { // The current leaf, or `nullptr` if the iterator points to short data. // If the current chunk is a substring node, current_leaf_ points to the // underlying flat or external node. - absl::Nullable current_leaf_ = nullptr; + absl::cord_internal::CordRep* absl_nullable current_leaf_ = nullptr; // The number of bytes left in the `Cord` over which we are iterating. size_t bytes_remaining_ = 0; @@ -569,13 +568,13 @@ class Cord { using iterator = ChunkIterator; using const_iterator = ChunkIterator; - explicit ChunkRange(absl::Nonnull cord) : cord_(cord) {} + explicit ChunkRange(const Cord* absl_nonnull cord) : cord_(cord) {} ChunkIterator begin() const; ChunkIterator end() const; private: - absl::Nonnull cord_; + const Cord* absl_nonnull cord_; }; // Cord::Chunks() @@ -628,7 +627,7 @@ class Cord { using iterator_category = std::input_iterator_tag; using value_type = char; using difference_type = ptrdiff_t; - using pointer = absl::Nonnull; + using pointer = const char* absl_nonnull; using reference = const char&; CharIterator() = default; @@ -642,7 +641,7 @@ class Cord { friend Cord; private: - explicit CharIterator(absl::Nonnull cord) + explicit CharIterator(const Cord* absl_nonnull cord) : chunk_iterator_(cord) {} ChunkIterator chunk_iterator_; @@ -654,14 +653,14 @@ class Cord { // advanced as a separate `Cord`. `n_bytes` must be less than or equal to the // number of bytes within the Cord; otherwise, behavior is undefined. It is // valid to pass `char_end()` and `0`. - static Cord AdvanceAndRead(absl::Nonnull it, size_t n_bytes); + static Cord AdvanceAndRead(CharIterator* absl_nonnull it, size_t n_bytes); // Cord::Advance() // // Advances the `Cord::CharIterator` by `n_bytes`. `n_bytes` must be less than // or equal to the number of bytes remaining within the Cord; otherwise, // behavior is undefined. It is valid to pass `char_end()` and `0`. - static void Advance(absl::Nonnull it, size_t n_bytes); + static void Advance(CharIterator* absl_nonnull it, size_t n_bytes); // Cord::ChunkRemaining() // @@ -710,13 +709,13 @@ class Cord { using iterator = CharIterator; using const_iterator = CharIterator; - explicit CharRange(absl::Nonnull cord) : cord_(cord) {} + explicit CharRange(const Cord* absl_nonnull cord) : cord_(cord) {} CharIterator begin() const; CharIterator end() const; private: - absl::Nonnull cord_; + const Cord* absl_nonnull cord_; }; // Cord::Chars() @@ -775,7 +774,7 @@ class Cord { CharIterator Find(const absl::Cord& needle) const; // Supports absl::Cord as a sink object for absl::Format(). - friend void AbslFormatFlush(absl::Nonnull cord, + friend void AbslFormatFlush(absl::Cord* absl_nonnull cord, absl::string_view part) { cord->Append(part); } @@ -878,7 +877,7 @@ class Cord { } #endif - friend absl::Nullable GetCordzInfoForTesting( + friend const CordzInfo* absl_nullable GetCordzInfoForTesting( const Cord& cord); // Calls the provided function once for each cord chunk, in order. Unlike @@ -907,21 +906,21 @@ class Cord { InlineRep& operator=(InlineRep&& src) noexcept; explicit constexpr InlineRep(absl::string_view sv, - absl::Nullable rep); + CordRep* absl_nullable rep); - void Swap(absl::Nonnull rhs); + void Swap(InlineRep* absl_nonnull rhs); size_t size() const; // Returns nullptr if holding pointer - absl::Nullable data() const; + const char* absl_nullable data() const; // Discards pointer, if any - void set_data(absl::Nonnull data, size_t n); - absl::Nonnull set_data(size_t n); // Write data to the result + void set_data(const char* absl_nonnull data, size_t n); + char* absl_nonnull set_data(size_t n); // Write data to the result // Returns nullptr if holding bytes - absl::Nullable tree() const; - absl::Nonnull as_tree() const; - absl::Nonnull as_chars() const; + absl::cord_internal::CordRep* absl_nullable tree() const; + absl::cord_internal::CordRep* absl_nonnull as_tree() const; + const char* absl_nonnull as_chars() const; // Returns non-null iff was holding a pointer - absl::Nullable clear(); + absl::cord_internal::CordRep* absl_nullable clear(); // Converts to pointer if necessary. void reduce_size(size_t n); // REQUIRES: holding data void remove_prefix(size_t n); // REQUIRES: holding data @@ -930,58 +929,56 @@ class Cord { // Creates a CordRepFlat instance from the current inlined data with `extra' // bytes of desired additional capacity. - absl::Nonnull MakeFlatWithExtraCapacity(size_t extra); + CordRepFlat* absl_nonnull MakeFlatWithExtraCapacity(size_t extra); // Sets the tree value for this instance. `rep` must not be null. // Requires the current instance to hold a tree, and a lock to be held on // any CordzInfo referenced by this instance. The latter is enforced through // the CordzUpdateScope argument. If the current instance is sampled, then // the CordzInfo instance is updated to reference the new `rep` value. - void SetTree(absl::Nonnull rep, const CordzUpdateScope& scope); + void SetTree(CordRep* absl_nonnull rep, const CordzUpdateScope& scope); // Identical to SetTree(), except that `rep` is allowed to be null, in // which case the current instance is reset to an empty value. - void SetTreeOrEmpty(absl::Nullable rep, + void SetTreeOrEmpty(CordRep* absl_nullable rep, const CordzUpdateScope& scope); // Sets the tree value for this instance, and randomly samples this cord. // This function disregards existing contents in `data_`, and should be // called when a Cord is 'promoted' from an 'uninitialized' or 'inlined' // value to a non-inlined (tree / ring) value. - void EmplaceTree(absl::Nonnull rep, MethodIdentifier method); + void EmplaceTree(CordRep* absl_nonnull rep, MethodIdentifier method); // Identical to EmplaceTree, except that it copies the parent stack from // the provided `parent` data if the parent is sampled. - void EmplaceTree(absl::Nonnull rep, const InlineData& parent, + void EmplaceTree(CordRep* absl_nonnull rep, const InlineData& parent, MethodIdentifier method); // Commits the change of a newly created, or updated `rep` root value into // this cord. `old_rep` indicates the old (inlined or tree) value of the // cord, and determines if the commit invokes SetTree() or EmplaceTree(). - void CommitTree(absl::Nullable old_rep, - absl::Nonnull rep, const CordzUpdateScope& scope, + void CommitTree(const CordRep* absl_nullable old_rep, + CordRep* absl_nonnull rep, const CordzUpdateScope& scope, MethodIdentifier method); - void AppendTreeToInlined(absl::Nonnull tree, + void AppendTreeToInlined(CordRep* absl_nonnull tree, MethodIdentifier method); - void AppendTreeToTree(absl::Nonnull tree, - MethodIdentifier method); - void AppendTree(absl::Nonnull tree, MethodIdentifier method); - void PrependTreeToInlined(absl::Nonnull tree, + void AppendTreeToTree(CordRep* absl_nonnull tree, MethodIdentifier method); + void AppendTree(CordRep* absl_nonnull tree, MethodIdentifier method); + void PrependTreeToInlined(CordRep* absl_nonnull tree, MethodIdentifier method); - void PrependTreeToTree(absl::Nonnull tree, - MethodIdentifier method); - void PrependTree(absl::Nonnull tree, MethodIdentifier method); + void PrependTreeToTree(CordRep* absl_nonnull tree, MethodIdentifier method); + void PrependTree(CordRep* absl_nonnull tree, MethodIdentifier method); bool IsSame(const InlineRep& other) const { return data_ == other.data_; } // Copies the inline contents into `dst`. Assumes the cord is not empty. - void CopyTo(absl::Nonnull dst) const { + void CopyTo(std::string* absl_nonnull dst) const { data_.CopyInlineToString(dst); } // Copies the inline contents into `dst`. Assumes the cord is not empty. - void CopyToArray(absl::Nonnull dst) const; + void CopyToArray(char* absl_nonnull dst) const; bool is_tree() const { return data_.is_tree(); } @@ -994,12 +991,12 @@ class Cord { } // Returns the profiled CordzInfo, or nullptr if not sampled. - absl::Nullable cordz_info() const { + absl::cord_internal::CordzInfo* absl_nullable cordz_info() const { return data_.cordz_info(); } // Sets the profiled CordzInfo. - void set_cordz_info(absl::Nonnull cordz_info) { + void set_cordz_info(cord_internal::CordzInfo* absl_nonnull cordz_info) { assert(cordz_info != nullptr); data_.set_cordz_info(cordz_info); } @@ -1031,19 +1028,19 @@ class Cord { InlineRep contents_; // Helper for GetFlat() and TryFlat(). - static bool GetFlatAux(absl::Nonnull rep, - absl::Nonnull fragment); + static bool GetFlatAux(absl::cord_internal::CordRep* absl_nonnull rep, + absl::string_view* absl_nonnull fragment); // Helper for ForEachChunk(). static void ForEachChunkAux( - absl::Nonnull rep, + absl::cord_internal::CordRep* absl_nonnull rep, absl::FunctionRef callback); // The destructor for non-empty Cords. void DestroyCordSlow(); // Out-of-line implementation of slower parts of logic. - void CopyToArraySlowPath(absl::Nonnull dst) const; + void CopyToArraySlowPath(char* absl_nonnull dst) const; int CompareSlowPath(absl::string_view rhs, size_t compared_size, size_t size_to_compare) const; int CompareSlowPath(const Cord& rhs, size_t compared_size, @@ -1060,8 +1057,8 @@ class Cord { // Returns a new reference to contents_.tree(), or steals an existing // reference if called on an rvalue. - absl::Nonnull TakeRep() const&; - absl::Nonnull TakeRep() &&; + absl::cord_internal::CordRep* absl_nonnull TakeRep() const&; + absl::cord_internal::CordRep* absl_nonnull TakeRep() &&; // Helper for Append(). template @@ -1098,12 +1095,11 @@ class Cord { friend class CrcCord; void SetCrcCordState(crc_internal::CrcCordState state); - absl::Nullable MaybeGetCrcCordState() - const; + const crc_internal::CrcCordState* absl_nullable MaybeGetCrcCordState() const; CharIterator FindImpl(CharIterator it, absl::string_view needle) const; - void CopyToArrayImpl(absl::Nonnull dst) const; + void CopyToArrayImpl(char* absl_nonnull dst) const; }; ABSL_NAMESPACE_END @@ -1123,14 +1119,14 @@ namespace cord_internal { // Does non-template-specific `CordRepExternal` initialization. // Requires `data` to be non-empty. void InitializeCordRepExternal(absl::string_view data, - absl::Nonnull rep); + CordRepExternal* absl_nonnull rep); // Creates a new `CordRep` that owns `data` and `releaser` and returns a pointer // to it. Requires `data` to be non-empty. template // NOLINTNEXTLINE - suppress clang-tidy raw pointer return. -absl::Nonnull NewExternalRep(absl::string_view data, - Releaser&& releaser) { +CordRep* absl_nonnull NewExternalRep(absl::string_view data, + Releaser&& releaser) { assert(!data.empty()); using ReleaserType = absl::decay_t; CordRepExternal* rep = new CordRepExternalImpl( @@ -1142,7 +1138,7 @@ absl::Nonnull NewExternalRep(absl::string_view data, // Overload for function reference types that dispatches using a function // pointer because there are no `alignof()` or `sizeof()` a function reference. // NOLINTNEXTLINE - suppress clang-tidy raw pointer return. -inline absl::Nonnull NewExternalRep( +inline CordRep* absl_nonnull NewExternalRep( absl::string_view data, void (&releaser)(absl::string_view)) { return NewExternalRep(data, &releaser); } @@ -1166,7 +1162,7 @@ Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser) { } constexpr Cord::InlineRep::InlineRep(absl::string_view sv, - absl::Nullable rep) + CordRep* absl_nullable rep) : data_(sv, rep) {} inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) @@ -1205,7 +1201,7 @@ inline Cord::InlineRep& Cord::InlineRep::operator=( return *this; } -inline void Cord::InlineRep::Swap(absl::Nonnull rhs) { +inline void Cord::InlineRep::Swap(Cord::InlineRep* absl_nonnull rhs) { if (rhs == this) { return; } @@ -1213,22 +1209,22 @@ inline void Cord::InlineRep::Swap(absl::Nonnull rhs) { swap(data_, rhs->data_); } -inline absl::Nullable Cord::InlineRep::data() const { +inline const char* absl_nullable Cord::InlineRep::data() const { return is_tree() ? nullptr : data_.as_chars(); } -inline absl::Nonnull Cord::InlineRep::as_chars() const { +inline const char* absl_nonnull Cord::InlineRep::as_chars() const { assert(!data_.is_tree()); return data_.as_chars(); } -inline absl::Nonnull Cord::InlineRep::as_tree() +inline absl::cord_internal::CordRep* absl_nonnull Cord::InlineRep::as_tree() const { assert(data_.is_tree()); return data_.as_tree(); } -inline absl::Nullable Cord::InlineRep::tree() +inline absl::cord_internal::CordRep* absl_nullable Cord::InlineRep::tree() const { if (is_tree()) { return as_tree(); @@ -1241,7 +1237,7 @@ inline size_t Cord::InlineRep::size() const { return is_tree() ? as_tree()->length : inline_size(); } -inline absl::Nonnull +inline cord_internal::CordRepFlat* absl_nonnull Cord::InlineRep::MakeFlatWithExtraCapacity(size_t extra) { static_assert(cord_internal::kMinFlatLength >= sizeof(data_), ""); size_t len = data_.inline_size(); @@ -1251,21 +1247,21 @@ Cord::InlineRep::MakeFlatWithExtraCapacity(size_t extra) { return result; } -inline void Cord::InlineRep::EmplaceTree(absl::Nonnull rep, +inline void Cord::InlineRep::EmplaceTree(CordRep* absl_nonnull rep, MethodIdentifier method) { assert(rep); data_.make_tree(rep); CordzInfo::MaybeTrackCord(data_, method); } -inline void Cord::InlineRep::EmplaceTree(absl::Nonnull rep, +inline void Cord::InlineRep::EmplaceTree(CordRep* absl_nonnull rep, const InlineData& parent, MethodIdentifier method) { data_.make_tree(rep); CordzInfo::MaybeTrackCord(data_, parent, method); } -inline void Cord::InlineRep::SetTree(absl::Nonnull rep, +inline void Cord::InlineRep::SetTree(CordRep* absl_nonnull rep, const CordzUpdateScope& scope) { assert(rep); assert(data_.is_tree()); @@ -1273,7 +1269,7 @@ inline void Cord::InlineRep::SetTree(absl::Nonnull rep, scope.SetCordRep(rep); } -inline void Cord::InlineRep::SetTreeOrEmpty(absl::Nullable rep, +inline void Cord::InlineRep::SetTreeOrEmpty(CordRep* absl_nullable rep, const CordzUpdateScope& scope) { assert(data_.is_tree()); if (rep) { @@ -1284,8 +1280,8 @@ inline void Cord::InlineRep::SetTreeOrEmpty(absl::Nullable rep, scope.SetCordRep(rep); } -inline void Cord::InlineRep::CommitTree(absl::Nullable old_rep, - absl::Nonnull rep, +inline void Cord::InlineRep::CommitTree(const CordRep* absl_nullable old_rep, + CordRep* absl_nonnull rep, const CordzUpdateScope& scope, MethodIdentifier method) { if (old_rep) { @@ -1295,7 +1291,7 @@ inline void Cord::InlineRep::CommitTree(absl::Nullable old_rep, } } -inline absl::Nullable Cord::InlineRep::clear() { +inline absl::cord_internal::CordRep* absl_nullable Cord::InlineRep::clear() { if (is_tree()) { CordzInfo::MaybeUntrackCord(cordz_info()); } @@ -1304,7 +1300,7 @@ inline absl::Nullable Cord::InlineRep::clear() { return result; } -inline void Cord::InlineRep::CopyToArray(absl::Nonnull dst) const { +inline void Cord::InlineRep::CopyToArray(char* absl_nonnull dst) const { assert(!is_tree()); size_t n = inline_size(); assert(n != 0); @@ -1488,7 +1484,7 @@ inline bool Cord::StartsWith(absl::string_view rhs) const { return EqualsImpl(rhs, rhs_size); } -inline void Cord::CopyToArrayImpl(absl::Nonnull dst) const { +inline void Cord::CopyToArrayImpl(char* absl_nonnull dst) const { if (!contents_.is_tree()) { if (!empty()) contents_.CopyToArray(dst); } else { @@ -1497,7 +1493,7 @@ inline void Cord::CopyToArrayImpl(absl::Nonnull dst) const { } inline void Cord::ChunkIterator::InitTree( - absl::Nonnull tree) { + cord_internal::CordRep* absl_nonnull tree) { tree = cord_internal::SkipCrcNode(tree); if (tree->tag == cord_internal::BTREE) { current_chunk_ = btree_reader_.Init(tree->btree()); @@ -1508,12 +1504,12 @@ inline void Cord::ChunkIterator::InitTree( } inline Cord::ChunkIterator::ChunkIterator( - absl::Nonnull tree) { + cord_internal::CordRep* absl_nonnull tree) { bytes_remaining_ = tree->length; InitTree(tree); } -inline Cord::ChunkIterator::ChunkIterator(absl::Nonnull cord) { +inline Cord::ChunkIterator::ChunkIterator(const Cord* absl_nonnull cord) { if (CordRep* tree = cord->contents_.tree()) { bytes_remaining_ = tree->length; if (ABSL_PREDICT_TRUE(bytes_remaining_ != 0)) { @@ -1649,13 +1645,13 @@ inline Cord::CharIterator::reference Cord::CharIterator::operator*() const { return *chunk_iterator_->data(); } -inline Cord Cord::AdvanceAndRead(absl::Nonnull it, +inline Cord Cord::AdvanceAndRead(CharIterator* absl_nonnull it, size_t n_bytes) { assert(it != nullptr); return it->chunk_iterator_.AdvanceAndReadBytes(n_bytes); } -inline void Cord::Advance(absl::Nonnull it, size_t n_bytes) { +inline void Cord::Advance(CharIterator* absl_nonnull it, size_t n_bytes) { assert(it != nullptr); it->chunk_iterator_.AdvanceBytes(n_bytes); } diff --git a/absl/strings/cord_analysis.cc b/absl/strings/cord_analysis.cc index 19b0fa44..dcbc826c 100644 --- a/absl/strings/cord_analysis.cc +++ b/absl/strings/cord_analysis.cc @@ -39,15 +39,15 @@ enum class Mode { kFairShare, kTotal, kTotalMorePrecise }; template struct CordRepRef { // Instantiates a CordRepRef instance. - explicit CordRepRef(absl::Nonnull r) : rep(r) {} + explicit CordRepRef(const CordRep* absl_nonnull r) : rep(r) {} // Creates a child reference holding the provided child. // Overloaded to add cumulative reference count for kFairShare. - CordRepRef Child(absl::Nonnull child) const { + CordRepRef Child(const CordRep* absl_nonnull child) const { return CordRepRef(child); } - absl::Nonnull rep; + const CordRep* absl_nonnull rep; }; // RawUsage holds the computed total number of bytes. @@ -66,7 +66,7 @@ template <> struct RawUsage { size_t total = 0; // TODO(b/289250880): Replace this with a flat_hash_set. - std::unordered_set> counted; + std::unordered_set counted; void Add(size_t size, CordRepRef repref) { if (counted.insert(repref.rep).second) { @@ -90,15 +90,15 @@ double MaybeDiv(double d, refcount_t refcount) { template <> struct CordRepRef { // Creates a CordRepRef with the provided rep and top (parent) fraction. - explicit CordRepRef(absl::Nonnull r, double frac = 1.0) + explicit CordRepRef(const CordRep* absl_nonnull r, double frac = 1.0) : rep(r), fraction(MaybeDiv(frac, r->refcount.Get())) {} // Returns a CordRepRef with a fraction of `this->fraction / child.refcount` - CordRepRef Child(absl::Nonnull child) const { + CordRepRef Child(const CordRep* absl_nonnull child) const { return CordRepRef(child, fraction); } - absl::Nonnull rep; + const CordRep* absl_nonnull rep; double fraction; }; @@ -150,7 +150,7 @@ void AnalyzeBtree(CordRepRef rep, RawUsage& raw_usage) { } template -size_t GetEstimatedUsage(absl::Nonnull rep) { +size_t GetEstimatedUsage(const CordRep* absl_nonnull rep) { // Zero initialized memory usage totals. RawUsage raw_usage; @@ -179,15 +179,15 @@ size_t GetEstimatedUsage(absl::Nonnull rep) { } // namespace -size_t GetEstimatedMemoryUsage(absl::Nonnull rep) { +size_t GetEstimatedMemoryUsage(const CordRep* absl_nonnull rep) { return GetEstimatedUsage(rep); } -size_t GetEstimatedFairShareMemoryUsage(absl::Nonnull rep) { +size_t GetEstimatedFairShareMemoryUsage(const CordRep* absl_nonnull rep) { return GetEstimatedUsage(rep); } -size_t GetMorePreciseMemoryUsage(absl::Nonnull rep) { +size_t GetMorePreciseMemoryUsage(const CordRep* absl_nonnull rep) { return GetEstimatedUsage(rep); } diff --git a/absl/strings/cord_analysis.h b/absl/strings/cord_analysis.h index f8ce3489..db50f3a1 100644 --- a/absl/strings/cord_analysis.h +++ b/absl/strings/cord_analysis.h @@ -29,7 +29,7 @@ namespace cord_internal { // Returns the *approximate* number of bytes held in full or in part by this // Cord (which may not remain the same between invocations). Cords that share // memory could each be "charged" independently for the same shared memory. -size_t GetEstimatedMemoryUsage(absl::Nonnull rep); +size_t GetEstimatedMemoryUsage(const CordRep* absl_nonnull rep); // Returns the *approximate* number of bytes held in full or in part by this // Cord for the distinct memory held by this cord. This is similar to @@ -47,13 +47,13 @@ size_t GetEstimatedMemoryUsage(absl::Nonnull rep); // // This is more expensive than `GetEstimatedMemoryUsage()` as it requires // deduplicating all memory references. -size_t GetMorePreciseMemoryUsage(absl::Nonnull rep); +size_t GetMorePreciseMemoryUsage(const CordRep* absl_nonnull rep); // Returns the *approximate* number of bytes held in full or in part by this // CordRep weighted by the sharing ratio of that data. For example, if some data // edge is shared by 4 different Cords, then each cord is attribute 1/4th of // the total memory usage as a 'fair share' of the total memory usage. -size_t GetEstimatedFairShareMemoryUsage(absl::Nonnull rep); +size_t GetEstimatedFairShareMemoryUsage(const CordRep* absl_nonnull rep); } // namespace cord_internal ABSL_NAMESPACE_END diff --git a/absl/strings/cordz_test_helpers.h b/absl/strings/cordz_test_helpers.h index 619f13c2..98117099 100644 --- a/absl/strings/cordz_test_helpers.h +++ b/absl/strings/cordz_test_helpers.h @@ -34,7 +34,7 @@ namespace absl { ABSL_NAMESPACE_BEGIN // Returns the CordzInfo for the cord, or nullptr if the cord is not sampled. -inline absl::Nullable GetCordzInfoForTesting( +inline const cord_internal::CordzInfo* absl_nullable GetCordzInfoForTesting( const Cord& cord) { if (!cord.contents_.is_tree()) return nullptr; return cord.contents_.cordz_info(); @@ -42,7 +42,7 @@ inline absl::Nullable GetCordzInfoForTesting( // Returns true if the provided cordz_info is in the list of sampled cords. inline bool CordzInfoIsListed( - absl::Nonnull cordz_info, + const cord_internal::CordzInfo* absl_nonnull cordz_info, cord_internal::CordzSampleToken token = {}) { for (const cord_internal::CordzInfo& info : token) { if (cordz_info == &info) return true; @@ -121,7 +121,7 @@ class CordzSamplingIntervalHelper { // Wrapper struct managing a small CordRep `rep` struct TestCordRep { - absl::Nonnull rep; + cord_internal::CordRepFlat* absl_nonnull rep; TestCordRep() { rep = cord_internal::CordRepFlat::New(100); diff --git a/absl/strings/escaping.cc b/absl/strings/escaping.cc index 1ff0576d..f1953b49 100644 --- a/absl/strings/escaping.cc +++ b/absl/strings/escaping.cc @@ -59,7 +59,7 @@ inline unsigned int hex_digit_to_int(char c) { } inline bool IsSurrogate(char32_t c, absl::string_view src, - absl::Nullable error) { + std::string* absl_nullable error) { if (c >= 0xD800 && c <= 0xDFFF) { if (error) { *error = absl::StrCat("invalid surrogate character (0xD800-DFFF): \\", @@ -85,8 +85,8 @@ inline bool IsSurrogate(char32_t c, absl::string_view src, // ---------------------------------------------------------------------- bool CUnescapeInternal(absl::string_view src, bool leave_nulls_escaped, - absl::Nonnull dst, - absl::Nullable error) { + std::string* absl_nonnull dst, + std::string* absl_nullable error) { strings_internal::STLStringResizeUninitialized(dst, src.size()); absl::string_view::size_type p = 0; // Current src position. @@ -432,7 +432,7 @@ inline size_t CEscapedLength(absl::string_view src) { } void CEscapeAndAppendInternal(absl::string_view src, - absl::Nonnull dest) { + std::string* absl_nonnull dest) { size_t escaped_len = CEscapedLength(src); if (escaped_len == src.size()) { dest->append(src.data(), src.size()); @@ -461,10 +461,10 @@ void CEscapeAndAppendInternal(absl::string_view src, // Reverses the mapping in Base64EscapeInternal; see that method's // documentation for details of the mapping. -bool Base64UnescapeInternal(absl::Nullable src_param, size_t szsrc, - absl::Nullable dest, size_t szdest, +bool Base64UnescapeInternal(const char* absl_nullable src_param, size_t szsrc, + char* absl_nullable dest, size_t szdest, const std::array& unbase64, - absl::Nonnull len) { + size_t* absl_nonnull len) { static const char kPad64Equals = '='; static const char kPad64Dot = '.'; @@ -800,8 +800,8 @@ constexpr std::array kUnWebSafeBase64 = { /* clang-format on */ template -bool Base64UnescapeInternal(absl::Nullable src, size_t slen, - absl::Nonnull dest, +bool Base64UnescapeInternal(const char* absl_nullable src, size_t slen, + String* absl_nonnull dest, const std::array& unbase64) { // Determine the size of the output string. Base64 encodes every 3 bytes into // 4 characters. Any leftover chars are added directly for good measure. @@ -870,7 +870,7 @@ constexpr std::array kHexValueStrict = { // or a string. This works because we use the [] operator to access // individual characters at a time. template -void HexStringToBytesInternal(absl::Nullable from, T to, +void HexStringToBytesInternal(const char* absl_nullable from, T to, size_t num) { for (size_t i = 0; i < num; i++) { to[i] = static_cast(kHexValueLenient[from[i * 2] & 0xFF] << 4) + @@ -897,8 +897,8 @@ void BytesToHexStringInternal(absl::Nullable src, T dest, // // See CUnescapeInternal() for implementation details. // ---------------------------------------------------------------------- -bool CUnescape(absl::string_view source, absl::Nonnull dest, - absl::Nullable error) { +bool CUnescape(absl::string_view source, std::string* absl_nonnull dest, + std::string* absl_nullable error) { return CUnescapeInternal(source, kUnescapeNulls, dest, error); } @@ -920,23 +920,23 @@ std::string Utf8SafeCHexEscape(absl::string_view src) { return CEscapeInternal(src, true, true); } -bool Base64Unescape(absl::string_view src, absl::Nonnull dest) { +bool Base64Unescape(absl::string_view src, std::string* absl_nonnull dest) { return Base64UnescapeInternal(src.data(), src.size(), dest, kUnBase64); } bool WebSafeBase64Unescape(absl::string_view src, - absl::Nonnull dest) { + std::string* absl_nonnull dest) { return Base64UnescapeInternal(src.data(), src.size(), dest, kUnWebSafeBase64); } -void Base64Escape(absl::string_view src, absl::Nonnull dest) { +void Base64Escape(absl::string_view src, std::string* absl_nonnull dest) { strings_internal::Base64EscapeInternal( reinterpret_cast(src.data()), src.size(), dest, true, strings_internal::kBase64Chars); } void WebSafeBase64Escape(absl::string_view src, - absl::Nonnull dest) { + std::string* absl_nonnull dest) { strings_internal::Base64EscapeInternal( reinterpret_cast(src.data()), src.size(), dest, false, strings_internal::kWebSafeBase64Chars); @@ -958,8 +958,7 @@ std::string WebSafeBase64Escape(absl::string_view src) { return dest; } -bool HexStringToBytes(absl::string_view hex, - absl::Nonnull bytes) { +bool HexStringToBytes(absl::string_view hex, std::string* absl_nonnull bytes) { std::string output; size_t num_bytes = hex.size() / 2; diff --git a/absl/strings/escaping.h b/absl/strings/escaping.h index 08271d29..3aaf39ca 100644 --- a/absl/strings/escaping.h +++ b/absl/strings/escaping.h @@ -71,12 +71,12 @@ ABSL_NAMESPACE_BEGIN // ... // } // EXPECT_EQ(unescaped_s, "foo\rbar\nbaz\t"); -bool CUnescape(absl::string_view source, absl::Nonnull dest, - absl::Nullable error); +bool CUnescape(absl::string_view source, std::string* absl_nonnull dest, + std::string* absl_nullable error); // Overload of `CUnescape()` with no error reporting. inline bool CUnescape(absl::string_view source, - absl::Nonnull dest) { + std::string* absl_nonnull dest) { return CUnescape(source, dest, nullptr); } @@ -126,7 +126,7 @@ std::string Utf8SafeCHexEscape(absl::string_view src); // Encodes a `src` string into a base64-encoded 'dest' string with padding // characters. This function conforms with RFC 4648 section 4 (base64) and RFC // 2045. -void Base64Escape(absl::string_view src, absl::Nonnull dest); +void Base64Escape(absl::string_view src, std::string* absl_nonnull dest); std::string Base64Escape(absl::string_view src); // WebSafeBase64Escape() @@ -134,8 +134,7 @@ std::string Base64Escape(absl::string_view src); // Encodes a `src` string into a base64 string, like Base64Escape() does, but // outputs '-' instead of '+' and '_' instead of '/', and does not pad 'dest'. // This function conforms with RFC 4648 section 5 (base64url). -void WebSafeBase64Escape(absl::string_view src, - absl::Nonnull dest); +void WebSafeBase64Escape(absl::string_view src, std::string* absl_nonnull dest); std::string WebSafeBase64Escape(absl::string_view src); // Base64Unescape() @@ -145,7 +144,7 @@ std::string WebSafeBase64Escape(absl::string_view src); // `src` contains invalid characters, `dest` is cleared and returns `false`. // If padding is included (note that `Base64Escape()` does produce it), it must // be correct. In the padding, '=' and '.' are treated identically. -bool Base64Unescape(absl::string_view src, absl::Nonnull dest); +bool Base64Unescape(absl::string_view src, std::string* absl_nonnull dest); // WebSafeBase64Unescape() // @@ -155,7 +154,7 @@ bool Base64Unescape(absl::string_view src, absl::Nonnull dest); // included (note that `WebSafeBase64Escape()` does not produce it), it must be // correct. In the padding, '=' and '.' are treated identically. bool WebSafeBase64Unescape(absl::string_view src, - absl::Nonnull dest); + std::string* absl_nonnull dest); // HexStringToBytes() // @@ -164,7 +163,7 @@ bool WebSafeBase64Unescape(absl::string_view src, // function returns false and leaves `bytes` in an unspecified state. Returns // true on success. [[nodiscard]] bool HexStringToBytes(absl::string_view hex, - absl::Nonnull bytes); + std::string* absl_nonnull bytes); // HexStringToBytes() // diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index f2c0253d..b55b412c 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h @@ -635,7 +635,7 @@ class InlineData { poison(); } - void CopyInlineToString(absl::Nonnull dst) const { + void CopyInlineToString(std::string* absl_nonnull dst) const { assert(!is_tree()); // As Cord can store only 15 bytes it is smaller than std::string's // small string optimization buffer size. Therefore we will always trigger diff --git a/absl/strings/numbers.cc b/absl/strings/numbers.cc index c7adaef5..a83fd2ca 100644 --- a/absl/strings/numbers.cc +++ b/absl/strings/numbers.cc @@ -47,7 +47,7 @@ namespace absl { ABSL_NAMESPACE_BEGIN -bool SimpleAtof(absl::string_view str, absl::Nonnull out) { +bool SimpleAtof(absl::string_view str, float* absl_nonnull out) { *out = 0.0; str = StripAsciiWhitespace(str); // std::from_chars doesn't accept an initial +, but SimpleAtof does, so if one @@ -78,7 +78,7 @@ bool SimpleAtof(absl::string_view str, absl::Nonnull out) { return true; } -bool SimpleAtod(absl::string_view str, absl::Nonnull out) { +bool SimpleAtod(absl::string_view str, double* absl_nonnull out) { *out = 0.0; str = StripAsciiWhitespace(str); // std::from_chars doesn't accept an initial +, but SimpleAtod does, so if one @@ -109,7 +109,7 @@ bool SimpleAtod(absl::string_view str, absl::Nonnull out) { return true; } -bool SimpleAtob(absl::string_view str, absl::Nonnull out) { +bool SimpleAtob(absl::string_view str, bool* absl_nonnull out) { ABSL_RAW_CHECK(out != nullptr, "Output pointer must not be nullptr."); if (EqualsIgnoreCase(str, "true") || EqualsIgnoreCase(str, "t") || EqualsIgnoreCase(str, "yes") || EqualsIgnoreCase(str, "y") || @@ -168,7 +168,7 @@ constexpr uint64_t kDivisionBy100Mul = 10486u; constexpr uint64_t kDivisionBy100Div = 1 << 20; // Encode functions write the ASCII output of input `n` to `out_str`. -inline char* EncodeHundred(uint32_t n, absl::Nonnull out_str) { +inline char* EncodeHundred(uint32_t n, char* absl_nonnull out_str) { int num_digits = static_cast(n - 10) >> 8; uint32_t div10 = (n * kDivisionBy10Mul) / kDivisionBy10Div; uint32_t mod10 = n - 10u * div10; @@ -178,7 +178,7 @@ inline char* EncodeHundred(uint32_t n, absl::Nonnull out_str) { return out_str + 2 + num_digits; } -inline char* EncodeTenThousand(uint32_t n, absl::Nonnull out_str) { +inline char* EncodeTenThousand(uint32_t n, char* absl_nonnull out_str) { // We split lower 2 digits and upper 2 digits of n into 2 byte consecutive // blocks. 123 -> [\0\1][\0\23]. We divide by 10 both blocks // (it's 1 division + zeroing upper bits), and compute modulo 10 as well "in @@ -234,8 +234,8 @@ inline uint64_t PrepareEightDigits(uint32_t i) { return tens; } -inline ABSL_ATTRIBUTE_ALWAYS_INLINE absl::Nonnull EncodeFullU32( - uint32_t n, absl::Nonnull out_str) { +inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* absl_nonnull EncodeFullU32( + uint32_t n, char* absl_nonnull out_str) { if (n < 10) { *out_str = static_cast('0' + n); return out_str + 1; @@ -284,7 +284,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE char* EncodeFullU64(uint64_t i, } // namespace -void numbers_internal::PutTwoDigits(uint32_t i, absl::Nonnull buf) { +void numbers_internal::PutTwoDigits(uint32_t i, char* absl_nonnull buf) { assert(i < 100); uint32_t base = kTwoZeroBytes; uint32_t div10 = (i * kDivisionBy10Mul) / kDivisionBy10Div; @@ -293,15 +293,15 @@ void numbers_internal::PutTwoDigits(uint32_t i, absl::Nonnull buf) { little_endian::Store16(buf, static_cast(base)); } -absl::Nonnull numbers_internal::FastIntToBuffer( - uint32_t n, absl::Nonnull out_str) { +char* absl_nonnull numbers_internal::FastIntToBuffer( + uint32_t n, char* absl_nonnull out_str) { out_str = EncodeFullU32(n, out_str); *out_str = '\0'; return out_str; } -absl::Nonnull numbers_internal::FastIntToBuffer( - int32_t i, absl::Nonnull buffer) { +char* absl_nonnull numbers_internal::FastIntToBuffer( + int32_t i, char* absl_nonnull buffer) { uint32_t u = static_cast(i); if (i < 0) { *buffer++ = '-'; @@ -315,15 +315,15 @@ absl::Nonnull numbers_internal::FastIntToBuffer( return buffer; } -absl::Nonnull numbers_internal::FastIntToBuffer( - uint64_t i, absl::Nonnull buffer) { +char* absl_nonnull numbers_internal::FastIntToBuffer( + uint64_t i, char* absl_nonnull buffer) { buffer = EncodeFullU64(i, buffer); *buffer = '\0'; return buffer; } -absl::Nonnull numbers_internal::FastIntToBuffer( - int64_t i, absl::Nonnull buffer) { +char* absl_nonnull numbers_internal::FastIntToBuffer( + int64_t i, char* absl_nonnull buffer) { uint64_t u = static_cast(i); if (i < 0) { *buffer++ = '-'; @@ -546,7 +546,7 @@ static ExpDigits SplitToSix(const double value) { // Helper function for fast formatting of floating-point. // The result is the same as "%g", a.k.a. "%.6g". size_t numbers_internal::SixDigitsToBuffer(double d, - absl::Nonnull const buffer) { + char* absl_nonnull const buffer) { static_assert(std::numeric_limits::is_iec559, "IEEE-754/IEC-559 support only"); @@ -694,9 +694,9 @@ static constexpr std::array kAsciiToInt = { // Parse the sign and optional hex or oct prefix in text. inline bool safe_parse_sign_and_base( - absl::Nonnull text /*inout*/, - absl::Nonnull base_ptr /*inout*/, - absl::Nonnull negative_ptr /*output*/) { + absl::string_view* absl_nonnull text /*inout*/, + int* absl_nonnull base_ptr /*inout*/, + bool* absl_nonnull negative_ptr /*output*/) { if (text->data() == nullptr) { return false; } @@ -981,7 +981,7 @@ ABSL_CONST_INIT const IntType LookupTables::kVminOverBase[] = template inline bool safe_parse_positive_int(absl::string_view text, int base, - absl::Nonnull value_p) { + IntType* absl_nonnull value_p) { IntType value = 0; const IntType vmax = std::numeric_limits::max(); assert(vmax > 0); @@ -1018,7 +1018,7 @@ inline bool safe_parse_positive_int(absl::string_view text, int base, template inline bool safe_parse_negative_int(absl::string_view text, int base, - absl::Nonnull value_p) { + IntType* absl_nonnull value_p) { IntType value = 0; const IntType vmin = std::numeric_limits::min(); assert(vmin < 0); @@ -1063,7 +1063,7 @@ inline bool safe_parse_negative_int(absl::string_view text, int base, // http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtol.html template inline bool safe_int_internal(absl::string_view text, - absl::Nonnull value_p, int base) { + IntType* absl_nonnull value_p, int base) { *value_p = 0; bool negative; if (!safe_parse_sign_and_base(&text, &base, &negative)) { @@ -1078,7 +1078,7 @@ inline bool safe_int_internal(absl::string_view text, template inline bool safe_uint_internal(absl::string_view text, - absl::Nonnull value_p, int base) { + IntType* absl_nonnull value_p, int base) { *value_p = 0; bool negative; if (!safe_parse_sign_and_base(&text, &base, &negative) || negative) { @@ -1112,52 +1112,52 @@ ABSL_CONST_INIT ABSL_DLL const char kHexTable[513] = "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"; -bool safe_strto8_base(absl::string_view text, absl::Nonnull value, +bool safe_strto8_base(absl::string_view text, int8_t* absl_nonnull value, int base) { return safe_int_internal(text, value, base); } -bool safe_strto16_base(absl::string_view text, absl::Nonnull value, +bool safe_strto16_base(absl::string_view text, int16_t* absl_nonnull value, int base) { return safe_int_internal(text, value, base); } -bool safe_strto32_base(absl::string_view text, absl::Nonnull value, +bool safe_strto32_base(absl::string_view text, int32_t* absl_nonnull value, int base) { return safe_int_internal(text, value, base); } -bool safe_strto64_base(absl::string_view text, absl::Nonnull value, +bool safe_strto64_base(absl::string_view text, int64_t* absl_nonnull value, int base) { return safe_int_internal(text, value, base); } -bool safe_strto128_base(absl::string_view text, absl::Nonnull value, +bool safe_strto128_base(absl::string_view text, int128* absl_nonnull value, int base) { return safe_int_internal(text, value, base); } -bool safe_strtou8_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou8_base(absl::string_view text, uint8_t* absl_nonnull value, int base) { return safe_uint_internal(text, value, base); } -bool safe_strtou16_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou16_base(absl::string_view text, uint16_t* absl_nonnull value, int base) { return safe_uint_internal(text, value, base); } -bool safe_strtou32_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou32_base(absl::string_view text, uint32_t* absl_nonnull value, int base) { return safe_uint_internal(text, value, base); } -bool safe_strtou64_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou64_base(absl::string_view text, uint64_t* absl_nonnull value, int base) { return safe_uint_internal(text, value, base); } -bool safe_strtou128_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou128_base(absl::string_view text, uint128* absl_nonnull value, int base) { return safe_uint_internal(text, value, base); } diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index 5f4b661f..9c679746 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h @@ -63,7 +63,7 @@ ABSL_NAMESPACE_BEGIN // state. template [[nodiscard]] bool SimpleAtoi(absl::string_view str, - absl::Nonnull out); + int_type* absl_nonnull out); // SimpleAtof() // @@ -74,7 +74,7 @@ template // allowed formats for `str`, except SimpleAtof() is locale-independent and will // always use the "C" locale. If any errors are encountered, this function // returns `false`, leaving `out` in an unspecified state. -[[nodiscard]] bool SimpleAtof(absl::string_view str, absl::Nonnull out); +[[nodiscard]] bool SimpleAtof(absl::string_view str, float* absl_nonnull out); // SimpleAtod() // @@ -85,8 +85,7 @@ template // allowed formats for `str`, except SimpleAtod is locale-independent and will // always use the "C" locale. If any errors are encountered, this function // returns `false`, leaving `out` in an unspecified state. -[[nodiscard]] bool SimpleAtod(absl::string_view str, - absl::Nonnull out); +[[nodiscard]] bool SimpleAtod(absl::string_view str, double* absl_nonnull out); // SimpleAtob() // @@ -96,7 +95,7 @@ template // are interpreted as boolean `false`: "false", "f", "no", "n", "0". If any // errors are encountered, this function returns `false`, leaving `out` in an // unspecified state. -[[nodiscard]] bool SimpleAtob(absl::string_view str, absl::Nonnull out); +[[nodiscard]] bool SimpleAtob(absl::string_view str, bool* absl_nonnull out); // SimpleHexAtoi() // @@ -110,13 +109,13 @@ template // `false`, leaving `out` in an unspecified state. template [[nodiscard]] bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out); + int_type* absl_nonnull out); // Overloads of SimpleHexAtoi() for 128 bit integers. [[nodiscard]] inline bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out); + absl::int128* absl_nonnull out); [[nodiscard]] inline bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out); + absl::uint128* absl_nonnull out); ABSL_NAMESPACE_END } // namespace absl @@ -150,30 +149,30 @@ ABSL_DLL extern const char // PutTwoDigits(42, buf); // // buf[0] == '4' // // buf[1] == '2' -void PutTwoDigits(uint32_t i, absl::Nonnull buf); +void PutTwoDigits(uint32_t i, char* absl_nonnull buf); // safe_strto?() functions for implementing SimpleAtoi() -bool safe_strto8_base(absl::string_view text, absl::Nonnull value, +bool safe_strto8_base(absl::string_view text, int8_t* absl_nonnull value, int base); -bool safe_strto16_base(absl::string_view text, absl::Nonnull value, +bool safe_strto16_base(absl::string_view text, int16_t* absl_nonnull value, int base); -bool safe_strto32_base(absl::string_view text, absl::Nonnull value, +bool safe_strto32_base(absl::string_view text, int32_t* absl_nonnull value, int base); -bool safe_strto64_base(absl::string_view text, absl::Nonnull value, +bool safe_strto64_base(absl::string_view text, int64_t* absl_nonnull value, int base); bool safe_strto128_base(absl::string_view text, - absl::Nonnull value, int base); -bool safe_strtou8_base(absl::string_view text, absl::Nonnull value, + absl::int128* absl_nonnull value, int base); +bool safe_strtou8_base(absl::string_view text, uint8_t* absl_nonnull value, int base); -bool safe_strtou16_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou16_base(absl::string_view text, uint16_t* absl_nonnull value, int base); -bool safe_strtou32_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou32_base(absl::string_view text, uint32_t* absl_nonnull value, int base); -bool safe_strtou64_base(absl::string_view text, absl::Nonnull value, +bool safe_strtou64_base(absl::string_view text, uint64_t* absl_nonnull value, int base); bool safe_strtou128_base(absl::string_view text, - absl::Nonnull value, int base); + absl::uint128* absl_nonnull value, int base); static const int kFastToBufferSize = 32; static const int kSixDigitsToBufferSize = 16; @@ -184,25 +183,25 @@ static const int kSixDigitsToBufferSize = 16; // outside the range 0.0001-999999 are output using scientific notation // (1.23456e+06). This routine is heavily optimized. // Required buffer size is `kSixDigitsToBufferSize`. -size_t SixDigitsToBuffer(double d, absl::Nonnull buffer); +size_t SixDigitsToBuffer(double d, char* absl_nonnull buffer); // WARNING: These functions may write more characters than necessary, because // they are intended for speed. All functions take an output buffer // as an argument and return a pointer to the last byte they wrote, which is the // terminating '\0'. At most `kFastToBufferSize` bytes are written. -absl::Nonnull FastIntToBuffer(int32_t i, absl::Nonnull buffer) +char* absl_nonnull FastIntToBuffer(int32_t i, char* absl_nonnull buffer) ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize); -absl::Nonnull FastIntToBuffer(uint32_t n, absl::Nonnull out_str) +char* absl_nonnull FastIntToBuffer(uint32_t n, char* absl_nonnull out_str) ABSL_INTERNAL_NEED_MIN_SIZE(out_str, kFastToBufferSize); -absl::Nonnull FastIntToBuffer(int64_t i, absl::Nonnull buffer) +char* absl_nonnull FastIntToBuffer(int64_t i, char* absl_nonnull buffer) ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize); -absl::Nonnull FastIntToBuffer(uint64_t i, absl::Nonnull buffer) +char* absl_nonnull FastIntToBuffer(uint64_t i, char* absl_nonnull buffer) ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize); // For enums and integer types that are not an exact match for the types above, // use templates to call the appropriate one of the four overloads above. template -absl::Nonnull FastIntToBuffer(int_type i, absl::Nonnull buffer) +char* absl_nonnull FastIntToBuffer(int_type i, char* absl_nonnull buffer) ABSL_INTERNAL_NEED_MIN_SIZE(buffer, kFastToBufferSize) { static_assert(sizeof(i) <= 64 / 8, "FastIntToBuffer works only with 64-bit-or-less integers."); @@ -228,7 +227,7 @@ absl::Nonnull FastIntToBuffer(int_type i, absl::Nonnull buffer) // with base different from 10 elsewhere in Abseil implementation). template [[nodiscard]] bool safe_strtoi_base(absl::string_view s, - absl::Nonnull out, int base) { + int_type* absl_nonnull out, int base) { static_assert(sizeof(*out) == 1 || sizeof(*out) == 2 || sizeof(*out) == 4 || sizeof(*out) == 8, "SimpleAtoi works only with 8, 16, 32, or 64-bit integers."); @@ -284,7 +283,7 @@ template // without the terminating null character. Thus `out` must be of length >= 16. // Returns the number of non-pad digits of the output (it can never be zero // since 0 has one digit). -inline size_t FastHexToBufferZeroPad16(uint64_t val, absl::Nonnull out) { +inline size_t FastHexToBufferZeroPad16(uint64_t val, char* absl_nonnull out) { #ifdef ABSL_INTERNAL_HAVE_SSSE3 uint64_t be = absl::big_endian::FromHost64(val); const auto kNibbleMask = _mm_set1_epi8(0xf); @@ -311,33 +310,33 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, absl::Nonnull out) { template [[nodiscard]] bool SimpleAtoi(absl::string_view str, - absl::Nonnull out) { + int_type* absl_nonnull out) { return numbers_internal::safe_strtoi_base(str, out, 10); } [[nodiscard]] inline bool SimpleAtoi(absl::string_view str, - absl::Nonnull out) { + absl::int128* absl_nonnull out) { return numbers_internal::safe_strto128_base(str, out, 10); } [[nodiscard]] inline bool SimpleAtoi(absl::string_view str, - absl::Nonnull out) { + absl::uint128* absl_nonnull out) { return numbers_internal::safe_strtou128_base(str, out, 10); } template [[nodiscard]] bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out) { + int_type* absl_nonnull out) { return numbers_internal::safe_strtoi_base(str, out, 16); } [[nodiscard]] inline bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out) { + absl::int128* absl_nonnull out) { return numbers_internal::safe_strto128_base(str, out, 16); } [[nodiscard]] inline bool SimpleHexAtoi(absl::string_view str, - absl::Nonnull out) { + absl::uint128* absl_nonnull out) { return numbers_internal::safe_strtou128_base(str, out, 16); } diff --git a/absl/strings/str_cat.cc b/absl/strings/str_cat.cc index c51c1373..1f3cfbff 100644 --- a/absl/strings/str_cat.cc +++ b/absl/strings/str_cat.cc @@ -42,8 +42,7 @@ ABSL_NAMESPACE_BEGIN namespace { // Append is merely a version of memcpy that returns the address of the byte // after the area just overwritten. -inline absl::Nonnull Append(absl::Nonnull out, - const AlphaNum& x) { +inline char* absl_nonnull Append(char* absl_nonnull out, const AlphaNum& x) { // memcpy is allowed to overwrite arbitrary memory, so doing this after the // call would force an extra fetch of x.size(). char* after = out + x.size(); @@ -159,7 +158,7 @@ std::string CatPieces(std::initializer_list pieces) { assert(((src).size() == 0) || \ (uintptr_t((src).data() - (dest).data()) > uintptr_t((dest).size()))) -void AppendPieces(absl::Nonnull dest, +void AppendPieces(std::string* absl_nonnull dest, std::initializer_list pieces) { size_t old_size = dest->size(); size_t to_append = 0; @@ -183,7 +182,7 @@ void AppendPieces(absl::Nonnull dest, } // namespace strings_internal -void StrAppend(absl::Nonnull dest, const AlphaNum& a) { +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a) { ASSERT_NO_OVERLAP(*dest, a); std::string::size_type old_size = dest->size(); STLStringAppendUninitializedAmortized(dest, a.size()); @@ -193,7 +192,7 @@ void StrAppend(absl::Nonnull dest, const AlphaNum& a) { assert(out == begin + dest->size()); } -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b) { ASSERT_NO_OVERLAP(*dest, a); ASSERT_NO_OVERLAP(*dest, b); @@ -206,7 +205,7 @@ void StrAppend(absl::Nonnull dest, const AlphaNum& a, assert(out == begin + dest->size()); } -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b, const AlphaNum& c) { ASSERT_NO_OVERLAP(*dest, a); ASSERT_NO_OVERLAP(*dest, b); @@ -221,7 +220,7 @@ void StrAppend(absl::Nonnull dest, const AlphaNum& a, assert(out == begin + dest->size()); } -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, const AlphaNum& d) { ASSERT_NO_OVERLAP(*dest, a); ASSERT_NO_OVERLAP(*dest, b); diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index 6a07797b..eafd8a3f 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h @@ -213,7 +213,7 @@ struct Hex { !std::is_pointer::value>::type* = nullptr) : Hex(spec, static_cast(v)) {} template - explicit Hex(absl::Nullable v, PadSpec spec = absl::kNoPad) + explicit Hex(Pointee* absl_nullable v, PadSpec spec = absl::kNoPad) : Hex(spec, reinterpret_cast(v)) {} template @@ -359,7 +359,7 @@ class AlphaNum { ABSL_ATTRIBUTE_LIFETIME_BOUND) : piece_(&buf.data[0], buf.size) {} - AlphaNum(absl::Nullable c_str // NOLINT(runtime/explicit) + AlphaNum(const char* absl_nullable c_str // NOLINT(runtime/explicit) ABSL_ATTRIBUTE_LIFETIME_BOUND) : piece_(NullSafeStringView(c_str)) {} AlphaNum(absl::string_view pc // NOLINT(runtime/explicit) @@ -392,7 +392,7 @@ class AlphaNum { AlphaNum& operator=(const AlphaNum&) = delete; absl::string_view::size_type size() const { return piece_.size(); } - absl::Nullable data() const { return piece_.data(); } + const char* absl_nullable data() const { return piece_.data(); } absl::string_view Piece() const { return piece_; } // Match unscoped enums. Use integral promotion so that a `char`-backed @@ -462,7 +462,7 @@ namespace strings_internal { // Do not call directly - this is not part of the public API. std::string CatPieces(std::initializer_list pieces); -void AppendPieces(absl::Nonnull dest, +void AppendPieces(std::string* absl_nonnull dest, std::initializer_list pieces); template @@ -592,18 +592,18 @@ template // absl::string_view p = s; // StrAppend(&s, p); -inline void StrAppend(absl::Nonnull) {} -void StrAppend(absl::Nonnull dest, const AlphaNum& a); -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +inline void StrAppend(std::string* absl_nonnull) {} +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a); +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b); -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b, const AlphaNum& c); -void StrAppend(absl::Nonnull dest, const AlphaNum& a, +void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, const AlphaNum& d); // Support 5 or more arguments template -inline void StrAppend(absl::Nonnull dest, const AlphaNum& a, +inline void StrAppend(std::string* absl_nonnull dest, const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, const AV&... args) { strings_internal::AppendPieces( diff --git a/absl/strings/str_format.h b/absl/strings/str_format.h index fc3d3e92..1d863055 100644 --- a/absl/strings/str_format.h +++ b/absl/strings/str_format.h @@ -112,7 +112,7 @@ class UntypedFormatSpec { protected: explicit UntypedFormatSpec( - absl::Nonnull pc) + const str_format_internal::ParsedFormatBase* absl_nonnull pc) : spec_(pc) {} private: @@ -152,7 +152,7 @@ str_format_internal::StreamedWrapper FormatStreamed(const T& v) { // EXPECT_EQ(8, n); class FormatCountCapture { public: - explicit FormatCountCapture(absl::Nonnull p) : p_(p) {} + explicit FormatCountCapture(int* absl_nonnull p) : p_(p) {} private: // FormatCountCaptureHelper is used to define FormatConvertImpl() for this @@ -161,8 +161,8 @@ class FormatCountCapture { // Unused() is here because of the false positive from -Wunused-private-field // p_ is used in the templated function of the friend FormatCountCaptureHelper // class. - absl::Nonnull Unused() { return p_; } - absl::Nonnull p_; + int* absl_nonnull Unused() { return p_; } + int* absl_nonnull p_; }; // FormatSpec @@ -377,7 +377,7 @@ template // std::string orig("For example PI is approximately "); // std::cout << StrAppendFormat(&orig, "%12.6f", 3.14); template -std::string& StrAppendFormat(absl::Nonnull dst, +std::string& StrAppendFormat(std::string* absl_nonnull dst, const FormatSpec& format, const Args&... args) { return str_format_internal::AppendPack( @@ -437,7 +437,7 @@ int PrintF(const FormatSpec& format, const Args&... args) { // Outputs: "The capital of Mongolia is Ulaanbaatar" // template -int FPrintF(absl::Nonnull output, const FormatSpec& format, +int FPrintF(std::FILE* absl_nonnull output, const FormatSpec& format, const Args&... args) { return str_format_internal::FprintF( output, str_format_internal::UntypedFormatSpecImpl::Extract(format), @@ -466,7 +466,7 @@ int FPrintF(absl::Nonnull output, const FormatSpec& format, // Post-condition: output == "The capital of Mongolia is Ulaanbaatar" // template -int SNPrintF(absl::Nonnull output, std::size_t size, +int SNPrintF(char* absl_nonnull output, std::size_t size, const FormatSpec& format, const Args&... args) { return str_format_internal::SnprintF( output, size, str_format_internal::UntypedFormatSpecImpl::Extract(format), @@ -500,7 +500,7 @@ class FormatRawSink { template ::value>::type> - FormatRawSink(absl::Nonnull raw) // NOLINT + FormatRawSink(T* absl_nonnull raw) // NOLINT : sink_(raw) {} private: @@ -857,16 +857,16 @@ class FormatSink { } // Support `absl::Format(&sink, format, args...)`. - friend void AbslFormatFlush(absl::Nonnull sink, + friend void AbslFormatFlush(FormatSink* absl_nonnull sink, absl::string_view v) { sink->Append(v); } private: friend str_format_internal::FormatSinkImpl; - explicit FormatSink(absl::Nonnull s) + explicit FormatSink(str_format_internal::FormatSinkImpl* absl_nonnull s) : sink_(s) {} - absl::Nonnull sink_; + str_format_internal::FormatSinkImpl* absl_nonnull sink_; }; // FormatConvertResult diff --git a/absl/strings/str_replace.cc b/absl/strings/str_replace.cc index a7ab52fe..377e30cf 100644 --- a/absl/strings/str_replace.cc +++ b/absl/strings/str_replace.cc @@ -37,8 +37,8 @@ using FixedMapping = // occurred. int ApplySubstitutions( absl::string_view s, - absl::Nonnull*> subs_ptr, - absl::Nonnull result_ptr) { + std::vector* absl_nonnull subs_ptr, + std::string* absl_nonnull result_ptr) { auto& subs = *subs_ptr; int substitutions = 0; size_t pos = 0; @@ -83,7 +83,7 @@ std::string StrReplaceAll(absl::string_view s, } int StrReplaceAll(strings_internal::FixedMapping replacements, - absl::Nonnull target) { + std::string* absl_nonnull target) { return StrReplaceAll(replacements, target); } diff --git a/absl/strings/str_replace.h b/absl/strings/str_replace.h index d74feac0..91b920bc 100644 --- a/absl/strings/str_replace.h +++ b/absl/strings/str_replace.h @@ -114,7 +114,7 @@ std::string StrReplaceAll(absl::string_view s, int StrReplaceAll( std::initializer_list> replacements, - absl::Nonnull target); + std::string* absl_nonnull target); // Overload of `StrReplaceAll()` to replace patterns within a given output // string *in place* with replacements provided within a container of key/value @@ -130,7 +130,7 @@ int StrReplaceAll( // EXPECT_EQ("if (ptr < &foo)", s); template int StrReplaceAll(const StrToStrMapping& replacements, - absl::Nonnull target); + std::string* absl_nonnull target); // Implementation details only, past this point. namespace strings_internal { @@ -187,8 +187,8 @@ std::vector FindSubstitutions( } int ApplySubstitutions(absl::string_view s, - absl::Nonnull*> subs_ptr, - absl::Nonnull result_ptr); + std::vector* absl_nonnull subs_ptr, + std::string* absl_nonnull result_ptr); } // namespace strings_internal @@ -204,7 +204,7 @@ std::string StrReplaceAll(absl::string_view s, template int StrReplaceAll(const StrToStrMapping& replacements, - absl::Nonnull target) { + std::string* absl_nonnull target) { auto subs = strings_internal::FindSubstitutions(*target, replacements); if (subs.empty()) return 0; diff --git a/absl/strings/string_view.cc b/absl/strings/string_view.cc index dc2951cf..33bd1bbc 100644 --- a/absl/strings/string_view.cc +++ b/absl/strings/string_view.cc @@ -30,10 +30,10 @@ namespace { // This is significantly faster for case-sensitive matches with very // few possible matches. -absl::Nullable memmatch(absl::Nullable phaystack, - size_t haylen, - absl::Nullable pneedle, - size_t neelen) { +const char* absl_nullable memmatch(const char* absl_nullable phaystack, + size_t haylen, + const char* absl_nullable pneedle, + size_t neelen) { if (0 == neelen) { return phaystack; // even if haylen is 0 } diff --git a/absl/strings/string_view.h b/absl/strings/string_view.h index b05c036b..9a1933b6 100644 --- a/absl/strings/string_view.h +++ b/absl/strings/string_view.h @@ -163,11 +163,11 @@ class ABSL_ATTRIBUTE_VIEW string_view { public: using traits_type = std::char_traits; using value_type = char; - using pointer = absl::Nullable; - using const_pointer = absl::Nullable; + using pointer = char* absl_nullable; + using const_pointer = const char* absl_nullable; using reference = char&; using const_reference = const char&; - using const_iterator = absl::Nullable; + using const_iterator = const char* absl_nullable; using iterator = const_iterator; using const_reverse_iterator = std::reverse_iterator; using reverse_iterator = const_reverse_iterator; @@ -197,11 +197,11 @@ class ABSL_ATTRIBUTE_VIEW string_view { // instead (see below). // The length check is skipped since it is unnecessary and causes code bloat. constexpr string_view( // NOLINT(runtime/explicit) - absl::Nonnull str) + const char* absl_nonnull str) : ptr_(str), length_(str ? StrlenInternal(str) : 0) {} // Constructor of a `string_view` from a `const char*` and length. - constexpr string_view(absl::Nullable data, size_type len) + constexpr string_view(const char* absl_nullable data, size_type len) : ptr_(data), length_(CheckLengthInternal(len)) {} constexpr string_view(const string_view&) noexcept = default; @@ -430,21 +430,21 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::compare()` for comparing a `string_view` and a // a different C-style string `s`. - constexpr int compare(absl::Nonnull s) const { + constexpr int compare(const char* absl_nonnull s) const { return compare(string_view(s)); } // Overload of `string_view::compare()` for comparing a substring of the // `string_view` and a different string C-style string `s`. constexpr int compare(size_type pos1, size_type count1, - absl::Nonnull s) const { + const char* absl_nonnull s) const { return substr(pos1, count1).compare(string_view(s)); } // Overload of `string_view::compare()` for comparing a substring of the // `string_view` and a substring of a different C-style string `s`. constexpr int compare(size_type pos1, size_type count1, - absl::Nonnull s, size_type count2) const { + const char* absl_nonnull s, size_type count2) const { return substr(pos1, count1).compare(string_view(s, count2)); } @@ -463,14 +463,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::find()` for finding a substring of a different // C-style string `s` within the `string_view`. - size_type find(absl::Nonnull s, size_type pos, + size_type find(const char* absl_nonnull s, size_type pos, size_type count) const { return find(string_view(s, count), pos); } // Overload of `string_view::find()` for finding a different C-style string // `s` within the `string_view`. - size_type find(absl::Nonnull s, size_type pos = 0) const { + size_type find(const char* absl_nonnull s, size_type pos = 0) const { return find(string_view(s), pos); } @@ -487,14 +487,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::rfind()` for finding a substring of a different // C-style string `s` within the `string_view`. - size_type rfind(absl::Nonnull s, size_type pos, + size_type rfind(const char* absl_nonnull s, size_type pos, size_type count) const { return rfind(string_view(s, count), pos); } // Overload of `string_view::rfind()` for finding a different C-style string // `s` within the `string_view`. - size_type rfind(absl::Nonnull s, size_type pos = npos) const { + size_type rfind(const char* absl_nonnull s, size_type pos = npos) const { return rfind(string_view(s), pos); } @@ -513,15 +513,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::find_first_of()` for finding a substring of a // different C-style string `s` within the `string_view`. - size_type find_first_of(absl::Nonnull s, size_type pos, + size_type find_first_of(const char* absl_nonnull s, size_type pos, size_type count) const { return find_first_of(string_view(s, count), pos); } // Overload of `string_view::find_first_of()` for finding a different C-style // string `s` within the `string_view`. - size_type find_first_of(absl::Nonnull s, - size_type pos = 0) const { + size_type find_first_of(const char* absl_nonnull s, size_type pos = 0) const { return find_first_of(string_view(s), pos); } @@ -540,14 +539,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::find_last_of()` for finding a substring of a // different C-style string `s` within the `string_view`. - size_type find_last_of(absl::Nonnull s, size_type pos, + size_type find_last_of(const char* absl_nonnull s, size_type pos, size_type count) const { return find_last_of(string_view(s, count), pos); } // Overload of `string_view::find_last_of()` for finding a different C-style // string `s` within the `string_view`. - size_type find_last_of(absl::Nonnull s, + size_type find_last_of(const char* absl_nonnull s, size_type pos = npos) const { return find_last_of(string_view(s), pos); } @@ -565,14 +564,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::find_first_not_of()` for finding a substring of a // different C-style string `s` within the `string_view`. - size_type find_first_not_of(absl::Nonnull s, size_type pos, + size_type find_first_not_of(const char* absl_nonnull s, size_type pos, size_type count) const { return find_first_not_of(string_view(s, count), pos); } // Overload of `string_view::find_first_not_of()` for finding a different // C-style string `s` within the `string_view`. - size_type find_first_not_of(absl::Nonnull s, + size_type find_first_not_of(const char* absl_nonnull s, size_type pos = 0) const { return find_first_not_of(string_view(s), pos); } @@ -591,14 +590,14 @@ class ABSL_ATTRIBUTE_VIEW string_view { // Overload of `string_view::find_last_not_of()` for finding a substring of a // different C-style string `s` within the `string_view`. - size_type find_last_not_of(absl::Nonnull s, size_type pos, + size_type find_last_not_of(const char* absl_nonnull s, size_type pos, size_type count) const { return find_last_not_of(string_view(s, count), pos); } // Overload of `string_view::find_last_not_of()` for finding a different // C-style string `s` within the `string_view`. - size_type find_last_not_of(absl::Nonnull s, + size_type find_last_not_of(const char* absl_nonnull s, size_type pos = npos) const { return find_last_not_of(string_view(s), pos); } @@ -659,7 +658,7 @@ class ABSL_ATTRIBUTE_VIEW string_view { // The constructor from std::string delegates to this constructor. // See the comment on that constructor for the rationale. struct SkipCheckLengthTag {}; - string_view(absl::Nullable data, size_type len, + string_view(const char* absl_nullable data, size_type len, SkipCheckLengthTag) noexcept : ptr_(data), length_(len) {} @@ -671,7 +670,7 @@ class ABSL_ATTRIBUTE_VIEW string_view { return len; } - static constexpr size_type StrlenInternal(absl::Nonnull str) { + static constexpr size_type StrlenInternal(const char* absl_nonnull str) { #if defined(_MSC_VER) && !defined(__clang__) // MSVC 2017+ can evaluate this at compile-time. const char* begin = str; @@ -696,7 +695,7 @@ class ABSL_ATTRIBUTE_VIEW string_view { : (compare_result < 0 ? -1 : 1); } - absl::Nullable ptr_; + const char* absl_nullable ptr_; size_type length_; }; @@ -757,7 +756,7 @@ inline string_view ClippedSubstr(string_view s, size_t pos, // Creates an `absl::string_view` from a pointer `p` even if it's null-valued. // This function should be used where an `absl::string_view` can be created from // a possibly-null pointer. -constexpr string_view NullSafeStringView(absl::Nullable p) { +constexpr string_view NullSafeStringView(const char* absl_nullable p) { return p ? string_view(p) : string_view(); } diff --git a/absl/strings/strip.h b/absl/strings/strip.h index 2d5faf60..55398ffe 100644 --- a/absl/strings/strip.h +++ b/absl/strings/strip.h @@ -45,7 +45,7 @@ ABSL_NAMESPACE_BEGIN // absl::string_view input("abc"); // EXPECT_TRUE(absl::ConsumePrefix(&input, "a")); // EXPECT_EQ(input, "bc"); -inline constexpr bool ConsumePrefix(absl::Nonnull str, +inline constexpr bool ConsumePrefix(absl::string_view* absl_nonnull str, absl::string_view expected) { if (!absl::StartsWith(*str, expected)) return false; str->remove_prefix(expected.size()); @@ -62,7 +62,7 @@ inline constexpr bool ConsumePrefix(absl::Nonnull str, // absl::string_view input("abcdef"); // EXPECT_TRUE(absl::ConsumeSuffix(&input, "def")); // EXPECT_EQ(input, "abc"); -inline constexpr bool ConsumeSuffix(absl::Nonnull str, +inline constexpr bool ConsumeSuffix(absl::string_view* absl_nonnull str, absl::string_view expected) { if (!absl::EndsWith(*str, expected)) return false; str->remove_suffix(expected.size()); diff --git a/absl/strings/substitute.cc b/absl/strings/substitute.cc index a71f565a..3c2ca5d2 100644 --- a/absl/strings/substitute.cc +++ b/absl/strings/substitute.cc @@ -35,9 +35,10 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace substitute_internal { -void SubstituteAndAppendArray( - absl::Nonnull output, absl::string_view format, - absl::Nullable args_array, size_t num_args) { +void SubstituteAndAppendArray(std::string* absl_nonnull output, + absl::string_view format, + const absl::string_view* absl_nullable args_array, + size_t num_args) { // Determine total size needed. size_t size = 0; for (size_t i = 0; i < format.size(); i++) { @@ -109,7 +110,7 @@ void SubstituteAndAppendArray( assert(target == output->data() + output->size()); } -Arg::Arg(absl::Nullable value) { +Arg::Arg(const void* absl_nullable value) { static_assert(sizeof(scratch_) >= sizeof(value) * 2 + 2, "fix sizeof(scratch_)"); if (value == nullptr) { diff --git a/absl/strings/substitute.h b/absl/strings/substitute.h index e9c4b6e8..08f64e99 100644 --- a/absl/strings/substitute.h +++ b/absl/strings/substitute.h @@ -106,7 +106,7 @@ class Arg { // Overloads for string-y things // // Explicitly overload `const char*` so the compiler doesn't cast to `bool`. - Arg(absl::Nullable value) // NOLINT(google-explicit-constructor) + Arg(const char* absl_nullable value) // NOLINT(google-explicit-constructor) : piece_(absl::NullSafeStringView(value)) {} template Arg( // NOLINT @@ -199,7 +199,7 @@ class Arg { // `void*` values, with the exception of `char*`, are printed as // "0x". However, in the case of `nullptr`, "NULL" is printed. Arg( // NOLINT(google-explicit-constructor) - absl::Nullable value); + const void* absl_nullable value); // Normal enums are already handled by the integer formatters. // This overload matches only scoped enums. @@ -222,12 +222,13 @@ class Arg { // Internal helper function. Don't call this from outside this implementation. // This interface may change without notice. -void SubstituteAndAppendArray( - absl::Nonnull output, absl::string_view format, - absl::Nullable args_array, size_t num_args); +void SubstituteAndAppendArray(std::string* absl_nonnull output, + absl::string_view format, + const absl::string_view* absl_nullable args_array, + size_t num_args); #if defined(ABSL_BAD_CALL_IF) -constexpr int CalculateOneBit(absl::Nonnull format) { +constexpr int CalculateOneBit(const char* absl_nonnull format) { // Returns: // * 2^N for '$N' when N is in [0-9] // * 0 for correct '$' escaping: '$$'. @@ -236,11 +237,11 @@ constexpr int CalculateOneBit(absl::Nonnull format) { : (1 << (*format - '0')); } -constexpr const char* SkipNumber(absl::Nonnull format) { +constexpr const char* SkipNumber(const char* absl_nonnull format) { return !*format ? format : (format + 1); } -constexpr int PlaceholderBitmask(absl::Nonnull format) { +constexpr int PlaceholderBitmask(const char* absl_nonnull format) { return !*format ? 0 : *format != '$' ? PlaceholderBitmask(format + 1) @@ -273,12 +274,12 @@ constexpr int PlaceholderBitmask(absl::Nonnull format) { // absl::SubstituteAndAppend(boilerplate, format, args...); // } // -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format) { substitute_internal::SubstituteAndAppendArray(output, format, nullptr, 0); } -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0) { const absl::string_view args[] = {a0.piece()}; @@ -286,7 +287,7 @@ inline void SubstituteAndAppend(absl::Nonnull output, ABSL_ARRAYSIZE(args)); } -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1) { @@ -295,7 +296,7 @@ inline void SubstituteAndAppend(absl::Nonnull output, ABSL_ARRAYSIZE(args)); } -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, @@ -305,7 +306,7 @@ inline void SubstituteAndAppend(absl::Nonnull output, ABSL_ARRAYSIZE(args)); } -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, @@ -317,7 +318,7 @@ inline void SubstituteAndAppend(absl::Nonnull output, ABSL_ARRAYSIZE(args)); } -inline void SubstituteAndAppend(absl::Nonnull output, +inline void SubstituteAndAppend(std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, @@ -331,7 +332,7 @@ inline void SubstituteAndAppend(absl::Nonnull output, } inline void SubstituteAndAppend( - absl::Nonnull output, absl::string_view format, + std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5) { @@ -342,7 +343,7 @@ inline void SubstituteAndAppend( } inline void SubstituteAndAppend( - absl::Nonnull output, absl::string_view format, + std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -355,7 +356,7 @@ inline void SubstituteAndAppend( } inline void SubstituteAndAppend( - absl::Nonnull output, absl::string_view format, + std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -368,7 +369,7 @@ inline void SubstituteAndAppend( } inline void SubstituteAndAppend( - absl::Nonnull output, absl::string_view format, + std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -382,7 +383,7 @@ inline void SubstituteAndAppend( } inline void SubstituteAndAppend( - absl::Nonnull output, absl::string_view format, + std::string* absl_nonnull output, absl::string_view format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -398,16 +399,16 @@ inline void SubstituteAndAppend( #if defined(ABSL_BAD_CALL_IF) // This body of functions catches cases where the number of placeholders // doesn't match the number of data arguments. -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format) +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format) ABSL_BAD_CALL_IF( substitute_internal::PlaceholderBitmask(format) != 0, "There were no substitution arguments " "but this format string either has a $[0-9] in it or contains " "an unescaped $ character (use $$ instead)"); -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format, +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format, const substitute_internal::Arg& a0) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1, "There was 1 substitution argument given, but " @@ -415,8 +416,8 @@ void SubstituteAndAppend(absl::Nonnull output, "one of $1-$9, or contains an unescaped $ character (use " "$$ instead)"); -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format, +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1) ABSL_BAD_CALL_IF( @@ -425,8 +426,8 @@ void SubstituteAndAppend(absl::Nonnull output, "missing its $0/$1, contains one of $2-$9, or contains an " "unescaped $ character (use $$ instead)"); -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format, +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2) @@ -436,8 +437,8 @@ void SubstituteAndAppend(absl::Nonnull output, "this format string is missing its $0/$1/$2, contains one of " "$3-$9, or contains an unescaped $ character (use $$ instead)"); -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format, +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, @@ -448,8 +449,8 @@ void SubstituteAndAppend(absl::Nonnull output, "this format string is missing its $0-$3, contains one of " "$4-$9, or contains an unescaped $ character (use $$ instead)"); -void SubstituteAndAppend(absl::Nonnull output, - absl::Nonnull format, +void SubstituteAndAppend(std::string* absl_nonnull output, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, @@ -462,7 +463,7 @@ void SubstituteAndAppend(absl::Nonnull output, "$5-$9, or contains an unescaped $ character (use $$ instead)"); void SubstituteAndAppend( - absl::Nonnull output, absl::Nonnull format, + std::string* absl_nonnull output, const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5) @@ -473,7 +474,7 @@ void SubstituteAndAppend( "$6-$9, or contains an unescaped $ character (use $$ instead)"); void SubstituteAndAppend( - absl::Nonnull output, absl::Nonnull format, + std::string* absl_nonnull output, const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -485,7 +486,7 @@ void SubstituteAndAppend( "$7-$9, or contains an unescaped $ character (use $$ instead)"); void SubstituteAndAppend( - absl::Nonnull output, absl::Nonnull format, + std::string* absl_nonnull output, const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -497,7 +498,7 @@ void SubstituteAndAppend( "$8-$9, or contains an unescaped $ character (use $$ instead)"); void SubstituteAndAppend( - absl::Nonnull output, absl::Nonnull format, + std::string* absl_nonnull output, const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -510,7 +511,7 @@ void SubstituteAndAppend( "contains an unescaped $ character (use $$ instead)"); void SubstituteAndAppend( - absl::Nonnull output, absl::Nonnull format, + std::string* absl_nonnull output, const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, @@ -643,13 +644,13 @@ void SubstituteAndAppend( #if defined(ABSL_BAD_CALL_IF) // This body of functions catches cases where the number of placeholders // doesn't match the number of data arguments. -std::string Substitute(absl::Nonnull format) +std::string Substitute(const char* absl_nonnull format) ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 0, "There were no substitution arguments " "but this format string either has a $[0-9] in it or " "contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0) ABSL_BAD_CALL_IF( substitute_internal::PlaceholderBitmask(format) != 1, @@ -657,7 +658,7 @@ std::string Substitute(absl::Nonnull format, "this format string is missing its $0, contains one of $1-$9, " "or contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1) ABSL_BAD_CALL_IF( @@ -666,7 +667,7 @@ std::string Substitute(absl::Nonnull format, "this format string is missing its $0/$1, contains one of " "$2-$9, or contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2) @@ -676,7 +677,7 @@ std::string Substitute(absl::Nonnull format, "this format string is missing its $0/$1/$2, contains one of " "$3-$9, or contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, @@ -687,7 +688,7 @@ std::string Substitute(absl::Nonnull format, "this format string is missing its $0-$3, contains one of " "$4-$9, or contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, @@ -699,7 +700,7 @@ std::string Substitute(absl::Nonnull format, "this format string is missing its $0-$4, contains one of " "$5-$9, or contains an unescaped $ character (use $$ instead)"); -std::string Substitute(absl::Nonnull format, +std::string Substitute(const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, @@ -713,7 +714,7 @@ std::string Substitute(absl::Nonnull format, "$6-$9, or contains an unescaped $ character (use $$ instead)"); std::string Substitute( - absl::Nonnull format, const substitute_internal::Arg& a0, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, const substitute_internal::Arg& a6) @@ -724,7 +725,7 @@ std::string Substitute( "$7-$9, or contains an unescaped $ character (use $$ instead)"); std::string Substitute( - absl::Nonnull format, const substitute_internal::Arg& a0, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, const substitute_internal::Arg& a6, @@ -736,7 +737,7 @@ std::string Substitute( "$8-$9, or contains an unescaped $ character (use $$ instead)"); std::string Substitute( - absl::Nonnull format, const substitute_internal::Arg& a0, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, const substitute_internal::Arg& a6, @@ -748,7 +749,7 @@ std::string Substitute( "contains an unescaped $ character (use $$ instead)"); std::string Substitute( - absl::Nonnull format, const substitute_internal::Arg& a0, + const char* absl_nonnull format, const substitute_internal::Arg& a0, const substitute_internal::Arg& a1, const substitute_internal::Arg& a2, const substitute_internal::Arg& a3, const substitute_internal::Arg& a4, const substitute_internal::Arg& a5, const substitute_internal::Arg& a6, diff --git a/absl/types/span.h b/absl/types/span.h index 33904a90..9d164960 100644 --- a/absl/types/span.h +++ b/absl/types/span.h @@ -724,12 +724,12 @@ ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool operator>=(Span a, const U& b) { // } // template -constexpr Span MakeSpan(absl::Nullable ptr, size_t size) noexcept { +constexpr Span MakeSpan(T* absl_nullable ptr, size_t size) noexcept { return Span(ptr, size); } template -Span MakeSpan(absl::Nullable begin, absl::Nullable end) noexcept { +Span MakeSpan(T* absl_nullable begin, T* absl_nullable end) noexcept { ABSL_HARDENING_ASSERT(begin <= end); return Span(begin, static_cast(end - begin)); } @@ -770,14 +770,14 @@ constexpr Span MakeSpan(T (&array)[N]) noexcept { // ProcessInts(absl::MakeConstSpan(std::vector{ 0, 0, 0 })); // template -constexpr Span MakeConstSpan(absl::Nullable ptr, +constexpr Span MakeConstSpan(T* absl_nullable ptr, size_t size) noexcept { return Span(ptr, size); } template -Span MakeConstSpan(absl::Nullable begin, - absl::Nullable end) noexcept { +Span MakeConstSpan(T* absl_nullable begin, + T* absl_nullable end) noexcept { ABSL_HARDENING_ASSERT(begin <= end); return Span(begin, end - begin); }