Skip to content

Commit c50fb16

Browse files
Automated rollback of commit d170d28.
PiperOrigin-RevId: 842620254
1 parent 7b9feca commit c50fb16

39 files changed

+1519
-2644
lines changed

benchmarks/benchmark.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,9 @@ BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDescSV, InitBlock, Alias);
328328

329329
static void BM_SerializeDescriptor_Proto2(benchmark::State& state) {
330330
upb_benchmark::FileDescriptorProto proto;
331-
(void)proto.ParseFromString(
332-
absl::string_view(descriptor.data, descriptor.size));
331+
proto.ParseFromString(absl::string_view(descriptor.data, descriptor.size));
333332
for (auto _ : state) {
334-
(void)proto.SerializePartialToArray(buf, sizeof(buf));
333+
proto.SerializePartialToArray(buf, sizeof(buf));
335334
benchmark::DoNotOptimize(buf);
336335
}
337336
state.SetBytesProcessed(state.iterations() * descriptor.size);
@@ -421,7 +420,7 @@ BENCHMARK(BM_JsonParse_Upb);
421420
static void BM_JsonParse_Proto2(benchmark::State& state) {
422421
protobuf::FileDescriptorProto proto;
423422
absl::string_view input(descriptor.data, descriptor.size);
424-
(void)proto.ParseFromString(input);
423+
proto.ParseFromString(input);
425424
std::string json;
426425
ABSL_CHECK_OK(google::protobuf::json::MessageToJsonString(proto, &json));
427426
for (auto _ : state) {
@@ -462,7 +461,7 @@ BENCHMARK(BM_JsonSerialize_Upb);
462461
static void BM_JsonSerialize_Proto2(benchmark::State& state) {
463462
protobuf::FileDescriptorProto proto;
464463
absl::string_view input(descriptor.data, descriptor.size);
465-
(void)proto.ParseFromString(input);
464+
proto.ParseFromString(input);
466465
std::string json;
467466
for (auto _ : state) {
468467
json.clear();

benchmarks/gen_protobuf_binary_cc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def RefMessage(name):
5454
print('''
5555
{{
5656
{name} proto;
57-
(void)proto.ParseFromArray(buf, 0);
58-
(void)proto.SerializePartialToArray(&buf[0], 0);
57+
proto.ParseFromArray(buf, 0);
58+
proto.SerializePartialToArray(&buf[0], 0);
5959
}}
6060
'''.format(name=name))
6161

lua/upbc.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ bool LuaGenerator::Generate(const protobuf::FileDescriptor* file,
9999
protobuf::FileDescriptorProto file_proto;
100100
file->CopyTo(&file_proto);
101101
std::string file_data;
102-
// TODO: Remove this suppression.
103-
(void)file_proto.SerializeToString(&file_data);
102+
file_proto.SerializeToString(&file_data);
104103

105104
printer.Print("local descriptor = table.concat({\n");
106105
absl::string_view data(file_data);

python/google/protobuf/proto_api.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ PythonMessageMutator::~PythonMessageMutator() {
4646
// check.
4747
if (!PyErr_Occurred() && owned_msg_ != nullptr) {
4848
std::string wire;
49-
// TODO: Remove this suppression.
50-
(void)message_->SerializePartialToString(&wire);
49+
message_->SerializePartialToString(&wire);
5150
PyObject* py_wire = PyBytes_FromStringAndSize(
5251
wire.data(), static_cast<Py_ssize_t>(wire.size()));
5352
PyObject* parse =
@@ -114,23 +113,20 @@ bool PythonConstMessagePointer::NotChanged() {
114113
// serialize result may still diff between languages. So parse to
115114
// another c++ message for compare.
116115
std::unique_ptr<google::protobuf::Message> parsed_msg(owned_msg_->New());
117-
// TODO: Remove this suppression.
118-
(void)parsed_msg->ParsePartialFromString(
116+
parsed_msg->ParsePartialFromString(
119117
absl::string_view(data, static_cast<int>(len)));
120118
std::string wire_other;
121119
google::protobuf::io::StringOutputStream stream_other(&wire_other);
122120
google::protobuf::io::CodedOutputStream output_other(&stream_other);
123121
output_other.SetSerializationDeterministic(true);
124-
// TODO: Remove this suppression.
125-
(void)parsed_msg->SerializePartialToCodedStream(&output_other);
122+
parsed_msg->SerializePartialToCodedStream(&output_other);
126123
output_other.Trim();
127124

128125
std::string wire;
129126
google::protobuf::io::StringOutputStream stream(&wire);
130127
google::protobuf::io::CodedOutputStream output(&stream);
131128
output.SetSerializationDeterministic(true);
132-
// TODO: Remove this suppression.
133-
(void)owned_msg_->SerializePartialToCodedStream(&output);
129+
owned_msg_->SerializePartialToCodedStream(&output);
134130
output.Trim();
135131

136132
if (wire == wire_other) {

python/google/protobuf/pyext/descriptor.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ bool Reparse(PyMessageFactory* message_factory, const Message& from,
228228
Message* to) {
229229
// Reparse message.
230230
std::string serialized;
231-
// TODO: Remove this suppression.
232-
(void)from.SerializeToString(&serialized);
231+
from.SerializeToString(&serialized);
233232
io::CodedInputStream input(
234233
reinterpret_cast<const uint8_t*>(serialized.c_str()), serialized.size());
235234
input.SetExtensionRegistry(message_factory->pool->pool,
@@ -1491,8 +1490,7 @@ static PyObject* GetSerializedPb(PyFileDescriptor* self, void* closure) {
14911490
FileDescriptorProto file_proto;
14921491
_GetDescriptor(self)->CopyTo(&file_proto);
14931492
std::string contents;
1494-
// TODO: Remove this suppression.
1495-
(void)file_proto.SerializePartialToString(&contents);
1493+
file_proto.SerializePartialToString(&contents);
14961494
self->serialized_pb = PyBytes_FromStringAndSize(
14971495
contents.c_str(), static_cast<size_t>(contents.size()));
14981496
if (self->serialized_pb == nullptr) {

python/google/protobuf/pyext/message_module.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,8 @@ absl::StatusOr<google::protobuf::Message*> CreateNewMessage(PyObject* py_msg) {
285285
bool CopyToOwnedMsg(google::protobuf::Message** copy, const google::protobuf::Message& message) {
286286
*copy = message.New();
287287
std::string wire;
288-
// TODO: Remove this suppression.
289-
(void)message.SerializePartialToString(&wire);
290-
// TODO: Remove this suppression.
291-
(void)(*copy)->ParsePartialFromString(wire);
288+
message.SerializePartialToString(&wire);
289+
(*copy)->ParsePartialFromString(wire);
292290
return true;
293291
}
294292

src/google/protobuf/compiler/cpp/enum.cc

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,11 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
204204

205205
if (has_reflection_) {
206206
p->Emit(R"(
207-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD $dllexport_decl $const $pb$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor();
207+
$dllexport_decl $const $pb$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor();
208208
)");
209209
} else {
210210
p->Emit(R"cc(
211-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD $return_type$
212-
$Msg_Enum$_Name($Msg_Enum$ value);
211+
$return_type$ $Msg_Enum$_Name($Msg_Enum$ value);
213212
)cc");
214213
}
215214

@@ -231,8 +230,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
231230
if (should_cache_ || !has_reflection_) {
232231
p->Emit({{"static_assert", write_assert}}, R"cc(
233232
template <typename T>
234-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD $return_type$
235-
$Msg_Enum$_Name(T value) {
233+
$return_type$ $Msg_Enum$_Name(T value) {
236234
$static_assert$;
237235
return $Msg_Enum$_Name(static_cast<$Msg_Enum$>(value));
238236
}
@@ -244,8 +242,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
244242
// pointers, so if the enum values are sparse, it's not worth it.
245243
p->Emit(R"cc(
246244
template <>
247-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD inline $return_type$
248-
$Msg_Enum$_Name($Msg_Enum$ value) {
245+
inline $return_type$ $Msg_Enum$_Name($Msg_Enum$ value) {
249246
return $pbi$::NameOfDenseEnum<$Msg_Enum$_descriptor, $kMin$, $kMax$>(
250247
static_cast<int>(value));
251248
}
@@ -254,8 +251,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
254251
} else {
255252
p->Emit({{"static_assert", write_assert}}, R"cc(
256253
template <typename T>
257-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD $return_type$
258-
$Msg_Enum$_Name(T value) {
254+
$return_type$ $Msg_Enum$_Name(T value) {
259255
$static_assert$;
260256
return $pbi$::NameOfEnum($Msg_Enum$_descriptor(), value);
261257
}
@@ -264,7 +260,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
264260

265261
if (has_reflection_) {
266262
p->Emit(R"cc(
267-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD inline bool $Msg_Enum$_Parse(
263+
inline bool $Msg_Enum$_Parse(
268264
//~
269265
::absl::string_view name, $Msg_Enum$* $nonnull$ value) {
270266
return $pbi$::ParseNamedEnum<$Msg_Enum$>($Msg_Enum$_descriptor(), name,
@@ -273,7 +269,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
273269
)cc");
274270
} else {
275271
p->Emit(R"cc(
276-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD bool $Msg_Enum$_Parse(
272+
bool $Msg_Enum$_Parse(
277273
//~
278274
::absl::string_view name, $Msg_Enum$* $nonnull$ value);
279275
)cc");
@@ -327,8 +323,7 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* p) const {
327323
.AnnotatedAs(enum_),
328324
},
329325
R"cc(
330-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD static inline bool $Enum$_IsValid(
331-
int value) {
326+
static inline bool $Enum$_IsValid(int value) {
332327
return $Msg_Enum$_IsValid(value);
333328
}
334329
static constexpr $Enum_$ $Enum_MIN$ = $Msg_Enum$_$Enum$_MIN;
@@ -356,11 +351,10 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* p) const {
356351

357352
p->Emit(R"cc(
358353
template <typename T>
359-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD static inline $return_type$ $Enum$_Name(
360-
T value) {
354+
static inline $return_type$ $Enum$_Name(T value) {
361355
return $Msg_Enum$_Name(value);
362356
}
363-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD static inline bool $Enum$_Parse(
357+
static inline bool $Enum$_Parse(
364358
//~
365359
::absl::string_view name, $Enum_$* $nonnull$ value) {
366360
return $Msg_Enum$_Parse(name, value);
@@ -379,36 +373,31 @@ void EnumGenerator::GenerateIsValid(io::Printer* p) const {
379373
static_cast<int64_t>(sorted_unique_values_.size()) - 1 ==
380374
sorted_unique_values_.back()) {
381375
// They are sequential. Do a simple range check.
382-
p->Emit(
383-
{{"min", sorted_unique_values_.front()},
384-
{"max", sorted_unique_values_.back()}},
385-
R"cc(
386-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD inline bool $Msg_Enum$_IsValid(
387-
int value) {
388-
return $min$ <= value && value <= $max$;
389-
}
390-
)cc");
376+
p->Emit({{"min", sorted_unique_values_.front()},
377+
{"max", sorted_unique_values_.back()}},
378+
R"cc(
379+
inline bool $Msg_Enum$_IsValid(int value) {
380+
return $min$ <= value && value <= $max$;
381+
}
382+
)cc");
391383
} else if (sorted_unique_values_.front() >= 0 &&
392384
sorted_unique_values_.back() < 64) {
393385
// Not sequential, but they fit in a 64-bit bitmap.
394386
uint64_t bitmap = 0;
395387
for (int n : sorted_unique_values_) {
396388
bitmap |= uint64_t{1} << n;
397389
}
398-
p->Emit(
399-
{{"bitmap", bitmap}, {"max", sorted_unique_values_.back()}},
400-
R"cc(
401-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD inline bool $Msg_Enum$_IsValid(
402-
int value) {
403-
return 0 <= value && value <= $max$ && (($bitmap$u >> value) & 1) != 0;
404-
}
405-
)cc");
390+
p->Emit({{"bitmap", bitmap}, {"max", sorted_unique_values_.back()}},
391+
R"cc(
392+
inline bool $Msg_Enum$_IsValid(int value) {
393+
return 0 <= value && value <= $max$ && (($bitmap$u >> value) & 1) != 0;
394+
}
395+
)cc");
406396
} else {
407397
// More complex struct. Use enum data structure for lookup.
408398
p->Emit(
409399
R"cc(
410-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD inline bool $Msg_Enum$_IsValid(
411-
int value) {
400+
inline bool $Msg_Enum$_IsValid(int value) {
412401
return $pbi$::ValidateEnum(value, $Msg_Enum$_internal_data_);
413402
}
414403
)cc");
@@ -420,8 +409,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {
420409

421410
if (has_reflection_) {
422411
p->Emit({{"idx", idx}}, R"cc(
423-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD const $pb$::EnumDescriptor* $nonnull$
424-
$Msg_Enum$_descriptor() {
412+
const $pb$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor() {
425413
$pbi$::AssignDescriptors(&$desc_table$);
426414
return $file_level_enum_descriptors$[$idx$];
427415
}
@@ -553,8 +541,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {
553541
$entries_by_number$,
554542
};
555543
556-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD $return_type$
557-
$Msg_Enum$_Name($Msg_Enum$ value) {
544+
$return_type$ $Msg_Enum$_Name($Msg_Enum$ value) {
558545
static const bool kDummy = $pbi$::InitializeEnumStrings(
559546
$Msg_Enum$_entries, $Msg_Enum$_entries_by_number, $num_unique$,
560547
$Msg_Enum$_strings);
@@ -566,8 +553,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {
566553
return idx == -1 ? $pbi$::GetEmptyString() : $Msg_Enum$_strings[idx].get();
567554
}
568555
569-
PROTOBUF_FUTURE_ADD_EARLY_NODISCARD bool $Msg_Enum$_Parse(
570-
::absl::string_view name, $Msg_Enum$* $nonnull$ value) {
556+
bool $Msg_Enum$_Parse(::absl::string_view name, $Msg_Enum$* $nonnull$ value) {
571557
int int_value;
572558
bool success = $pbi$::LookUpEnumValue(
573559
$Msg_Enum$_entries, $num_declared$, name, &int_value);

0 commit comments

Comments
 (0)