Removed tautological comparisons of `(size_t)index > 0`.

Example:

```
bazel-out/k8-fastbuild/bin/protos_generator/tests/test_model.upb.proto.cc: In member function 'void protos_generator::test::protos::internal::TestModelV1Access::set_value4(size_t, int32_t)':
bazel-out/k8-fastbuild/bin/protos_generator/tests/test_model.upb.proto.cc:559:14: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
  559 |     assert(0 <= index && index < len);
```

PiperOrigin-RevId: 489086133
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent 677b928a44
commit 6178a0bf3c
  1. 12
      protos_generator/gen_accessors.cc

@ -343,7 +343,7 @@ void WriteRepeatedMessageAccessor(const protobuf::Descriptor* message,
$1 $0::$2(size_t index) const { $1 $0::$2(size_t index) const {
size_t len; size_t len;
auto* ptr = $3_$5(msg_, &len); auto* ptr = $3_$5(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
return ::protos::internal::CreateMessage<$4>((upb_Message*)*(ptr + index)); return ::protos::internal::CreateMessage<$4>((upb_Message*)*(ptr + index));
} }
)cc", )cc",
@ -369,7 +369,7 @@ void WriteRepeatedMessageAccessor(const protobuf::Descriptor* message,
$1 $0::mutable_$2(size_t index) const { $1 $0::mutable_$2(size_t index) const {
size_t len; size_t len;
auto* ptr = $3_$6(msg_, &len); auto* ptr = $3_$6(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
return ::protos::internal::CreateMessageProxy<$4>( return ::protos::internal::CreateMessageProxy<$4>(
(upb_Message*)*(ptr + index), $5); (upb_Message*)*(ptr + index), $5);
} }
@ -391,7 +391,7 @@ void WriteRepeatedStringAccessor(const protobuf::Descriptor* message,
$1 $0::$2(size_t index) const { $1 $0::$2(size_t index) const {
size_t len; size_t len;
auto* ptr = $3_mutable_$4(msg_, &len); auto* ptr = $3_mutable_$4(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
return ::protos::UpbStrToStringView(*(ptr + index)); return ::protos::UpbStrToStringView(*(ptr + index));
} }
)cc", )cc",
@ -417,7 +417,7 @@ void WriteRepeatedStringAccessor(const protobuf::Descriptor* message,
void $0::set_$2(size_t index, $1 val) { void $0::set_$2(size_t index, $1 val) {
size_t len; size_t len;
auto* ptr = $3_mutable_$4(msg_, &len); auto* ptr = $3_mutable_$4(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
*(ptr + index) = ::protos::UpbStrFromStringView(val, arena_); *(ptr + index) = ::protos::UpbStrFromStringView(val, arena_);
} }
)cc", )cc",
@ -436,7 +436,7 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message,
$1 $0::$2(size_t index) const { $1 $0::$2(size_t index) const {
size_t len; size_t len;
auto* ptr = $3_mutable_$4(msg_, &len); auto* ptr = $3_mutable_$4(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
return *(ptr + index); return *(ptr + index);
} }
)cc", )cc",
@ -460,7 +460,7 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message,
void $0::set_$2(size_t index, $1 val) { void $0::set_$2(size_t index, $1 val) {
size_t len; size_t len;
auto* ptr = $3_mutable_$4(msg_, &len); auto* ptr = $3_mutable_$4(msg_, &len);
assert(0 <= index && index < len); assert(index < len);
*(ptr + index) = val; *(ptr + index) = val;
} }
)cc", )cc",

Loading…
Cancel
Save