diff --git a/upb/collections/array_internal.h b/upb/collections/array_internal.h index 38c90cdc10..51964e9b23 100644 --- a/upb/collections/array_internal.h +++ b/upb/collections/array_internal.h @@ -39,12 +39,14 @@ extern "C" { #endif +// LINT.IfChange(struct_definition) // Our internal representation for repeated fields. struct upb_Array { uintptr_t data; /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */ size_t size; /* The number of elements in the array. */ size_t capacity; /* Allocated storage. Measured in elements. */ }; +// LINT.ThenChange(GoogleInternalName1) UPB_INLINE const void* _upb_array_constptr(const upb_Array* arr) { UPB_ASSERT((arr->data & 7) <= 4); diff --git a/upb/msg_internal.h b/upb/msg_internal.h index 80ee776881..315390fbbb 100644 --- a/upb/msg_internal.h +++ b/upb/msg_internal.h @@ -340,18 +340,25 @@ const upb_Message_Extension* _upb_Message_Getext( void _upb_Message_Clearext(upb_Message* msg, const upb_MiniTableExtension* ext); +// LINT.IfChange(presence_logic) + /** Hasbit access *************************************************************/ +UPB_INLINE size_t _upb_hasbit_ofs(size_t idx) { return idx / 8; } + +UPB_INLINE char _upb_hasbit_mask(size_t idx) { return 1 << (idx % 8); } + UPB_INLINE bool _upb_hasbit(const upb_Message* msg, size_t idx) { - return (*UPB_PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0; + return (*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), const char) & + _upb_hasbit_mask(idx)) != 0; } UPB_INLINE void _upb_sethas(const upb_Message* msg, size_t idx) { - (*UPB_PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8)); + (*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) |= _upb_hasbit_mask(idx); } UPB_INLINE void _upb_clearhas(const upb_Message* msg, size_t idx) { - (*UPB_PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8))); + (*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) &= ~_upb_hasbit_mask(idx); } UPB_INLINE size_t _upb_Message_Hasidx(const upb_MiniTableField* f) { @@ -403,6 +410,8 @@ UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_Message* msg, size_t ofs) { return *UPB_PTR_AT(msg, ofs, const upb_Message*) != NULL; } +// LINT.ThenChange(GoogleInternalName2) + /* Map entries aren't actually stored, they are only used during parsing. For * parsing, it helps a lot if all map entry messages have the same layout. * The compiler and def.c must ensure that all map entries have this layout. */ diff --git a/upb/string_view.h b/upb/string_view.h index 953afb09c4..bc735d9cd2 100644 --- a/upb/string_view.h +++ b/upb/string_view.h @@ -37,10 +37,12 @@ extern "C" { #endif +// LINT.IfChange(struct_definition) typedef struct { const char* data; size_t size; } upb_StringView; +// LINT.ThenChange(GoogleInternalName0) UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data, size_t size) {