Export of internal Abseil changes

--
389189dbb322df0d0468ab13edf7dc185dc63833 by Abseil Team <absl-team@google.com>:

absl str_format.h can compile with -Wconversion and -Wsign-compare

PiperOrigin-RevId: 420799960

--
762e5adc429fc143756c42fe92fe8073c87c075f by Abseil Team <absl-team@google.com>:

GetStackTraceWithContext: Fix min_dropped_frames when no frames are recorded

Previously, if there were still frames to skip, they would be included
in min_dropped_frames.

PiperOrigin-RevId: 420766341

--
7d4374b8eaa410f4f98ec03d6a8997dccadfb271 by Abseil Team <absl-team@google.com>:

absl::flags compiles with -Wconversion and -Wsign-compare

PiperOrigin-RevId: 420476807

--
5f00f7805419d725fa1ff57b388e4c0750d1d6b0 by Derek Mauro <dmauro@google.com>:

Internal change

PiperOrigin-RevId: 420282152

--
bd5471fc34956acf3888bf90287b2aee4415c96d by Derek Mauro <dmauro@google.com>:

Internal change

PiperOrigin-RevId: 420282033

--
61c78020804e4290e9b2fe151aeaf99b198716ee by Derek Mauro <dmauro@google.com>:

Internal change

PiperOrigin-RevId: 420281867

--
dbe3aad24b65ea11664401a307ea3d2f28e8a7b9 by Derek Mauro <dmauro@google.com>:

Remove the incorrect test for the availability of [[nodiscard]]

It should have been ABSL_HAVE_CPP_ATTRIBUTE(nodiscard) instead of
ABSL_HAVE_ATTRIBUTE(nodiscard). As a result, some code is not
compliant with [[nodiscard]], so we cannot simply correct the availability
test.

Recommend that C++17-only code use the standard [[nodiscard] directly.

PiperOrigin-RevId: 420150702
GitOrigin-RevId: 389189dbb322df0d0468ab13edf7dc185dc63833
Change-Id: Idf6ebae3c4edd945c9032c7db3d0ab32d16e8078
pull/1095/head
Abseil Team 3 years ago committed by vslashg
parent 78f9680225
commit 2a042b082c
  1. 10
      absl/base/attributes.h
  2. 11
      absl/debugging/internal/stacktrace_aarch64-inl.inc
  3. 11
      absl/debugging/internal/stacktrace_arm-inl.inc
  4. 11
      absl/debugging/internal/stacktrace_powerpc-inl.inc
  5. 11
      absl/debugging/internal/stacktrace_riscv-inl.inc
  6. 11
      absl/debugging/internal/stacktrace_x86-inl.inc
  7. 8
      absl/flags/internal/flag.h
  8. 2
      absl/strings/internal/str_format/arg.h
  9. 6
      absl/strings/internal/str_format/extension.h
  10. 3
      absl/strings/internal/str_format/output.h
  11. 6
      absl/strings/internal/str_format/parser.h

@ -401,6 +401,9 @@
//
// Tells the compiler to warn about unused results.
//
// For code or headers that are assured to only build with C++17 and up, prefer
// just using the standard `[[nodiscard]]` directly over this macro.
//
// When annotating a function, it must appear as the first part of the
// declaration or definition. The compiler will warn if the return value from
// such a function is unused:
@ -427,9 +430,10 @@
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
//
// Note: past advice was to place the macro after the argument list.
#if ABSL_HAVE_ATTRIBUTE(nodiscard)
#define ABSL_MUST_USE_RESULT [[nodiscard]]
#elif defined(__clang__) && ABSL_HAVE_ATTRIBUTE(warn_unused_result)
//
// TODO(b/176172494): Use ABSL_HAVE_CPP_ATTRIBUTE(nodiscard) when all code is
// compliant with the stricter [[nodiscard]].
#if defined(__clang__) && ABSL_HAVE_ATTRIBUTE(warn_unused_result)
#define ABSL_MUST_USE_RESULT __attribute__((warn_unused_result))
#else
#define ABSL_MUST_USE_RESULT

@ -176,12 +176,17 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
// Implementation detail: we clamp the max of frames we are willing to
// count, so as not to spend too much time in the loop below.
const int kMaxUnwind = 200;
int j = 0;
for (; frame_pointer != nullptr && j < kMaxUnwind; j++) {
int num_dropped_frames = 0;
for (int j = 0; frame_pointer != nullptr && j < kMaxUnwind; j++) {
if (skip_count > 0) {
skip_count--;
} else {
num_dropped_frames++;
}
frame_pointer =
NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(frame_pointer, ucp);
}
*min_dropped_frames = j;
*min_dropped_frames = num_dropped_frames;
}
return n;
}

@ -112,11 +112,16 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
// Implementation detail: we clamp the max of frames we are willing to
// count, so as not to spend too much time in the loop below.
const int kMaxUnwind = 200;
int j = 0;
for (; sp != nullptr && j < kMaxUnwind; j++) {
int num_dropped_frames = 0;
for (int j = 0; sp != nullptr && j < kMaxUnwind; j++) {
if (skip_count > 0) {
skip_count--;
} else {
num_dropped_frames++;
}
sp = NextStackFrame<!IS_STACK_FRAMES>(sp);
}
*min_dropped_frames = j;
*min_dropped_frames = num_dropped_frames;
}
return n;
}

