diff --git a/protos/protos.cc b/protos/protos.cc index 6ee9f8d393..4cd3d1ecd5 100644 --- a/protos/protos.cc +++ b/protos/protos.cc @@ -115,8 +115,8 @@ bool HasExtensionOrUnknown(const upb_Message* msg, const upb_MiniTableExtension* eid) { MessageLock msg_lock(msg); return _upb_Message_Getext(msg, eid) != nullptr || - upb_MiniTable_FindUnknown(msg, eid->field.number, 0).status == - kUpb_FindUnknown_Ok; + upb_MiniTable_FindUnknown(msg, upb_MiniTableExtension_Number(eid), 0) + .status == kUpb_FindUnknown_Ok; } const upb_Message_Extension* GetOrPromoteExtension( @@ -170,8 +170,9 @@ absl::Status MoveExtension(upb_Message* message, upb_Arena* message_arena, if (message_arena != extension_arena) { // Try fuse, if fusing is not allowed or fails, create copy of extension. if (!upb_Arena_Fuse(message_arena, extension_arena)) { - msg_ext->data.ptr = - DeepClone(extension, msg_ext->ext->sub.submsg, message_arena); + msg_ext->data.ptr = DeepClone( + extension, upb_MiniTableExtension_GetSubMessage(msg_ext->ext), + message_arena); return absl::OkStatus(); } } @@ -189,7 +190,8 @@ absl::Status SetExtension(upb_Message* message, upb_Arena* message_arena, } // Clone extension into target message arena. msg_ext->data.ptr = - DeepClone(extension, msg_ext->ext->sub.submsg, message_arena); + DeepClone(extension, upb_MiniTableExtension_GetSubMessage(msg_ext->ext), + message_arena); return absl::OkStatus(); } diff --git a/protos/protos.h b/protos/protos.h index 8ef7b66aa9..27d8c4eb43 100644 --- a/protos/protos.h +++ b/protos/protos.h @@ -18,6 +18,7 @@ #include "upb/message/copy.h" #include "upb/message/internal/accessors.h" #include "upb/message/internal/extension.h" +#include "upb/mini_table/extension.h" #include "upb/wire/decode.h" #include "upb/wire/encode.h" @@ -412,7 +413,8 @@ absl::StatusOr> GetExtension( const_cast(internal::GetInternalMsg(message)), id.mini_table_ext(), ::protos::internal::GetArena(message)); if (!ext) { - return ExtensionNotFoundError(id.mini_table_ext()->field.number); + return ExtensionNotFoundError( + upb_MiniTableExtension_Number(id.mini_table_ext())); } return Ptr(::protos::internal::CreateMessage( ext->data.ptr, ::protos::internal::GetArena(message))); diff --git a/upb/message/copy.c b/upb/message/copy.c index 52f8f67767..e0977c4a78 100644 --- a/upb/message/copy.c +++ b/upb/message/copy.c @@ -184,8 +184,9 @@ static bool upb_Clone_ExtensionValue( upb_Arena* arena) { dest->data = source->data; return upb_Clone_MessageValue( - &dest->data, upb_MiniTableField_CType(&mini_table_ext->field), - mini_table_ext->sub.submsg, arena); + &dest->data, + upb_MiniTableField_CType(&mini_table_ext->UPB_PRIVATE(field)), + upb_MiniTableExtension_GetSubMessage(mini_table_ext), arena); } upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, @@ -259,7 +260,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, const upb_Message_Extension* ext = _upb_Message_Getexts(src, &ext_count); for (size_t i = 0; i < ext_count; ++i) { const upb_Message_Extension* msg_ext = &ext[i]; - const upb_MiniTableField* field = &msg_ext->ext->field; + const upb_MiniTableField* field = &msg_ext->ext->UPB_PRIVATE(field); upb_Message_Extension* dst_ext = _upb_Message_GetOrCreateExtension(dst, msg_ext->ext, arena); if (!dst_ext) return NULL; @@ -272,7 +273,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, UPB_ASSERT(msg_array); upb_Array* cloned_array = upb_Array_DeepClone(msg_array, upb_MiniTableField_CType(field), - msg_ext->ext->sub.submsg, arena); + msg_ext->ext->UPB_PRIVATE(sub).submsg, arena); if (!cloned_array) { return NULL; } diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h index 5ace3fcfa8..65f301d506 100644 --- a/upb/message/internal/accessors.h +++ b/upb/message/internal/accessors.h @@ -217,7 +217,7 @@ UPB_INLINE void _upb_MiniTable_CopyFieldData(void* to, const void* from, UPB_INLINE bool _upb_Message_HasExtensionField( const upb_Message* msg, const upb_MiniTableExtension* ext) { - UPB_ASSERT(upb_MiniTableField_HasPresence(&ext->field)); + UPB_ASSERT(upb_MiniTableField_HasPresence(&ext->UPB_PRIVATE(field))); return _upb_Message_Getext(msg, ext) != NULL; } @@ -249,12 +249,12 @@ static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField( UPB_INLINE void _upb_Message_GetExtensionField( const upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* default_val, void* val) { - UPB_ASSUME(upb_MiniTableField_IsExtension(&mt_ext->field)); + UPB_ASSUME(upb_MiniTableField_IsExtension(&mt_ext->UPB_PRIVATE(field))); const upb_Message_Extension* ext = _upb_Message_Getext(msg, mt_ext); if (ext) { - _upb_MiniTable_CopyFieldData(val, &ext->data, &mt_ext->field); + _upb_MiniTable_CopyFieldData(val, &ext->data, &mt_ext->UPB_PRIVATE(field)); } else { - _upb_MiniTable_CopyFieldData(val, default_val, &mt_ext->field); + _upb_MiniTable_CopyFieldData(val, default_val, &mt_ext->UPB_PRIVATE(field)); } } @@ -300,7 +300,7 @@ UPB_INLINE bool _upb_Message_SetExtensionField( upb_Message_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a); if (!ext) return false; - _upb_MiniTable_CopyFieldData(&ext->data, val, &mt_ext->field); + _upb_MiniTable_CopyFieldData(&ext->data, val, &mt_ext->UPB_PRIVATE(field)); return true; } diff --git a/upb/message/map_sorter.c b/upb/message/map_sorter.c index 6b396a4e6b..42dc4b5ec3 100644 --- a/upb/message/map_sorter.c +++ b/upb/message/map_sorter.c @@ -8,6 +8,7 @@ #include "upb/message/internal/map_sorter.h" #include "upb/base/internal/log2.h" +#include "upb/mini_table/extension.h" // Must be last. #include "upb/port/def.inc" @@ -126,8 +127,8 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type, static int _upb_mapsorter_cmpext(const void* _a, const void* _b) { const upb_Message_Extension* const* a = _a; const upb_Message_Extension* const* b = _b; - uint32_t a_num = (*a)->ext->field.number; - uint32_t b_num = (*b)->ext->field.number; + uint32_t a_num = upb_MiniTableExtension_Number((*a)->ext); + uint32_t b_num = upb_MiniTableExtension_Number((*b)->ext); assert(a_num != b_num); return a_num < b_num ? -1 : 1; } diff --git a/upb/message/promote.c b/upb/message/promote.c index 5bb84b12d3..f9efd5fc71 100644 --- a/upb/message/promote.c +++ b/upb/message/promote.c @@ -69,14 +69,15 @@ upb_GetExtension_Status upb_MiniTable_GetOrPromoteExtension( upb_Message* msg, const upb_MiniTableExtension* ext_table, int decode_options, upb_Arena* arena, const upb_Message_Extension** extension) { - UPB_ASSERT(upb_MiniTableField_CType(&ext_table->field) == kUpb_CType_Message); + UPB_ASSERT(upb_MiniTableField_CType(upb_MiniTableExtension_AsField( + ext_table)) == kUpb_CType_Message); *extension = _upb_Message_Getext(msg, ext_table); if (*extension) { return kUpb_GetExtension_Ok; } // Check unknown fields, if available promote. - int field_number = ext_table->field.number; + int field_number = upb_MiniTableExtension_Number(ext_table); upb_FindUnknownRet result = upb_MiniTable_FindUnknown(msg, field_number, 0); if (result.status != kUpb_FindUnknown_Ok) { return kUpb_GetExtension_NotPresent; @@ -84,7 +85,8 @@ upb_GetExtension_Status upb_MiniTable_GetOrPromoteExtension( size_t len; size_t ofs = result.ptr - upb_Message_GetUnknown(msg, &len); // Decode and promote from unknown. - const upb_MiniTable* extension_table = ext_table->sub.submsg; + const upb_MiniTable* extension_table = + upb_MiniTableExtension_GetSubMessage(ext_table); upb_UnknownToMessageRet parse_result = upb_MiniTable_ParseUnknownMessage( result.ptr, result.len, extension_table, /* base_message= */ NULL, decode_options, arena); diff --git a/upb/message/promote_test.cc b/upb/message/promote_test.cc index 0d279d44f3..dc7191a3ed 100644 --- a/upb/message/promote_test.cc +++ b/upb/message/promote_test.cc @@ -37,6 +37,7 @@ #include "upb/mini_descriptor/internal/encode.hpp" #include "upb/mini_descriptor/internal/modifiers.h" #include "upb/mini_descriptor/link.h" +#include "upb/mini_table/extension.h" #include "upb/mini_table/field.h" #include "upb/mini_table/message.h" #include "upb/mini_table/sub.h" @@ -72,11 +73,15 @@ TEST(GeneratedCode, FindUnknown) { arena); upb_FindUnknownRet result = upb_MiniTable_FindUnknown( - base_msg, upb_test_ModelExtension1_model_ext_ext.field.number, 0); + base_msg, + upb_MiniTableExtension_Number(&upb_test_ModelExtension1_model_ext_ext), + 0); EXPECT_EQ(kUpb_FindUnknown_Ok, result.status); result = upb_MiniTable_FindUnknown( - base_msg, upb_test_ModelExtension2_model_ext_ext.field.number, 0); + base_msg, + upb_MiniTableExtension_Number(&upb_test_ModelExtension2_model_ext_ext), + 0); EXPECT_EQ(kUpb_FindUnknown_NotPresent, result.status); upb_Arena_Free(arena); diff --git a/upb/mini_descriptor/decode.c b/upb/mini_descriptor/decode.c index 1470b3f56e..7d977086c5 100644 --- a/upb/mini_descriptor/decode.c +++ b/upb/mini_descriptor/decode.c @@ -805,7 +805,7 @@ static const char* upb_MtDecoder_DoBuildMiniTableExtension( &count, &sub_counts); if (!ret || count != 1) return NULL; - upb_MiniTableField* f = &ext->field; + upb_MiniTableField* f = &ext->UPB_PRIVATE(field); f->mode |= kUpb_LabelFlags_IsExtension; f->offset = 0; @@ -819,8 +819,8 @@ static const char* upb_MtDecoder_DoBuildMiniTableExtension( if ((f->mode & kUpb_FieldMode_Mask) == kUpb_FieldMode_Array) return NULL; } - ext->extendee = extendee; - ext->sub = sub; + ext->UPB_PRIVATE(extendee) = extendee; + ext->UPB_PRIVATE(sub) = sub; return ret; } diff --git a/upb/mini_table/extension.h b/upb/mini_table/extension.h index 7fde3158c7..0f3075278a 100644 --- a/upb/mini_table/extension.h +++ b/upb/mini_table/extension.h @@ -8,8 +8,43 @@ #ifndef UPB_MINI_TABLE_EXTENSION_H_ #define UPB_MINI_TABLE_EXTENSION_H_ +#include + #include "upb/mini_table/internal/extension.h" +// Must be last. +#include "upb/port/def.inc" + typedef struct upb_MiniTableExtension upb_MiniTableExtension; +#ifdef __cplusplus +extern "C" { +#endif + +UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTableExtension_AsField( + const upb_MiniTableExtension* e) { + return UPB_PRIVATE(_upb_MiniTableExtension_AsField)(e); +} + +UPB_API_INLINE uint32_t +upb_MiniTableExtension_Number(const upb_MiniTableExtension* e) { + return UPB_PRIVATE(_upb_MiniTableExtension_Number)(e); +} + +UPB_API_INLINE const struct upb_MiniTable* upb_MiniTableExtension_GetSubMessage( + const upb_MiniTableExtension* e) { + return UPB_PRIVATE(_upb_MiniTableExtension_GetSubMessage)(e); +} + +UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage( + upb_MiniTableExtension* e, const struct upb_MiniTable* m) { + return UPB_PRIVATE(_upb_MiniTableExtension_SetSubMessage)(e, m); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port/undef.inc" + #endif /* UPB_MINI_TABLE_EXTENSION_H_ */ diff --git a/upb/mini_table/extension_registry.c b/upb/mini_table/extension_registry.c index 3c3f58f583..f5b118f185 100644 --- a/upb/mini_table/extension_registry.c +++ b/upb/mini_table/extension_registry.c @@ -7,8 +7,14 @@ #include "upb/mini_table/extension_registry.h" +#include +#include +#include + #include "upb/hash/str_table.h" +#include "upb/mem/arena.h" #include "upb/mini_table/extension.h" +#include "upb/mini_table/message.h" // Must be last. #include "upb/port/def.inc" @@ -36,7 +42,7 @@ upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena) { UPB_API bool upb_ExtensionRegistry_Add(upb_ExtensionRegistry* r, const upb_MiniTableExtension* e) { char buf[EXTREG_KEY_SIZE]; - extreg_key(buf, e->extendee, e->field.number); + extreg_key(buf, e->UPB_PRIVATE(extendee), upb_MiniTableExtension_Number(e)); if (upb_strtable_lookup2(&r->exts, buf, EXTREG_KEY_SIZE, NULL)) return false; return upb_strtable_insert(&r->exts, buf, EXTREG_KEY_SIZE, upb_value_constptr(e), r->arena); @@ -57,7 +63,8 @@ failure: for (end = e, e = start; e < end; e++) { const upb_MiniTableExtension* ext = *e; char buf[EXTREG_KEY_SIZE]; - extreg_key(buf, ext->extendee, ext->field.number); + extreg_key(buf, ext->UPB_PRIVATE(extendee), + upb_MiniTableExtension_Number(ext)); upb_strtable_remove2(&r->exts, buf, EXTREG_KEY_SIZE, NULL); } return false; diff --git a/upb/mini_table/internal/extension.h b/upb/mini_table/internal/extension.h index f052fe6d20..b05932458c 100644 --- a/upb/mini_table/internal/extension.h +++ b/upb/mini_table/internal/extension.h @@ -8,6 +8,8 @@ #ifndef UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ #define UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ +#include + #include "upb/mini_table/internal/field.h" #include "upb/mini_table/internal/sub.h" @@ -16,12 +18,41 @@ struct upb_MiniTableExtension { // Do not move this field. We need to be able to alias pointers. - struct upb_MiniTableField field; + struct upb_MiniTableField UPB_PRIVATE(field); - const struct upb_MiniTable* extendee; - union upb_MiniTableSub sub; // NULL unless submessage or proto2 enum + const struct upb_MiniTable* UPB_PRIVATE(extendee); + union upb_MiniTableSub UPB_PRIVATE(sub); // NULL unless submsg or proto2 enum }; +#ifdef __cplusplus +extern "C" { +#endif + +UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE( + _upb_MiniTableExtension_AsField)(const struct upb_MiniTableExtension* e) { + return (const struct upb_MiniTableField*)&e->UPB_PRIVATE(field); +} + +UPB_INLINE uint32_t UPB_PRIVATE(_upb_MiniTableExtension_Number)( + const struct upb_MiniTableExtension* e) { + return e->UPB_PRIVATE(field).number; +} + +UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE( + _upb_MiniTableExtension_GetSubMessage)( + const struct upb_MiniTableExtension* e) { + return e->UPB_PRIVATE(sub).submsg; +} + +UPB_INLINE void UPB_PRIVATE(_upb_MiniTableExtension_SetSubMessage)( + struct upb_MiniTableExtension* e, const struct upb_MiniTable* m) { + e->UPB_PRIVATE(sub).submsg = m; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + #include "upb/port/undef.inc" #endif /* UPB_MINI_TABLE_INTERNAL_EXTENSION_H_ */ diff --git a/upb/reflection/field_def.c b/upb/reflection/field_def.c index 87d989e96a..a6d287cc7e 100644 --- a/upb/reflection/field_def.c +++ b/upb/reflection/field_def.c @@ -728,7 +728,8 @@ static void _upb_FieldDef_CreateExt(upb_DefBuilder* ctx, const char* prefix, f->layout_index = ctx->ext_count++; if (ctx->layout) { - UPB_ASSERT(_upb_FieldDef_ExtensionMiniTable(f)->field.number == f->number_); + UPB_ASSERT(upb_MiniTableExtension_Number( + _upb_FieldDef_ExtensionMiniTable(f)) == f->number_); } } @@ -923,7 +924,7 @@ void _upb_FieldDef_BuildMiniTableExtension(upb_DefBuilder* ctx, const upb_MiniTableExtension* ext = _upb_FieldDef_ExtensionMiniTable(f); if (ctx->layout) { - UPB_ASSERT(upb_FieldDef_Number(f) == ext->field.number); + UPB_ASSERT(upb_FieldDef_Number(f) == upb_MiniTableExtension_Number(ext)); } else { upb_StringView desc; if (!upb_FieldDef_MiniDescriptorEncode(f, ctx->tmp_arena, &desc)) { diff --git a/upb/test/BUILD b/upb/test/BUILD index 93661f452e..e07b8d5dbd 100644 --- a/upb/test/BUILD +++ b/upb/test/BUILD @@ -164,6 +164,7 @@ cc_library( visibility = ["//upb:__subpackages__"], deps = [ "//upb:base", + "//upb:mem", "//upb:message", "//upb:mini_descriptor", "//upb:mini_table", diff --git a/upb/test/fuzz_util.cc b/upb/test/fuzz_util.cc index 714fcac006..299ab24c58 100644 --- a/upb/test/fuzz_util.cc +++ b/upb/test/fuzz_util.cc @@ -7,11 +7,20 @@ #include "upb/test/fuzz_util.h" +#include + +#include + +#include "upb/base/descriptor_constants.h" #include "upb/base/status.hpp" -#include "upb/message/message.h" +#include "upb/mem/arena.h" #include "upb/mini_descriptor/decode.h" +#include "upb/mini_table/enum.h" #include "upb/mini_table/extension.h" #include "upb/mini_table/extension_registry.h" +#include "upb/mini_table/field.h" +#include "upb/mini_table/message.h" +#include "upb/mini_table/sub.h" // Must be last #include "upb/port/def.inc" @@ -87,16 +96,17 @@ void Builder::BuildEnums() { } bool Builder::LinkExtension(upb_MiniTableExtension* ext) { - upb_MiniTableField* field = &ext->field; + upb_MiniTableField* field = + (upb_MiniTableField*)upb_MiniTableExtension_AsField(ext); if (upb_MiniTableField_CType(field) == kUpb_CType_Message) { auto mt = NextMiniTable(); if (!mt) field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_Int32; - ext->sub.submsg = mt; + ext->UPB_PRIVATE(sub).submsg = mt; } if (upb_MiniTableField_IsClosedEnum(field)) { auto et = NextEnumTable(); if (!et) field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_Int32; - ext->sub.subenum = et; + ext->UPB_PRIVATE(sub).subenum = et; } return true; } @@ -120,7 +130,8 @@ void Builder::BuildExtensions(upb_ExtensionRegistry** exts) { status.ptr()); if (!ptr) break; if (!LinkExtension(ext)) continue; - if (upb_ExtensionRegistry_Lookup(*exts, ext->extendee, ext->field.number)) + if (upb_ExtensionRegistry_Lookup(*exts, ext->UPB_PRIVATE(extendee), + upb_MiniTableExtension_Number(ext))) continue; upb_ExtensionRegistry_AddArray( *exts, const_cast(&ext), 1); diff --git a/upb/wire/decode.c b/upb/wire/decode.c index c2525ea6ac..47068914dc 100644 --- a/upb/wire/decode.c +++ b/upb/wire/decode.c @@ -783,9 +783,11 @@ static void upb_Decoder_AddKnownMessageSetItem( _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory); } upb_Message* submsg = _upb_Decoder_NewSubMessage( - d, &ext->ext->sub, &ext->ext->field, (upb_TaggedMessagePtr*)&ext->data); - upb_DecodeStatus status = upb_Decode(data, size, submsg, item_mt->sub.submsg, - d->extreg, d->options, &d->arena); + d, &ext->ext->UPB_PRIVATE(sub), upb_MiniTableExtension_AsField(ext->ext), + (upb_TaggedMessagePtr*)&ext->data); + upb_DecodeStatus status = upb_Decode( + data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt), + d->extreg, d->options, &d->arena); if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); } @@ -915,7 +917,7 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d, case kUpb_ExtMode_Extendable: { const upb_MiniTableExtension* ext = upb_ExtensionRegistry_Lookup(d->extreg, t, field_number); - if (ext) return &ext->field; + if (ext) return upb_MiniTableExtension_AsField(ext); break; } case kUpb_ExtMode_IsMessageSet: @@ -1123,7 +1125,7 @@ static const char* _upb_Decoder_DecodeKnownField( } d->unknown_msg = msg; msg = &ext->data; - subs = &ext->ext->sub; + subs = &ext->ext->UPB_PRIVATE(sub); } switch (mode & kUpb_FieldMode_Mask) { diff --git a/upb/wire/encode.c b/upb/wire/encode.c index 212ec05410..40aeea2630 100644 --- a/upb/wire/encode.c +++ b/upb/wire/encode.c @@ -28,6 +28,7 @@ #include "upb/message/internal/map_sorter.h" #include "upb/message/message.h" #include "upb/message/tagged_ptr.h" +#include "upb/mini_table/extension.h" #include "upb/mini_table/field.h" #include "upb/mini_table/internal/field.h" #include "upb/mini_table/internal/message.h" @@ -514,10 +515,11 @@ static void encode_msgset_item(upb_encstate* e, const upb_Message_Extension* ext) { size_t size; encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup); - encode_message(e, ext->data.ptr, ext->ext->sub.submsg, &size); + encode_message(e, ext->data.ptr, + upb_MiniTableExtension_GetSubMessage(ext->ext), &size); encode_varint(e, size); encode_tag(e, kUpb_MsgSet_Message, kUpb_WireType_Delimited); - encode_varint(e, ext->ext->field.number); + encode_varint(e, upb_MiniTableExtension_Number(ext->ext)); encode_tag(e, kUpb_MsgSet_TypeId, kUpb_WireType_Varint); encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_StartGroup); } @@ -527,7 +529,8 @@ static void encode_ext(upb_encstate* e, const upb_Message_Extension* ext, if (UPB_UNLIKELY(is_message_set)) { encode_msgset_item(e, ext); } else { - encode_field(e, &ext->data, &ext->ext->sub, &ext->ext->field); + encode_field(e, &ext->data, &ext->ext->UPB_PRIVATE(sub), + &ext->ext->UPB_PRIVATE(field)); } } diff --git a/upb_generator/protoc-gen-upb.cc b/upb_generator/protoc-gen-upb.cc index f5c5056739..f764cd1551 100644 --- a/upb_generator/protoc-gen-upb.cc +++ b/upb_generator/protoc-gen-upb.cc @@ -282,8 +282,8 @@ void GenerateExtensionInHeader(const DefPoolPair& pools, upb::FieldDefPtr ext, R"cc( UPB_INLINE $0 $1_$2(const struct $3* msg) { const upb_MiniTableExtension* ext = &$4; - UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(&ext->field)); - UPB_ASSUME(_upb_MiniTableField_GetRep(&ext->field) == $5); + UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(&ext->UPB_PRIVATE(field))); + UPB_ASSUME(_upb_MiniTableField_GetRep(&ext->UPB_PRIVATE(field)) == $5); $0 default_val = $6; $0 ret; _upb_Message_GetExtensionField(msg, ext, &default_val, &ret); @@ -297,8 +297,8 @@ void GenerateExtensionInHeader(const DefPoolPair& pools, upb::FieldDefPtr ext, R"cc( UPB_INLINE void $1_set_$2(struct $3* msg, $0 val, upb_Arena* arena) { const upb_MiniTableExtension* ext = &$4; - UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(&ext->field)); - UPB_ASSUME(_upb_MiniTableField_GetRep(&ext->field) == $5); + UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(&ext->UPB_PRIVATE(field))); + UPB_ASSUME(_upb_MiniTableField_GetRep(&ext->UPB_PRIVATE(field)) == $5); bool ok = _upb_Message_SetExtensionField(msg, ext, &val, arena); UPB_ASSERT(ok); }