@@ -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