@ -231,11 +231,16 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
// Implementation detail: we clamp the max of frames we are willing to
// count, so as not to spend too much time in the loop below.
const int kMaxUnwind = 1000;
int j = 0;
for (; next_sp != nullptr && j < kMaxUnwind; j++) {
int num_dropped_frames = 0;
for (int j = 0; next_sp != nullptr && j < kMaxUnwind; j++) {
if (skip_count > 0) {
skip_count--;
} else {
num_dropped_frames++;
}
next_sp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(next_sp, ucp);
}
*min_dropped_frames = j;
*min_dropped_frames = num_dropped_frames;
}
return n;
}

@ -213,12 +213,17 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
// Implementation detail: we clamp the max of frames we are willing to
// count, so as not to spend too much time in the loop below.
const int kMaxUnwind = 200;
int j = 0;
for (; frame_pointer != nullptr && j < kMaxUnwind; j++) {
int num_dropped_frames = 0;
for (int j = 0; frame_pointer != nullptr && j < kMaxUnwind; j++) {
if (skip_count > 0) {
skip_count--;
} else {
num_dropped_frames++;
}
frame_pointer =
NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(frame_pointer, ucp);
}
*min_dropped_frames = j;
*min_dropped_frames = num_dropped_frames;
}
return n;
}

@ -341,12 +341,17 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
// Implementation detail: we clamp the max of frames we are willing to
// count, so as not to spend too much time in the loop below.
const int kMaxUnwind = 1000;
int j = 0;
for (; fp != nullptr && j < kMaxUnwind; j++) {
int num_dropped_frames = 0;
for (int j = 0; fp != nullptr && j < kMaxUnwind; j++) {
if (skip_count > 0) {
skip_count--;
} else {
num_dropped_frames++;
}
fp = NextStackFrame<!IS_STACK_FRAMES, IS_WITH_CONTEXT>(fp, ucp, stack_low,
stack_high);
}
*min_dropped_frames = j;
*min_dropped_frames = num_dropped_frames;
}
return n;
}

@ -303,7 +303,9 @@ constexpr FlagDefaultArg DefaultArg(char) {
///////////////////////////////////////////////////////////////////////////////
// Flag current value auxiliary structs.
constexpr int64_t UninitializedFlagValue() { return 0xababababababababll; }
constexpr int64_t UninitializedFlagValue() {
return static_cast<int64_t>(0xababababababababll);
}
template <typename T>
using FlagUseValueAndInitBitStorage = std::integral_constant<
@ -755,8 +757,8 @@ void* FlagOps(FlagOp op, const void* v1, void* v2, void* v3) {
case FlagOp::kValueOffset: {
// Round sizeof(FlagImp) to a multiple of alignof(FlagValue<T>) to get the
// offset of the data.
ptrdiff_t round_to = alignof(FlagValue<T>);
ptrdiff_t offset =
size_t round_to = alignof(FlagValue<T>);
size_t offset =
(sizeof(FlagImpl) + round_to - 1) / round_to * round_to;
return reinterpret_cast<void*>(offset);
}

@ -144,7 +144,7 @@ StringConvertResult FormatConvertImpl(const AbslCord& value,
size_t space_remaining = 0;
int width = conv.width();
if (width >= 0) space_remaining = width;
if (width >= 0) space_remaining = static_cast<size_t>(width);
size_t to_write = value.size();

@ -70,7 +70,7 @@ class FormatSinkImpl {
~FormatSinkImpl() { Flush(); }
void Flush() {
raw_.Write(string_view(buf_, pos_ - buf_));
raw_.Write(string_view(buf_, static_cast<size_t>(pos_ - buf_)));
pos_ = buf_;
}
@ -120,7 +120,9 @@ class FormatSinkImpl {
}
private:
size_t Avail() const { return buf_ + sizeof(buf_) - pos_; }
size_t Avail() const {
return static_cast<size_t>(buf_ + sizeof(buf_) - pos_);
}
FormatRawSinkImpl raw_;
size_t size_ = 0;

@ -22,6 +22,7 @@
#define ABSL_STRINGS_INTERNAL_STR_FORMAT_OUTPUT_H_
#include <cstdio>
#include <ios>
#include <ostream>
#include <string>
@ -71,7 +72,7 @@ inline void AbslFormatFlush(std::string* out, string_view s) {
out->append(s.data(), s.size());
}
inline void AbslFormatFlush(std::ostream* out, string_view s) {
out->write(s.data(), s.size());
out->write(s.data(), static_cast<std::streamsize>(s.size()));
}
inline void AbslFormatFlush(FILERawSink* sink, string_view v) {

@ -151,7 +151,8 @@ bool ParseFormatString(string_view src, Consumer consumer) {
const char* p = src.data();
const char* const end = p + src.size();
while (p != end) {
const char* percent = static_cast<const char*>(memchr(p, '%', end - p));
const char* percent =
static_cast<const char*>(memchr(p, '%', static_cast<size_t>(end - p)));
if (!percent) {
// We found the last substring.
return consumer.Append(string_view(p, end - p));
@ -242,7 +243,8 @@ class ParsedFormatBase {
string_view text(base, 0);
for (const auto& item : items_) {
const char* const end = text.data() + text.size();
text = string_view(end, (base + item.text_end) - end);
text =
string_view(end, static_cast<size_t>((base + item.text_end) - end));
if (item.is_conversion) {
if (!consumer.ConvertOne(item.conv, text)) return false;
} else {

Loading…
Cancel
Save