Added UPB_ASSERT() that helps avoid unused var warnings.

* Added UPB_ASSERT() that helps avoid unused var warnings.

* Addressed PR comments.

* Fixed assert in the JIT.
pull/13171/head
Joshua Haberman 9 years ago
parent e16ed470be
commit fa338b70a6
  1. 2
      tests/json/test.upbdefs.c
  2. 92
      tests/json/test.upbdefs.h
  3. 6
      tests/pb/test_decoder.cc
  4. 2
      tests/test_util.h
  5. 7
      tools/dump_cinit.lua
  6. 16
      upb/bindings/googlepb/bridge.cc
  7. 4
      upb/bindings/googlepb/bridge.h
  8. 22
      upb/bindings/googlepb/proto1.cc
  9. 38
      upb/bindings/googlepb/proto2.cc
  10. 12
      upb/bindings/lua/upb.c
  11. 16
      upb/bindings/python/upb.c
  12. 22
      upb/bindings/ruby/upb.c
  13. 4
      upb/bindings/stdc/io.c
  14. 100
      upb/def.c
  15. 12
      upb/def.h
  16. 2
      upb/descriptor/descriptor.upbdefs.c
  17. 264
      upb/descriptor/descriptor.upbdefs.h
  18. 32
      upb/descriptor/reader.c
  19. 22
      upb/handlers-inl.h
  20. 34
      upb/handlers.c
  21. 2
      upb/handlers.h
  22. 57
      upb/json/parser.c
  23. 58
      upb/json/parser.rl
  24. 11
      upb/json/printer.c
  25. 28
      upb/pb/compile_decoder.c
  26. 18
      upb/pb/compile_decoder_x64.c
  27. 12
      upb/pb/compile_decoder_x64.dasc
  28. 12
      upb/pb/compile_decoder_x64.h
  29. 59
      upb/pb/decoder.c
  30. 9
      upb/pb/encoder.c
  31. 2
      upb/pb/textprinter.c
  32. 4
      upb/pb/varint.int.h
  33. 78
      upb/refcounted.c
  34. 6
      upb/refcounted.h
  35. 2
      upb/shim/shim.c
  36. 18
      upb/symtab.c
  37. 52
      upb/table.c
  38. 3
      upb/table.int.h
  39. 2
      upb/upb.c
  40. 19
      upb/upb.h

@ -6,8 +6,6 @@
* Do not edit -- your changes will be discarded when the file is * Do not edit -- your changes will be discarded when the file is
* regenerated. */ * regenerated. */
#include <assert.h>
#include "upb/def.h" #include "upb/def.h"
#include "upb/structdefs.int.h" #include "upb/structdefs.int.h"

@ -73,43 +73,43 @@ UPB_INLINE bool upbdefs_upb_test_json_MyEnum_is(const upb_enumdef *e) {
/* Functions to get a fielddef from a msgdef reference. */ /* Functions to get a fielddef from a msgdef reference. */
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_SubMessage_f_foo(const upb_msgdef *m) { assert(upbdefs_upb_test_json_SubMessage_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_SubMessage_f_foo(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_SubMessage_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_bool_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 22); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_bool_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 22); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_int32_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 21); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_int32_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 21); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 24); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 24); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 23); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 23); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 25); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 25); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 20); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 20); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 7); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bytes(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bytes(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_enum(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_enum(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 9); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 17); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 17); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bytes(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 16); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bytes(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 16); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_enum(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 19); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_enum(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 19); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 11); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 11); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 12); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 12); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 18); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 18); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 15); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 15); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 13); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 13); }
UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 14); } UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 14); }
UPB_END_EXTERN_C UPB_END_EXTERN_C
@ -124,7 +124,7 @@ class MyEnum : public ::upb::reffed_ptr<const ::upb::EnumDef> {
public: public:
MyEnum(const ::upb::EnumDef* e, const void *ref_donor = NULL) MyEnum(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_upb_test_json_MyEnum_is(e)); UPB_ASSERT(upbdefs_upb_test_json_MyEnum_is(e));
} }
static MyEnum get() { static MyEnum get() {
const ::upb::EnumDef* e = upbdefs_upb_test_json_MyEnum_get(&e); const ::upb::EnumDef* e = upbdefs_upb_test_json_MyEnum_get(&e);
@ -136,7 +136,7 @@ class SubMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
SubMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL) SubMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_SubMessage_is(m)); UPB_ASSERT(upbdefs_upb_test_json_SubMessage_is(m));
} }
static SubMessage get() { static SubMessage get() {
@ -149,7 +149,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
TestMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL) TestMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m));
} }
static TestMessage get() { static TestMessage get() {
@ -161,7 +161,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapBoolStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapBoolStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m));
} }
static MapBoolStringEntry get() { static MapBoolStringEntry get() {
@ -174,7 +174,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapInt32StringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapInt32StringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m));
} }
static MapInt32StringEntry get() { static MapInt32StringEntry get() {
@ -187,7 +187,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapStringBoolEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapStringBoolEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m));
} }
static MapStringBoolEntry get() { static MapStringBoolEntry get() {
@ -200,7 +200,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapStringInt32Entry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapStringInt32Entry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m));
} }
static MapStringInt32Entry get() { static MapStringInt32Entry get() {
@ -213,7 +213,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapStringMsgEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapStringMsgEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m));
} }
static MapStringMsgEntry get() { static MapStringMsgEntry get() {
@ -226,7 +226,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MapStringStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) MapStringStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m));
} }
static MapStringStringEntry get() { static MapStringStringEntry get() {

@ -116,11 +116,11 @@ void vappendf(string* str, const char *format, va_list args) {
int count = vsnprintf(NULL, 0, format, args); int count = vsnprintf(NULL, 0, format, args);
if (count >= 0) if (count >= 0)
{ {
assert(count < 32768); UPB_ASSERT(count < 32768);
char *buffer = new char[count + 1]; char *buffer = new char[count + 1];
assert(buffer); UPB_ASSERT(buffer);
count = vsnprintf(buffer, count + 1, format, copy); count = vsnprintf(buffer, count + 1, format, copy);
assert(count >= 0); UPB_ASSERT(count >= 0);
str->append(buffer, count); str->append(buffer, count);
delete [] buffer; delete [] buffer;
} }

@ -123,7 +123,7 @@ class VerboseParserEnvironment {
skipped_with_null_ = true; skipped_with_null_ = true;
} else { } else {
buf2 = (char*)malloc(bytes); buf2 = (char*)malloc(bytes);
assert(buf2); UPB_ASSERT(buf2);
memcpy(buf2, buf_ + ofs_, bytes); memcpy(buf2, buf_ + ofs_, bytes);
} }

@ -407,7 +407,6 @@ local function dump_defs_c(filedef, append)
-- Emit forward declarations. -- Emit forward declarations.
emit_file_warning(filedef, append) emit_file_warning(filedef, append)
append('#include <assert.h>\n\n')
append('#include "upb/def.h"\n') append('#include "upb/def.h"\n')
append('#include "upb/structdefs.int.h"\n\n') append('#include "upb/structdefs.int.h"\n\n')
append("static const upb_msgdef %s;\n", linktab:cdecl(upb.DEF_MSG)) append("static const upb_msgdef %s;\n", linktab:cdecl(upb.DEF_MSG))
@ -639,7 +638,7 @@ local function print_message(def, map, indent, append)
append("%s %s(const ::upb::MessageDef* m, const void *ref_donor = NULL)\n", append("%s %s(const ::upb::MessageDef* m, const void *ref_donor = NULL)\n",
indent, def:name()) indent, def:name())
append("%s : reffed_ptr(m, ref_donor) {\n", indent) append("%s : reffed_ptr(m, ref_donor) {\n", indent)
append("%s assert(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name())) append("%s UPB_ASSERT(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name()))
append("%s }\n", indent) append("%s }\n", indent)
append("\n") append("\n")
append("%s static %s get() {\n", indent, def:name()) append("%s static %s get() {\n", indent, def:name())
@ -659,7 +658,7 @@ local function print_enum(def, indent, append)
append("%s %s(const ::upb::EnumDef* e, const void *ref_donor = NULL)\n", append("%s %s(const ::upb::EnumDef* e, const void *ref_donor = NULL)\n",
indent, def:name()) indent, def:name())
append("%s : reffed_ptr(e, ref_donor) {\n", indent) append("%s : reffed_ptr(e, ref_donor) {\n", indent)
append("%s assert(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name())) append("%s UPB_ASSERT(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name()))
append("%s }\n", indent) append("%s }\n", indent)
append("%s static %s get() {\n", indent, def:name()) append("%s static %s get() {\n", indent, def:name())
append("%s const ::upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name())) append("%s const ::upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name()))
@ -748,7 +747,7 @@ local function dump_defs_h(file, append, linktab)
local msg_cident = to_cident(f:containing_type():full_name()) local msg_cident = to_cident(f:containing_type():full_name())
local field_cident = to_cident(f:name()) local field_cident = to_cident(f:name())
append("UPB_INLINE const upb_fielddef *upbdefs_%s_f_%s(const upb_msgdef *m) {" .. append("UPB_INLINE const upb_fielddef *upbdefs_%s_f_%s(const upb_msgdef *m) {" ..
" assert(upbdefs_%s_is(m));" .. " UPB_ASSERT(upbdefs_%s_is(m));" ..
" return upb_msgdef_itof(m, %d); }\n", " return upb_msgdef_itof(m, %d); }\n",
msg_cident, field_cident, msg_cident, f:number()) msg_cident, field_cident, msg_cident, f:number())
end end

@ -18,7 +18,7 @@
#define ASSERT_STATUS(status) do { \ #define ASSERT_STATUS(status) do { \
if (!upb_ok(status)) { \ if (!upb_ok(status)) { \
fprintf(stderr, "upb status failure: %s\n", upb_status_errmsg(status)); \ fprintf(stderr, "upb status failure: %s\n", upb_status_errmsg(status)); \
assert(upb_ok(status)); \ UPB_ASSERT(upb_ok(status)); \
} \ } \
} while (0) } while (0)
@ -49,7 +49,7 @@ const goog::Message* TryGetFieldPrototype(const goog::Message& m,
const goog::Message* GetFieldPrototype(const goog::Message& m, const goog::Message* GetFieldPrototype(const goog::Message& m,
const goog::FieldDescriptor* f) { const goog::FieldDescriptor* f) {
const goog::Message* ret = TryGetFieldPrototype(m, f); const goog::Message* ret = TryGetFieldPrototype(m, f);
assert(ret); UPB_ASSERT(ret);
return ret; return ret;
} }
@ -66,7 +66,7 @@ const EnumDef* DefBuilder::GetEnumDef(const goog::EnumDescriptor* ed) {
for (int i = 0; i < ed->value_count(); i++) { for (int i = 0; i < ed->value_count(); i++) {
const goog::EnumValueDescriptor* val = ed->value(i); const goog::EnumValueDescriptor* val = ed->value(i);
bool success = e->AddValue(val->name(), val->number(), &status); bool success = e->AddValue(val->name(), val->number(), &status);
UPB_ASSERT_VAR(success, success); UPB_ASSERT(success);
} }
e->Freeze(&status); e->Freeze(&status);
@ -96,7 +96,7 @@ const MessageDef* DefBuilder::GetMaybeUnfrozenMessageDef(
for (size_t i = 0; i < fields.size(); i++) { for (size_t i = 0; i < fields.size(); i++) {
const goog::FieldDescriptor* proto2_f = fields[i]; const goog::FieldDescriptor* proto2_f = fields[i];
assert(proto2_f); UPB_ASSERT(proto2_f);
md->AddField(NewFieldDef(proto2_f, m), &status); md->AddField(NewFieldDef(proto2_f, m), &status);
} }
ASSERT_STATUS(&status); ASSERT_STATUS(&status);
@ -128,7 +128,7 @@ reffed_ptr<FieldDef> DefBuilder::NewFieldDef(const goog::FieldDescriptor* f,
subm = TryGetFieldPrototype(*m, f); subm = TryGetFieldPrototype(*m, f);
if (upb_f->type() == UPB_TYPE_MESSAGE) { if (upb_f->type() == UPB_TYPE_MESSAGE) {
assert(subm); UPB_ASSERT(subm);
} else if (subm) { } else if (subm) {
// Weak field: subm will be weak prototype even though the proto2 // Weak field: subm will be weak prototype even though the proto2
// descriptor does not indicate a submessage field. // descriptor does not indicate a submessage field.
@ -250,14 +250,14 @@ const Handlers* CodeCache::GetMaybeUnfrozenWriteHandlers(
if (!proto2_f) { if (!proto2_f) {
proto2_f = d->file()->pool()->FindExtensionByNumber(d, upb_f->number()); proto2_f = d->file()->pool()->FindExtensionByNumber(d, upb_f->number());
} }
assert(proto2_f); UPB_ASSERT(proto2_f);
bool ok = WriteHandlers::AddFieldHandler(m, proto2_f, h); bool ok = WriteHandlers::AddFieldHandler(m, proto2_f, h);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
if (upb_f->type() == UPB_TYPE_MESSAGE) { if (upb_f->type() == UPB_TYPE_MESSAGE) {
const goog::Message* prototype = GetFieldPrototype(m, proto2_f); const goog::Message* prototype = GetFieldPrototype(m, proto2_f);
assert(prototype); UPB_ASSERT(prototype);
const upb::Handlers* sub_handlers = const upb::Handlers* sub_handlers =
GetMaybeUnfrozenWriteHandlers(upb_f->message_subdef(), *prototype); GetMaybeUnfrozenWriteHandlers(upb_f->message_subdef(), *prototype);
h->SetSubHandlers(upb_f, sub_handlers); h->SetSubHandlers(upb_f, sub_handlers);

@ -128,7 +128,7 @@ class DefBuilder {
template <class T> template <class T>
T* AddToCache(const void *proto2_descriptor, reffed_ptr<T> def) { T* AddToCache(const void *proto2_descriptor, reffed_ptr<T> def) {
assert(def_cache_.find(proto2_descriptor) == def_cache_.end()); UPB_ASSERT(def_cache_.find(proto2_descriptor) == def_cache_.end());
def_cache_[proto2_descriptor] = def; def_cache_[proto2_descriptor] = def;
return def.get(); // Continued lifetime is guaranteed by cache. return def.get(); // Continued lifetime is guaranteed by cache.
} }
@ -207,7 +207,7 @@ class CodeCache {
const MessageDef* md, const ::google::protobuf::Message& m); const MessageDef* md, const ::google::protobuf::Message& m);
Handlers* AddToCache(const MessageDef* md, reffed_ptr<Handlers> handlers) { Handlers* AddToCache(const MessageDef* md, reffed_ptr<Handlers> handlers) {
assert(handlers_cache_.find(md) == handlers_cache_.end()); UPB_ASSERT(handlers_cache_.find(md) == handlers_cache_.end());
handlers_cache_[md] = handlers; handlers_cache_[md] = handlers;
return handlers.get(); // Continue lifetime is guaranteed by the cache. return handlers.get(); // Continue lifetime is guaranteed by the cache.
} }

@ -35,7 +35,7 @@ namespace proto2 { class Arena; }
#include "upb/sink.h" #include "upb/sink.h"
// Unconditionally evaluate, but also assert in debug mode. // Unconditionally evaluate, but also assert in debug mode.
#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0) #define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0)
template <class T> static T* GetPointer(void* message, size_t offset) { template <class T> static T* GetPointer(void* message, size_t offset) {
return reinterpret_cast<T*>(static_cast<char*>(message) + offset); return reinterpret_cast<T*>(static_cast<char*>(message) + offset);
@ -58,7 +58,7 @@ class P2R_Handlers {
dynamic_cast<const _pi::Proto2Reflection*>(base_r); dynamic_cast<const _pi::Proto2Reflection*>(base_r);
if (!r) return false; if (!r) return false;
// Extensions don't exist in proto1. // Extensions don't exist in proto1.
assert(!proto2_f->is_extension()); UPB_ASSERT(!proto2_f->is_extension());
#define PRIMITIVE(name, type_name) \ #define PRIMITIVE(name, type_name) \
case _pi::CREP_REQUIRED_##name: \ case _pi::CREP_REQUIRED_##name: \
@ -107,7 +107,7 @@ class P2R_Handlers {
SetWeakMessageHandlers(proto2_f, m, r, upb_f, h); SetWeakMessageHandlers(proto2_f, m, r, upb_f, h);
return true; return true;
default: default:
assert(false); UPB_ASSERT(false);
return false; return false;
} }
} }
@ -147,10 +147,10 @@ class P2R_Handlers {
} else if (dynamic_cast<const _pi::Proto2Reflection*>(m.GetReflection())) { } else if (dynamic_cast<const _pi::Proto2Reflection*>(m.GetReflection())) {
// Since proto1 has no dynamic message, it must be from the generated // Since proto1 has no dynamic message, it must be from the generated
// factory. // factory.
assert(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE); UPB_ASSERT(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE);
ret = proto2::MessageFactory::generated_factory()->GetPrototype( ret = proto2::MessageFactory::generated_factory()->GetPrototype(
f->message_type()); f->message_type());
assert(ret); UPB_ASSERT(ret);
return ret; return ret;
} else { } else {
return NULL; return NULL;
@ -175,7 +175,7 @@ class P2R_Handlers {
} }
void SetHasbit(void* message) const { void SetHasbit(void* message) const {
assert(!is_repeated_); UPB_ASSERT(!is_repeated_);
uint8_t* byte = GetPointer<uint8_t>(message, hasbyte_); uint8_t* byte = GetPointer<uint8_t>(message, hasbyte_);
*byte |= mask_; *byte |= mask_;
} }
@ -193,13 +193,13 @@ class P2R_Handlers {
upb::Handlers::Type type) { upb::Handlers::Type type) {
upb::Handlers::Selector selector; upb::Handlers::Selector selector;
bool ok = upb::Handlers::GetSelector(f, type, &selector); bool ok = upb::Handlers::GetSelector(f, type, &selector);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return selector; return selector;
} }
static int16_t GetHasbit(const proto2::FieldDescriptor* f, static int16_t GetHasbit(const proto2::FieldDescriptor* f,
const _pi::Proto2Reflection* r) { const _pi::Proto2Reflection* r) {
assert(!f->is_repeated()); UPB_ASSERT(!f->is_repeated());
return (r->layout_->has_bit_offset * 8) + r->GetFieldLayout(f)->has_index; return (r->layout_->has_bit_offset * 8) + r->GetFieldLayout(f)->has_index;
} }
@ -303,7 +303,7 @@ class P2R_Handlers {
const proto2::FieldDescriptor* proto2_f, const _pi::Proto2Reflection* r, const proto2::FieldDescriptor* proto2_f, const _pi::Proto2Reflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
// This type is only used for non-repeated string fields. // This type is only used for non-repeated string fields.
assert(!f->IsSequence()); UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartStringHandler( CHKRET(h->SetStartStringHandler(
f, UpbBind(StartOutOfLineString, new FieldOffset(proto2_f, r)))); f, UpbBind(StartOutOfLineString, new FieldOffset(proto2_f, r))));
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringBuf))); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringBuf)));
@ -452,7 +452,7 @@ class P2R_Handlers {
// around waiting for reuse, which we will not do. // around waiting for reuse, which we will not do.
static void Delete(Type* t) { static void Delete(Type* t) {
UPB_UNUSED(t); UPB_UNUSED(t);
assert(false); UPB_ASSERT(false);
} }
#else #else
static ::proto2::Arena* GetArena(Type* t) { static ::proto2::Arena* GetArena(Type* t) {
@ -470,7 +470,7 @@ class P2R_Handlers {
static void Delete(Type* t, ::proto2::Arena* arena) { static void Delete(Type* t, ::proto2::Arena* arena) {
UPB_UNUSED(t); UPB_UNUSED(t);
UPB_UNUSED(arena); UPB_UNUSED(arena);
assert(false); UPB_ASSERT(false);
} }
static void Merge(const Type& from, Type* to) { static void Merge(const Type& from, Type* to) {
to->MergeFrom(from); to->MergeFrom(from);

@ -21,14 +21,14 @@
namespace { namespace {
template<typename To, typename From> To CheckDownCast(From* f) { template<typename To, typename From> To CheckDownCast(From* f) {
assert(f == NULL || dynamic_cast<To>(f) != NULL); UPB_ASSERT(f == NULL || dynamic_cast<To>(f) != NULL);
return static_cast<To>(f); return static_cast<To>(f);
} }
} }
// Unconditionally evaluate, but also assert in debug mode. // Unconditionally evaluate, but also assert in debug mode.
#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0) #define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0)
namespace upb { namespace upb {
namespace google_google3 { class GMR_Handlers; } namespace google_google3 { class GMR_Handlers; }
@ -222,7 +222,7 @@ case goog::FieldDescriptor::cpptype: \
upb::Handlers::Type type) { upb::Handlers::Type type) {
upb::Handlers::Selector selector; upb::Handlers::Selector selector;
bool ok = upb::Handlers::GetSelector(f, type, &selector); bool ok = upb::Handlers::GetSelector(f, type, &selector);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return selector; return selector;
} }
@ -230,7 +230,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* f, const goog::FieldDescriptor* f,
const goog::internal::GeneratedMessageReflection* r) { const goog::internal::GeneratedMessageReflection* r) {
// proto2 does not store hasbits for repeated fields. // proto2 does not store hasbits for repeated fields.
assert(!f->is_repeated()); UPB_ASSERT(!f->is_repeated());
return (r->has_bits_offset_ * 8) + f->index(); return (r->has_bits_offset_ * 8) + f->index();
} }
@ -238,7 +238,7 @@ case goog::FieldDescriptor::cpptype: \
static size_t GetOneofDiscriminantOffset( static size_t GetOneofDiscriminantOffset(
const goog::FieldDescriptor* f, const goog::FieldDescriptor* f,
const goog::internal::GeneratedMessageReflection* r) { const goog::internal::GeneratedMessageReflection* r) {
assert(f->containing_oneof()); UPB_ASSERT(f->containing_oneof());
return r->oneof_case_offset_ + f->containing_oneof()->index(); return r->oneof_case_offset_ + f->containing_oneof()->index();
} }
#endif #endif
@ -326,7 +326,7 @@ case goog::FieldDescriptor::cpptype: \
} }
void SetHasbit(void* m) const { void SetHasbit(void* m) const {
assert(!is_repeated_); UPB_ASSERT(!is_repeated_);
uint8_t* byte = GetPointer<uint8_t>(m, hasbyte_); uint8_t* byte = GetPointer<uint8_t>(m, hasbyte_);
*byte |= mask_; *byte |= mask_;
} }
@ -470,7 +470,7 @@ case goog::FieldDescriptor::cpptype: \
return ONEOF_TYPE_STRINGPIECE; return ONEOF_TYPE_STRINGPIECE;
#endif #endif
default: default:
assert(false); UPB_ASSERT(false);
return ONEOF_TYPE_NONE; return ONEOF_TYPE_NONE;
} }
} }
@ -582,7 +582,7 @@ case goog::FieldDescriptor::cpptype: \
} }
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF #ifdef GOOGLE_PROTOBUF_HAS_ONEOF
else if (proto2_f->containing_oneof()) { else if (proto2_f->containing_oneof()) {
assert(!proto2_f->is_repeated()); UPB_ASSERT(!proto2_f->is_repeated());
CHKRET(h->SetValueHandler<T>( CHKRET(h->SetValueHandler<T>(
f, UpbBindT(SetOneofPrimitive<T>, f, UpbBindT(SetOneofPrimitive<T>,
new OneofFieldHandlerData(proto2_f, r)))); new OneofFieldHandlerData(proto2_f, r))));
@ -656,7 +656,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f, const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r, const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(!proto2_f->is_extension()); UPB_ASSERT(!proto2_f->is_extension());
scoped_ptr<EnumHandlerData> data(new EnumHandlerData(proto2_f, r, f)); scoped_ptr<EnumHandlerData> data(new EnumHandlerData(proto2_f, r, f));
if (f->IsSequence()) { if (f->IsSequence()) {
CHKRET(h->SetInt32Handler(f, UpbBind(AppendEnum, data.release()))); CHKRET(h->SetInt32Handler(f, UpbBind(AppendEnum, data.release())));
@ -696,7 +696,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f, const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r, const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(proto2_f->is_extension()); UPB_ASSERT(proto2_f->is_extension());
scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r)); scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r));
if (f->IsSequence()) { if (f->IsSequence()) {
CHKRET( CHKRET(
@ -745,11 +745,11 @@ case goog::FieldDescriptor::cpptype: \
const goog::internal::GeneratedMessageReflection* r, const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, const upb::FieldDef* f,
upb::Handlers* h) { upb::Handlers* h) {
assert(!proto2_f->is_extension()); UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(&OnStringBuf<T>))); CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(&OnStringBuf<T>)));
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF #ifdef GOOGLE_PROTOBUF_HAS_ONEOF
if (proto2_f->containing_oneof()) { if (proto2_f->containing_oneof()) {
assert(!f->IsSequence()); UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartStringHandler( CHKRET(h->SetStartStringHandler(
f, UpbBindT(&StartOneofString<T>, f, UpbBindT(&StartOneofString<T>,
new OneofFieldHandlerData(proto2_f, r)))); new OneofFieldHandlerData(proto2_f, r))));
@ -835,7 +835,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f, const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r, const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(proto2_f->is_extension()); UPB_ASSERT(proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(OnStringBuf<T>))); CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(OnStringBuf<T>)));
scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r)); scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r));
if (f->IsSequence()) { if (f->IsSequence()) {
@ -908,7 +908,7 @@ case goog::FieldDescriptor::cpptype: \
new SubMessageHandlerData(proto2_f, r, field_prototype)); new SubMessageHandlerData(proto2_f, r, field_prototype));
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF #ifdef GOOGLE_PROTOBUF_HAS_ONEOF
if (proto2_f->containing_oneof()) { if (proto2_f->containing_oneof()) {
assert(!f->IsSequence()); UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartSubMessageHandler( CHKRET(h->SetStartSubMessageHandler(
f, UpbBind(StartOneofSubMessage, new OneofSubMessageHandlerData( f, UpbBind(StartOneofSubMessage, new OneofSubMessageHandlerData(
proto2_f, r, field_prototype)))); proto2_f, r, field_prototype))));
@ -965,7 +965,7 @@ case goog::FieldDescriptor::cpptype: \
// around waiting for reuse, which we will not do. // around waiting for reuse, which we will not do.
static void Delete(Type* t) { static void Delete(Type* t) {
UPB_UNUSED(t); UPB_UNUSED(t);
assert(false); UPB_ASSERT(false);
} }
#endif // ifdef GOOGLE_PROTOBUF_HAS_ARENAS #endif // ifdef GOOGLE_PROTOBUF_HAS_ARENAS
@ -1089,7 +1089,7 @@ case goog::FieldDescriptor::cpptype: \
// "We could speed this up by using CordReader internals." // "We could speed this up by using CordReader internals."
Cord piece(*source_cord); Cord piece(*source_cord);
piece.RemovePrefix(handle->object_offset() + (buf - handle->buffer())); piece.RemovePrefix(handle->object_offset() + (buf - handle->buffer()));
assert(piece.size() >= n); UPB_ASSERT(piece.size() >= n);
piece.RemoveSuffix(piece.size() - n); piece.RemoveSuffix(piece.size() - n);
c->Append(piece); c->Append(piece);
@ -1102,7 +1102,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::FieldDescriptor* proto2_f, const proto2::FieldDescriptor* proto2_f,
const proto2::internal::GeneratedMessageReflection* r, const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(!proto2_f->is_extension()); UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandler(&OnCordBuf))); CHKRET(h->SetStringHandler(f, UpbMakeHandler(&OnCordBuf)));
if (f->IsSequence()) { if (f->IsSequence()) {
SetStartRepeatedField<Cord>(proto2_f, r, f, h); SetStartRepeatedField<Cord>(proto2_f, r, f, h);
@ -1139,7 +1139,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::FieldDescriptor* proto2_f, const proto2::FieldDescriptor* proto2_f,
const proto2::internal::GeneratedMessageReflection* r, const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(!proto2_f->is_extension()); UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringPieceBuf))); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringPieceBuf)));
if (f->IsSequence()) { if (f->IsSequence()) {
SetStartRepeatedPtrField<proto2::internal::StringPieceField>(proto2_f, r, SetStartRepeatedPtrField<proto2::internal::StringPieceField>(proto2_f, r,
@ -1194,7 +1194,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::Message& m, const proto2::Message& m,
const proto2::internal::GeneratedMessageReflection* r, const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) { const upb::FieldDef* f, upb::Handlers* h) {
assert(!proto2_f->is_repeated()); UPB_ASSERT(!proto2_f->is_repeated());
const goog::Message* field_prototype = GetFieldPrototype(m, proto2_f); const goog::Message* field_prototype = GetFieldPrototype(m, proto2_f);
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnLazyFieldBuf))); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnLazyFieldBuf)));
if (proto2_f->is_extension()) { if (proto2_f->is_extension()) {

@ -141,7 +141,7 @@ static void *newudata_with_userval(lua_State *L, size_t size,
/* Set metatable. */ /* Set metatable. */
luaL_getmetatable(L, type); luaL_getmetatable(L, type);
assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
lua_newtable(L); lua_newtable(L);
@ -322,7 +322,7 @@ bool lupb_refcounted_pushwrapper(lua_State *L, const upb_refcounted *obj,
/* Lookup our cache in the registry (we don't put our objects in the registry /* Lookup our cache in the registry (we don't put our objects in the registry
* directly because we need our cache to be a weak table). */ * directly because we need our cache to be a weak table). */
lua_getfield(L, LUA_REGISTRYINDEX, LUPB_OBJCACHE); lua_getfield(L, LUA_REGISTRYINDEX, LUPB_OBJCACHE);
assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
lua_pushlightuserdata(L, (void*)obj); lua_pushlightuserdata(L, (void*)obj);
lua_rawget(L, -2); lua_rawget(L, -2);
/* Stack is now: objcache, cached value. */ /* Stack is now: objcache, cached value. */
@ -382,7 +382,7 @@ void lupb_refcounted_pushnewrapper(lua_State *L, const upb_refcounted *obj,
const char *type, const void *ref_donor) { const char *type, const void *ref_donor) {
bool created = bool created =
lupb_refcounted_pushwrapper(L, obj, type, ref_donor, sizeof(void *)); lupb_refcounted_pushwrapper(L, obj, type, ref_donor, sizeof(void *));
UPB_ASSERT_VAR(created, created == true); UPB_ASSERT(created == true);
} }
static int lupb_refcounted_gc(lua_State *L) { static int lupb_refcounted_gc(lua_State *L) {
@ -461,7 +461,7 @@ bool lupb_def_pushwrapper(lua_State *L, const upb_def *def,
void lupb_def_pushnewrapper(lua_State *L, const upb_def *def, void lupb_def_pushnewrapper(lua_State *L, const upb_def *def,
const void *ref_donor) { const void *ref_donor) {
bool created = lupb_def_pushwrapper(L, def, ref_donor); bool created = lupb_def_pushwrapper(L, def, ref_donor);
UPB_ASSERT_VAR(created, created == true); UPB_ASSERT(created == true);
} }
static int lupb_def_type(lua_State *L) { static int lupb_def_type(lua_State *L) {
@ -1310,7 +1310,7 @@ static int lupb_filedefiter_next(lua_State *L) {
const upb_def *def; const upb_def *def;
def = upb_filedef_def(f, i); def = upb_filedef_def(f, i);
assert(def); UPB_ASSERT(def);
if (type == UPB_DEF_ANY || upb_def_type(def) == type) { if (type == UPB_DEF_ANY || upb_def_type(def) == type) {
lua_pushinteger(L, i + 1); lua_pushinteger(L, i + 1);
@ -1738,7 +1738,7 @@ static lupb_msgdef *lupb_msg_assignoffsets(lua_State *L, int narg) {
upb_fielddef *f = upb_msg_iter_field(&i); upb_fielddef *f = upb_msg_iter_field(&i);
if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE) { if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE) {
bool created = lupb_def_pushwrapper(L, upb_fielddef_subdef(f), NULL); bool created = lupb_def_pushwrapper(L, upb_fielddef_subdef(f), NULL);
UPB_ASSERT_VAR(created, !created); UPB_ASSERT(!created);
lupb_msg_assignoffsets(L, -1); lupb_msg_assignoffsets(L, -1);
lua_rawseti(L, -2, idx++); /* Append to uservalue. */ lua_rawseti(L, -2, idx++); /* Append to uservalue. */
} }

@ -63,7 +63,7 @@ static PyObject *weakref_callback = NULL;
static PyObject *PyUpb_StringForPointer(const void *ptr) { static PyObject *PyUpb_StringForPointer(const void *ptr) {
PyObject *o = PyString_FromStringAndSize((const char *)&ptr, sizeof(void*)); PyObject *o = PyString_FromStringAndSize((const char *)&ptr, sizeof(void*));
assert(o); UPB_ASSERT(o);
return o; return o;
} }
@ -73,11 +73,11 @@ static PyObject *PyUpb_ObjCacheDeleteCallback(PyObject *self, PyObject *ref) {
// remove from the cache. As a result we are forced to keep a second map // remove from the cache. As a result we are forced to keep a second map
// mapping weakref->C pointer. // mapping weakref->C pointer.
PyObject *ptr_str = PyDict_GetItem(reverse_cache, ref); PyObject *ptr_str = PyDict_GetItem(reverse_cache, ref);
assert(ptr_str); UPB_ASSERT(ptr_str);
int err = PyDict_DelItem(obj_cache, ptr_str); int err = PyDict_DelItem(obj_cache, ptr_str);
assert(!err); UPB_ASSERT(!err);
err = PyDict_DelItem(reverse_cache, ref); err = PyDict_DelItem(reverse_cache, ref);
assert(!err); UPB_ASSERT(!err);
return Py_None; return Py_None;
} }
@ -87,7 +87,7 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) {
PyObject *ret; PyObject *ret;
if (ref) { if (ref) {
ret = PyWeakref_GetObject(ref); ret = PyWeakref_GetObject(ref);
assert(ret != Py_None); UPB_ASSERT(ret != Py_None);
Py_INCREF(ret); Py_INCREF(ret);
} else { } else {
PyUpb_ObjWrapper *wrapper = (PyUpb_ObjWrapper*)type->tp_alloc(type, 0); PyUpb_ObjWrapper *wrapper = (PyUpb_ObjWrapper*)type->tp_alloc(type, 0);
@ -95,12 +95,12 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) {
wrapper->weakreflist = NULL; wrapper->weakreflist = NULL;
ret = (PyObject*)wrapper; ret = (PyObject*)wrapper;
ref = PyWeakref_NewRef(ret, weakref_callback); ref = PyWeakref_NewRef(ret, weakref_callback);
assert(PyWeakref_GetObject(ref) == ret); UPB_ASSERT(PyWeakref_GetObject(ref) == ret);
assert(ref); UPB_ASSERT(ref);
PyDict_SetItem(obj_cache, kv, ref); PyDict_SetItem(obj_cache, kv, ref);
PyDict_SetItem(reverse_cache, ref, kv); PyDict_SetItem(reverse_cache, ref, kv);
} }
assert(ret); UPB_ASSERT(ret);
Py_DECREF(kv); Py_DECREF(kv);
return ret; return ret;
} }

@ -161,8 +161,8 @@ static void objcache_init() {
// Call to uninitialize the cache. Should be done once on process shutdown. // Call to uninitialize the cache. Should be done once on process shutdown.
static void objcache_uninit(ruby_vm_t *vm) { static void objcache_uninit(ruby_vm_t *vm) {
assert(objcache_initialized); UPB_ASSERT(objcache_initialized);
assert(upb_inttable_count(&objcache) == 0); UPB_ASSERT(upb_inttable_count(&objcache) == 0);
objcache_initialized = false; objcache_initialized = false;
upb_inttable_uninit(&objcache); upb_inttable_uninit(&objcache);
@ -171,7 +171,7 @@ static void objcache_uninit(ruby_vm_t *vm) {
// Looks up the given object in the cache. If the corresponding Ruby wrapper // Looks up the given object in the cache. If the corresponding Ruby wrapper
// object is found, returns it, otherwise creates the wrapper and returns that. // object is found, returns it, otherwise creates the wrapper and returns that.
static VALUE objcache_getorcreate(const void *obj, createfunc *func) { static VALUE objcache_getorcreate(const void *obj, createfunc *func) {
assert(objcache_initialized); UPB_ASSERT(objcache_initialized);
upb_value v; upb_value v;
if (!upb_inttable_lookupptr(&objcache, obj, &v)) { if (!upb_inttable_lookupptr(&objcache, obj, &v)) {
@ -184,10 +184,10 @@ static VALUE objcache_getorcreate(const void *obj, createfunc *func) {
// Removes the given object from the cache. Should only be called by the code // Removes the given object from the cache. Should only be called by the code
// that is freeing the wrapper object. // that is freeing the wrapper object.
static void objcache_remove(const void *obj) { static void objcache_remove(const void *obj) {
assert(objcache_initialized); UPB_ASSERT(objcache_initialized);
bool removed = upb_inttable_removeptr(&objcache, obj, NULL); bool removed = upb_inttable_removeptr(&objcache, obj, NULL);
UPB_ASSERT_VAR(removed, removed); UPB_ASSERT(removed);
} }
/* message layout *************************************************************/ /* message layout *************************************************************/
@ -256,7 +256,7 @@ static size_t rupb_sizeof(const upb_fielddef *f) {
default: default:
break; break;
} }
assert(false); UPB_ASSERT(false);
return 0; return 0;
} }
@ -656,7 +656,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) {
rupb_Message *msg = msg_get(obj); rupb_Message *msg = msg_get(obj);
// method_missing protocol: (method [, arg1, arg2, ...]) // method_missing protocol: (method [, arg1, arg2, ...])
assert(argc >= 1 && SYMBOL_P(argv[0])); UPB_ASSERT(argc >= 1 && SYMBOL_P(argv[0]));
// OPT(haberman): find a better way to get the method name. // OPT(haberman): find a better way to get the method name.
// This is allocating a new string each time, which should not be necessary. // This is allocating a new string each time, which should not be necessary.
VALUE method = rb_id2str(SYM2ID(argv[0])); VALUE method = rb_id2str(SYM2ID(argv[0]));
@ -668,7 +668,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) {
// foo.bar = x // foo.bar = x
// //
// Ruby should guarantee that we have exactly one more argument (x) // Ruby should guarantee that we have exactly one more argument (x)
assert(argc == 2); UPB_ASSERT(argc == 2);
return msg_setter(msg, method, argv[1]); return msg_setter(msg, method, argv[1]);
} else { } else {
// Call was: // Call was:
@ -1011,14 +1011,14 @@ static const upb_handlers *new_fill_handlers(const rupb_MessageDef *rmd,
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t ret; upb_selector_t ret;
bool ok = upb_handlers_getselector(f, type, &ret); bool ok = upb_handlers_getselector(f, type, &ret);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return ret; return ret;
} }
static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) { static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
if (str == Qnil) return; if (str == Qnil) return;
assert(BUILTIN_TYPE(str) == RUBY_T_STRING); UPB_ASSERT(BUILTIN_TYPE(str) == RUBY_T_STRING);
upb_sink subsink; upb_sink subsink;
upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str), upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str),
@ -1042,7 +1042,7 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink) {
static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink) { static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink) {
if (ary == Qnil) return; if (ary == Qnil) return;
assert(BUILTIN_TYPE(ary) == RUBY_T_ARRAY); UPB_ASSERT(BUILTIN_TYPE(ary) == RUBY_T_ARRAY);
upb_sink subsink; upb_sink subsink;
upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink); upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink);

@ -36,7 +36,7 @@ static upb_stdio_buf *upb_stdio_rotatebufs(upb_stdio *s) {
reuse[num_reused++] = buf; reuse[num_reused++] = buf;
} }
} }
assert(num_reused + num_inuse == s->nbuf); UPB_ASSERT(num_reused + num_inuse == s->nbuf);
memcpy(s->bufs + num_inuse, reuse, num_reused * sizeof(upb_stdio_buf*)); memcpy(s->bufs + num_inuse, reuse, num_reused * sizeof(upb_stdio_buf*));
if (num_reused == 0) { if (num_reused == 0) {
++s->nbuf; ++s->nbuf;
@ -78,7 +78,7 @@ retry:
return upb_errno_is_wouldblock(errno) ? return upb_errno_is_wouldblock(errno) ?
UPB_BYTE_WOULDBLOCK : UPB_BYTE_ERROR; UPB_BYTE_WOULDBLOCK : UPB_BYTE_ERROR;
} }
assert(false); UPB_ASSERT(false);
} }
return UPB_BYTE_OK; return UPB_BYTE_OK;
} }

@ -104,7 +104,7 @@ const char *upb_def_name(const upb_def *d) {
} }
bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) { bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
assert(!upb_def_isfrozen(def)); UPB_ASSERT(!upb_def_isfrozen(def));
if (!upb_isident(fullname, strlen(fullname), true, s)) { if (!upb_isident(fullname, strlen(fullname), true, s)) {
return false; return false;
} }
@ -133,7 +133,7 @@ upb_def *upb_def_dup(const upb_def *def, const void *o) {
case UPB_DEF_ENUM: case UPB_DEF_ENUM:
return upb_enumdef_upcast_mutable( return upb_enumdef_upcast_mutable(
upb_enumdef_dup(upb_downcast_enumdef(def), o)); upb_enumdef_dup(upb_downcast_enumdef(def), o));
default: assert(false); return NULL; default: UPB_ASSERT(false); return NULL;
} }
} }
@ -204,14 +204,14 @@ static bool upb_validate_field(upb_fielddef *f, upb_status *s) {
bool has_default_number = upb_fielddef_enumhasdefaultint32(f); bool has_default_number = upb_fielddef_enumhasdefaultint32(f);
/* Previously verified by upb_validate_enumdef(). */ /* Previously verified by upb_validate_enumdef(). */
assert(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0); UPB_ASSERT(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0);
/* We've already validated that we have an associated enumdef and that it /* We've already validated that we have an associated enumdef and that it
* has at least one member, so at least one of these should be true. * has at least one member, so at least one of these should be true.
* Because if the user didn't set anything, we'll pick up the enum's * Because if the user didn't set anything, we'll pick up the enum's
* default, but if the user *did* set something we should at least pick up * default, but if the user *did* set something we should at least pick up
* the one they set (int32 or string). */ * the one they set (int32 or string). */
assert(has_default_name || has_default_number); UPB_ASSERT(has_default_name || has_default_number);
if (!has_default_name) { if (!has_default_name) {
upb_status_seterrf(s, upb_status_seterrf(s,
@ -267,7 +267,7 @@ static bool upb_validate_enumdef(const upb_enumdef *e, upb_status *s) {
uint32_t field_rank(const upb_fielddef *f) { uint32_t field_rank(const upb_fielddef *f) {
uint32_t ret = upb_fielddef_number(f); uint32_t ret = upb_fielddef_number(f);
const uint32_t high_bit = 1 << 30; const uint32_t high_bit = 1 << 30;
assert(ret < high_bit); UPB_ASSERT(ret < high_bit);
if (!upb_fielddef_issubmsg(f)) if (!upb_fielddef_issubmsg(f))
ret |= high_bit; ret |= high_bit;
return ret; return ret;
@ -305,7 +305,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
!upb_msg_field_done(&j); !upb_msg_field_done(&j);
upb_msg_field_next(&j), i++) { upb_msg_field_next(&j), i++) {
upb_fielddef *f = upb_msg_iter_field(&j); upb_fielddef *f = upb_msg_iter_field(&j);
assert(f->msg.def == m); UPB_ASSERT(f->msg.def == m);
if (!upb_validate_field(f, s)) { if (!upb_validate_field(f, s)) {
upb_gfree(fields); upb_gfree(fields);
return false; return false;
@ -418,7 +418,7 @@ err:
upb_def *def = defs[i]; upb_def *def = defs[i];
def->came_from_user = false; def->came_from_user = false;
} }
assert(!(s && upb_ok(s))); UPB_ASSERT(!(s && upb_ok(s)));
return false; return false;
} }
@ -537,19 +537,19 @@ bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
if (upb_enumdef_numvals(e) == 1) { if (upb_enumdef_numvals(e) == 1) {
bool ok = upb_enumdef_setdefault(e, num, NULL); bool ok = upb_enumdef_setdefault(e, num, NULL);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
} }
return true; return true;
} }
int32_t upb_enumdef_default(const upb_enumdef *e) { int32_t upb_enumdef_default(const upb_enumdef *e) {
assert(upb_enumdef_iton(e, e->defaultval)); UPB_ASSERT(upb_enumdef_iton(e, e->defaultval));
return e->defaultval; return e->defaultval;
} }
bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) { bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) {
assert(!upb_enumdef_isfrozen(e)); UPB_ASSERT(!upb_enumdef_isfrozen(e));
if (!upb_enumdef_iton(e, val)) { if (!upb_enumdef_iton(e, val)) {
upb_status_seterrf(s, "number '%d' is not in the enum.", val); upb_status_seterrf(s, "number '%d' is not in the enum.", val);
return false; return false;
@ -633,7 +633,7 @@ static void freefield(upb_refcounted *r) {
static const char *enumdefaultstr(const upb_fielddef *f) { static const char *enumdefaultstr(const upb_fielddef *f) {
const upb_enumdef *e; const upb_enumdef *e;
assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
e = upb_fielddef_enumsubdef(f); e = upb_fielddef_enumsubdef(f);
if (f->default_is_string && f->defaultval.bytes) { if (f->default_is_string && f->defaultval.bytes) {
/* Default was explicitly set as a string. */ /* Default was explicitly set as a string. */
@ -650,7 +650,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) {
/* Default is completely unset; pull enumdef default. */ /* Default is completely unset; pull enumdef default. */
if (upb_enumdef_numvals(e) > 0) { if (upb_enumdef_numvals(e) > 0) {
const char *name = upb_enumdef_iton(e, upb_enumdef_default(e)); const char *name = upb_enumdef_iton(e, upb_enumdef_default(e));
assert(name); UPB_ASSERT(name);
return name; return name;
} }
} }
@ -660,7 +660,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) {
static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) { static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) {
const upb_enumdef *e; const upb_enumdef *e;
assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
e = upb_fielddef_enumsubdef(f); e = upb_fielddef_enumsubdef(f);
if (!f->default_is_string) { if (!f->default_is_string) {
/* Default was explicitly set as an integer. */ /* Default was explicitly set as an integer. */
@ -761,7 +761,7 @@ bool upb_fielddef_typeisset(const upb_fielddef *f) {
} }
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) { upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) {
assert(f->type_is_set_); UPB_ASSERT(f->type_is_set_);
return f->type_; return f->type_;
} }
@ -863,7 +863,7 @@ static void release_containingtype(upb_fielddef *f) {
bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
upb_status *s) { upb_status *s) {
char *name_copy; char *name_copy;
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
if (upb_fielddef_containingtype(f)) { if (upb_fielddef_containingtype(f)) {
upb_status_seterrmsg(s, "field has already been added to a message."); upb_status_seterrmsg(s, "field has already been added to a message.");
return false; return false;
@ -894,7 +894,7 @@ bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) {
static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) { static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) {
UPB_UNUSED(f); UPB_UNUSED(f);
UPB_UNUSED(type); UPB_UNUSED(type);
assert(f->type_is_set_ && upb_fielddef_type(f) == type); UPB_ASSERT(f->type_is_set_ && upb_fielddef_type(f) == type);
} }
int64_t upb_fielddef_defaultint64(const upb_fielddef *f) { int64_t upb_fielddef_defaultint64(const upb_fielddef *f) {
@ -906,7 +906,7 @@ int32_t upb_fielddef_defaultint32(const upb_fielddef *f) {
if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) { if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) {
int32_t val; int32_t val;
bool ok = enumdefaultint32(f, &val); bool ok = enumdefaultint32(f, &val);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return val; return val;
} else { } else {
chkdefaulttype(f, UPB_TYPE_INT32); chkdefaulttype(f, UPB_TYPE_INT32);
@ -940,14 +940,14 @@ double upb_fielddef_defaultdouble(const upb_fielddef *f) {
} }
const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) { const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) {
assert(f->type_is_set_); UPB_ASSERT(f->type_is_set_);
assert(upb_fielddef_type(f) == UPB_TYPE_STRING || UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING ||
upb_fielddef_type(f) == UPB_TYPE_BYTES || upb_fielddef_type(f) == UPB_TYPE_BYTES ||
upb_fielddef_type(f) == UPB_TYPE_ENUM); upb_fielddef_type(f) == UPB_TYPE_ENUM);
if (upb_fielddef_type(f) == UPB_TYPE_ENUM) { if (upb_fielddef_type(f) == UPB_TYPE_ENUM) {
const char *ret = enumdefaultstr(f); const char *ret = enumdefaultstr(f);
assert(ret); UPB_ASSERT(ret);
/* Enum defaults can't have embedded NULLs. */ /* Enum defaults can't have embedded NULLs. */
if (len) *len = strlen(ret); if (len) *len = strlen(ret);
return ret; return ret;
@ -1029,8 +1029,8 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) {
} }
void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
assert(upb_fielddef_checktype(type)); UPB_ASSERT(upb_fielddef_checktype(type));
upb_fielddef_uninit_default(f); upb_fielddef_uninit_default(f);
f->type_ = type; f->type_ = type;
f->type_is_set_ = true; f->type_is_set_ = true;
@ -1038,7 +1038,7 @@ void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) {
} }
void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
switch (type) { switch (type) {
case UPB_DESCRIPTOR_TYPE_DOUBLE: case UPB_DESCRIPTOR_TYPE_DOUBLE:
upb_fielddef_settype(f, UPB_TYPE_DOUBLE); upb_fielddef_settype(f, UPB_TYPE_DOUBLE);
@ -1080,7 +1080,7 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) {
case UPB_DESCRIPTOR_TYPE_ENUM: case UPB_DESCRIPTOR_TYPE_ENUM:
upb_fielddef_settype(f, UPB_TYPE_ENUM); upb_fielddef_settype(f, UPB_TYPE_ENUM);
break; break;
default: assert(false); default: UPB_ASSERT(false);
} }
if (type == UPB_DESCRIPTOR_TYPE_FIXED64 || if (type == UPB_DESCRIPTOR_TYPE_FIXED64 ||
@ -1138,34 +1138,34 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) {
} }
void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) { void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->is_extension_ = is_extension; f->is_extension_ = is_extension;
} }
void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) { void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->lazy_ = lazy; f->lazy_ = lazy;
} }
void upb_fielddef_setpacked(upb_fielddef *f, bool packed) { void upb_fielddef_setpacked(upb_fielddef *f, bool packed) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->packed_ = packed; f->packed_ = packed;
} }
void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
assert(upb_fielddef_checklabel(label)); UPB_ASSERT(upb_fielddef_checklabel(label));
f->label_ = label; f->label_ = label;
} }
void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) { void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
assert(upb_fielddef_checkintfmt(fmt)); UPB_ASSERT(upb_fielddef_checkintfmt(fmt));
f->intfmt = fmt; f->intfmt = fmt;
} }
void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->tagdelim = tag_delim; f->tagdelim = tag_delim;
f->tagdelim = tag_delim; f->tagdelim = tag_delim;
} }
@ -1173,12 +1173,12 @@ void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) {
static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) { static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) {
if (!f->type_is_set_ || upb_fielddef_isfrozen(f) || if (!f->type_is_set_ || upb_fielddef_isfrozen(f) ||
upb_fielddef_type(f) != type) { upb_fielddef_type(f) != type) {
assert(false); UPB_ASSERT(false);
return false; return false;
} }
if (f->default_is_string) { if (f->default_is_string) {
str_t *s = f->defaultval.bytes; str_t *s = f->defaultval.bytes;
assert(s || type == UPB_TYPE_ENUM); UPB_ASSERT(s || type == UPB_TYPE_ENUM);
if (s) freestr(s); if (s) freestr(s);
} }
f->default_is_string = false; f->default_is_string = false;
@ -1226,16 +1226,16 @@ void upb_fielddef_setdefaultdouble(upb_fielddef *f, double value) {
bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
upb_status *s) { upb_status *s) {
str_t *str2; str_t *str2;
assert(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM);
if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s)) if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s))
return false; return false;
if (f->default_is_string) { if (f->default_is_string) {
str_t *s = f->defaultval.bytes; str_t *s = f->defaultval.bytes;
assert(s || f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(s || f->type_ == UPB_TYPE_ENUM);
if (s) freestr(s); if (s) freestr(s);
} else { } else {
assert(f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(f->type_ == UPB_TYPE_ENUM);
} }
str2 = newstr(str, len); str2 = newstr(str, len);
@ -1246,18 +1246,18 @@ bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str, void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str,
upb_status *s) { upb_status *s) {
assert(f->type_is_set_); UPB_ASSERT(f->type_is_set_);
upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s); upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s);
} }
bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) { bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) {
int32_t val; int32_t val;
assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
return enumdefaultint32(f, &val); return enumdefaultint32(f, &val);
} }
bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) { bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) {
assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
return enumdefaultstr(f) != NULL; return enumdefaultstr(f) != NULL;
} }
@ -1287,8 +1287,8 @@ static void release_subdef(upb_fielddef *f) {
bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef, bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef,
upb_status *s) { upb_status *s) {
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
assert(upb_fielddef_hassubdef(f)); UPB_ASSERT(upb_fielddef_hassubdef(f));
if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false; if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false;
release_subdef(f); release_subdef(f);
f->sub.def = subdef; f->sub.def = subdef;
@ -1310,7 +1310,7 @@ bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef,
bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name, bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name,
upb_status *s) { upb_status *s) {
char *name_copy; char *name_copy;
assert(!upb_fielddef_isfrozen(f)); UPB_ASSERT(!upb_fielddef_isfrozen(f));
if (!upb_fielddef_hassubdef(f)) { if (!upb_fielddef_hassubdef(f)) {
upb_status_seterrmsg(s, "field type does not accept a subdef"); upb_status_seterrmsg(s, "field type does not accept a subdef");
return false; return false;
@ -1443,7 +1443,7 @@ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
NULL); NULL);
newm->map_entry = m->map_entry; newm->map_entry = m->map_entry;
newm->syntax = m->syntax; newm->syntax = m->syntax;
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
for(upb_msg_field_begin(&i, m); for(upb_msg_field_begin(&i, m);
!upb_msg_field_done(&i); !upb_msg_field_done(&i);
upb_msg_field_next(&i)) { upb_msg_field_next(&i)) {
@ -1644,7 +1644,7 @@ bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
*o = upb_trygetoneof(upb_value_getptr(val)); *o = upb_trygetoneof(upb_value_getptr(val));
*f = upb_trygetfield(upb_value_getptr(val)); *f = upb_trygetfield(upb_value_getptr(val));
assert((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */ UPB_ASSERT((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */
return true; return true;
} }
@ -1659,7 +1659,7 @@ int upb_msgdef_numoneofs(const upb_msgdef *m) {
} }
void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) { void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) {
assert(!upb_msgdef_isfrozen(m)); UPB_ASSERT(!upb_msgdef_isfrozen(m));
m->map_entry = map_entry; m->map_entry = map_entry;
} }
@ -1772,7 +1772,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
upb_oneofdef *newo = upb_oneofdef_new(owner); upb_oneofdef *newo = upb_oneofdef_new(owner);
if (!newo) return NULL; if (!newo) return NULL;
ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL); ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) { for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) {
upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f); upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f);
if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) { if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) {
@ -1786,7 +1786,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; } const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; }
bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) { bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) {
assert(!upb_oneofdef_isfrozen(o)); UPB_ASSERT(!upb_oneofdef_isfrozen(o));
if (upb_oneofdef_containingtype(o)) { if (upb_oneofdef_containingtype(o)) {
upb_status_seterrmsg(s, "oneof already added to a message"); upb_status_seterrmsg(s, "oneof already added to a message");
return false; return false;
@ -1818,8 +1818,8 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) {
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
const void *ref_donor, const void *ref_donor,
upb_status *s) { upb_status *s) {
assert(!upb_oneofdef_isfrozen(o)); UPB_ASSERT(!upb_oneofdef_isfrozen(o));
assert(!o->parent || !upb_msgdef_isfrozen(o->parent)); UPB_ASSERT(!o->parent || !upb_msgdef_isfrozen(o->parent));
/* This method is idempotent. Check if |f| is already part of this oneofdef /* This method is idempotent. Check if |f| is already part of this oneofdef
* and return immediately if so. */ * and return immediately if so. */

@ -186,7 +186,7 @@ UPB_END_EXTERN_C
return (upb_##lower *)def; \ return (upb_##lower *)def; \
} \ } \
UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \ UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \
assert(upb_def_type(def) == UPB_DEF_##upper); \ UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \
return (const upb_##lower *)def; \ return (const upb_##lower *)def; \
} \ } \
UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \ UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \
@ -1420,7 +1420,7 @@ UPB_END_EXTERN_C
#ifdef __cplusplus #ifdef __cplusplus
UPB_INLINE const char* upb_safecstr(const std::string& str) { UPB_INLINE const char* upb_safecstr(const std::string& str) {
assert(str.size() == std::strlen(str.c_str())); UPB_ASSERT(str.size() == std::strlen(str.c_str()));
return str.c_str(); return str.c_str();
} }
@ -1459,19 +1459,19 @@ inline bool FieldDef::CheckIntegerFormat(int32_t val) {
return upb_fielddef_checkintfmt(val); return upb_fielddef_checkintfmt(val);
} }
inline FieldDef::Type FieldDef::ConvertType(int32_t val) { inline FieldDef::Type FieldDef::ConvertType(int32_t val) {
assert(CheckType(val)); UPB_ASSERT(CheckType(val));
return static_cast<FieldDef::Type>(val); return static_cast<FieldDef::Type>(val);
} }
inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) { inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) {
assert(CheckLabel(val)); UPB_ASSERT(CheckLabel(val));
return static_cast<FieldDef::Label>(val); return static_cast<FieldDef::Label>(val);
} }
inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) { inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) {
assert(CheckDescriptorType(val)); UPB_ASSERT(CheckDescriptorType(val));
return static_cast<FieldDef::DescriptorType>(val); return static_cast<FieldDef::DescriptorType>(val);
} }
inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) { inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) {
assert(CheckIntegerFormat(val)); UPB_ASSERT(CheckIntegerFormat(val));
return static_cast<FieldDef::IntegerFormat>(val); return static_cast<FieldDef::IntegerFormat>(val);
} }

@ -6,8 +6,6 @@
* Do not edit -- your changes will be discarded when the file is * Do not edit -- your changes will be discarded when the file is
* regenerated. */ * regenerated. */
#include <assert.h>
#include "upb/def.h" #include "upb/def.h"
#include "upb/structdefs.int.h" #include "upb/structdefs.int.h"

@ -184,111 +184,111 @@ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en
/* Functions to get a fielddef from a msgdef reference. */ /* Functions to get a fielddef from a msgdef reference. */
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
UPB_END_EXTERN_C UPB_END_EXTERN_C
@ -302,7 +302,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_DescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m));
} }
static DescriptorProto get() { static DescriptorProto get() {
@ -314,7 +314,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
} }
static ExtensionRange get() { static ExtensionRange get() {
@ -327,7 +327,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
} }
static ReservedRange get() { static ReservedRange get() {
@ -341,7 +341,7 @@ class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
} }
static EnumDescriptorProto get() { static EnumDescriptorProto get() {
@ -354,7 +354,7 @@ class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_EnumOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m));
} }
static EnumOptions get() { static EnumOptions get() {
@ -367,7 +367,7 @@ class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe
public: public:
EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
} }
static EnumValueDescriptorProto get() { static EnumValueDescriptorProto get() {
@ -380,7 +380,7 @@ class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m));
} }
static EnumValueOptions get() { static EnumValueOptions get() {
@ -393,7 +393,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
} }
static FieldDescriptorProto get() { static FieldDescriptorProto get() {
@ -405,7 +405,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
Label(const ::upb::EnumDef* e, const void *ref_donor = NULL) Label(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e)); UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
} }
static Label get() { static Label get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e); const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
@ -417,7 +417,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
Type(const ::upb::EnumDef* e, const void *ref_donor = NULL) Type(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e)); UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
} }
static Type get() { static Type get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e); const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
@ -430,7 +430,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_FieldOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m));
} }
static FieldOptions get() { static FieldOptions get() {
@ -442,7 +442,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
CType(const ::upb::EnumDef* e, const void *ref_donor = NULL) CType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_google_protobuf_FieldOptions_CType_is(e)); UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e));
} }
static CType get() { static CType get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e); const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
@ -454,7 +454,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL) JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e)); UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
} }
static JSType get() { static JSType get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e); const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
@ -467,7 +467,7 @@ class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m));
} }
static FileDescriptorProto get() { static FileDescriptorProto get() {
@ -480,7 +480,7 @@ class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL) FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m));
} }
static FileDescriptorSet get() { static FileDescriptorSet get() {
@ -493,7 +493,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_FileOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m));
} }
static FileOptions get() { static FileOptions get() {
@ -505,7 +505,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL) OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) { : reffed_ptr(e, ref_donor) {
assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e)); UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
} }
static OptimizeMode get() { static OptimizeMode get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e); const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
@ -518,7 +518,7 @@ class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_MessageOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m));
} }
static MessageOptions get() { static MessageOptions get() {
@ -531,7 +531,7 @@ class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
public: public:
MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
} }
static MethodDescriptorProto get() { static MethodDescriptorProto get() {
@ -544,7 +544,7 @@ class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_MethodOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m));
} }
static MethodOptions get() { static MethodOptions get() {
@ -557,7 +557,7 @@ class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
} }
static OneofDescriptorProto get() { static OneofDescriptorProto get() {
@ -570,7 +570,7 @@ class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
public: public:
ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
} }
static ServiceDescriptorProto get() { static ServiceDescriptorProto get() {
@ -583,7 +583,7 @@ class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_ServiceOptions_is(m)); UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m));
} }
static ServiceOptions get() { static ServiceOptions get() {
@ -596,7 +596,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL) SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m));
} }
static SourceCodeInfo get() { static SourceCodeInfo get() {
@ -608,7 +608,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
Location(const ::upb::MessageDef* m, const void *ref_donor = NULL) Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
} }
static Location get() { static Location get() {
@ -622,7 +622,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL) UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m));
} }
static UninterpretedOption get() { static UninterpretedOption get() {
@ -634,7 +634,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public: public:
NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL) NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) { : reffed_ptr(m, ref_donor) {
assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
} }
static NamePart get() { static NamePart get() {

@ -111,9 +111,9 @@ static bool upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) {
static upb_msgdef *upb_descreader_top(upb_descreader *r) { static upb_msgdef *upb_descreader_top(upb_descreader *r) {
int index; int index;
assert(r->stack_len > 1); UPB_ASSERT(r->stack_len > 1);
index = r->stack[r->stack_len-1].start - 1; index = r->stack[r->stack_len-1].start - 1;
assert(index >= 0); UPB_ASSERT(index >= 0);
return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index)); return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index));
} }
@ -183,7 +183,7 @@ static size_t file_onname(void *closure, const void *hd, const char *buf,
/* XXX: see comment at the top of the file. */ /* XXX: see comment at the top of the file. */
ok = upb_filedef_setname(r->file, name, NULL); ok = upb_filedef_setname(r->file, name, NULL);
upb_gfree(name); upb_gfree(name);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return n; return n;
} }
@ -199,7 +199,7 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf,
/* XXX: see comment at the top of the file. */ /* XXX: see comment at the top of the file. */
upb_descreader_setscopename(r, package); upb_descreader_setscopename(r, package);
ok = upb_filedef_setpackage(r->file, package, NULL); ok = upb_filedef_setpackage(r->file, package, NULL);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return n; return n;
} }
@ -218,7 +218,7 @@ static size_t file_onsyntax(void *closure, const void *hd, const char *buf,
ok = false; ok = false;
} }
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return n; return n;
} }
@ -227,7 +227,7 @@ static void *file_startmsg(void *closure, const void *hd) {
upb_msgdef *m = upb_msgdef_new(&m); upb_msgdef *m = upb_msgdef_new(&m);
bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
UPB_UNUSED(hd); UPB_UNUSED(hd);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return r; return r;
} }
@ -236,7 +236,7 @@ static void *file_startenum(void *closure, const void *hd) {
upb_enumdef *e = upb_enumdef_new(&e); upb_enumdef *e = upb_enumdef_new(&e);
bool ok = upb_filedef_addenum(r->file, e, &e, NULL); bool ok = upb_filedef_addenum(r->file, e, &e, NULL);
UPB_UNUSED(hd); UPB_UNUSED(hd);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return r; return r;
} }
@ -246,7 +246,7 @@ static void *file_startext(void *closure, const void *hd) {
r->f = upb_fielddef_new(r); r->f = upb_fielddef_new(r);
ok = upb_filedef_addext(r->file, r->f, r, NULL); ok = upb_filedef_addext(r->file, r->f, r, NULL);
UPB_UNUSED(hd); UPB_UNUSED(hd);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return r; return r;
} }
@ -332,7 +332,7 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf,
static bool field_startmsg(void *closure, const void *hd) { static bool field_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure; upb_descreader *r = closure;
UPB_UNUSED(hd); UPB_UNUSED(hd);
assert(r->f); UPB_ASSERT(r->f);
upb_gfree(r->default_string); upb_gfree(r->default_string);
r->default_string = NULL; r->default_string = NULL;
@ -418,9 +418,9 @@ static bool field_endmsg(void *closure, const void *hd, upb_status *status) {
UPB_UNUSED(hd); UPB_UNUSED(hd);
/* TODO: verify that all required fields were present. */ /* TODO: verify that all required fields were present. */
assert(upb_fielddef_number(f) != 0); UPB_ASSERT(upb_fielddef_number(f) != 0);
assert(upb_fielddef_name(f) != NULL); UPB_ASSERT(upb_fielddef_name(f) != NULL);
assert((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f)); UPB_ASSERT((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f));
if (r->default_string) { if (r->default_string) {
if (upb_fielddef_issubmsg(f)) { if (upb_fielddef_issubmsg(f)) {
@ -479,7 +479,7 @@ static bool field_onnumber(void *closure, const void *hd, int32_t val) {
UPB_UNUSED(hd); UPB_UNUSED(hd);
ok = upb_fielddef_setnumber(r->f, val, NULL); ok = upb_fielddef_setnumber(r->f, val, NULL);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return true; return true;
} }
@ -577,7 +577,7 @@ static void *msg_startmsg(void *closure, const void *hd) {
upb_msgdef *m = upb_msgdef_new(&m); upb_msgdef *m = upb_msgdef_new(&m);
bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
UPB_UNUSED(hd); UPB_UNUSED(hd);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return r; return r;
} }
@ -586,7 +586,7 @@ static void *msg_startext(void *closure, const void *hd) {
upb_fielddef *f = upb_fielddef_new(&f); upb_fielddef *f = upb_fielddef_new(&f);
bool ok = upb_filedef_addext(r->file, f, &f, NULL); bool ok = upb_filedef_addext(r->file, f, &f, NULL);
UPB_UNUSED(hd); UPB_UNUSED(hd);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return r; return r;
} }
@ -694,7 +694,7 @@ static void reghandlers(const void *closure, upb_handlers *h) {
upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL); upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL);
} }
assert(upb_ok(upb_handlers_status(h))); UPB_ASSERT(upb_ok(upb_handlers_status(h)));
} }
#undef F #undef F

@ -833,7 +833,7 @@ struct ConvertParams<BoundFunc5<R, P1, P2, P3, P4, P5, F, I>, T> {
inline bool Handlers::SetValueHandler<vtype>( \ inline bool Handlers::SetValueHandler<vtype>( \
const FieldDef *f, \ const FieldDef *f, \
const Handlers::utype ## Handler& handler) { \ const Handlers::utype ## Handler& handler) { \
assert(!handler.registered_); \ UPB_ASSERT(!handler.registered_); \
handler.AddCleanup(this); \ handler.AddCleanup(this); \
handler.registered_ = true; \ handler.registered_ = true; \
return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \ return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \
@ -945,7 +945,7 @@ inline Handler<T>::Handler(F func)
template <class T> template <class T>
inline Handler<T>::~Handler() { inline Handler<T>::~Handler() {
assert(registered_); UPB_ASSERT(registered_);
} }
inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); } inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); }
@ -1031,63 +1031,63 @@ inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) {
} }
inline bool Handlers::SetStartMessageHandler( inline bool Handlers::SetStartMessageHandler(
const Handlers::StartMessageHandler &handler) { const Handlers::StartMessageHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_); return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetEndMessageHandler( inline bool Handlers::SetEndMessageHandler(
const Handlers::EndMessageHandler &handler) { const Handlers::EndMessageHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_); return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetStartStringHandler(const FieldDef *f, inline bool Handlers::SetStartStringHandler(const FieldDef *f,
const StartStringHandler &handler) { const StartStringHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_); return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetEndStringHandler(const FieldDef *f, inline bool Handlers::SetEndStringHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_); return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetStringHandler(const FieldDef *f, inline bool Handlers::SetStringHandler(const FieldDef *f,
const StringHandler& handler) { const StringHandler& handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_); return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetStartSequenceHandler( inline bool Handlers::SetStartSequenceHandler(
const FieldDef *f, const StartFieldHandler &handler) { const FieldDef *f, const StartFieldHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_); return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetStartSubMessageHandler( inline bool Handlers::SetStartSubMessageHandler(
const FieldDef *f, const StartFieldHandler &handler) { const FieldDef *f, const StartFieldHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_); return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f, inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_); return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_);
} }
inline bool Handlers::SetEndSequenceHandler(const FieldDef *f, inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_); UPB_ASSERT(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
handler.AddCleanup(this); handler.AddCleanup(this);
return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_); return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_);

@ -1,6 +1,6 @@
/* /*
** TODO(haberman): it's unclear whether a lot of the consistency checks should ** TODO(haberman): it's unclear whether a lot of the consistency checks should
** assert() or return false. ** UPB_ASSERT() or return false.
*/ */
#include "upb/handlers.h" #include "upb/handlers.h"
@ -113,7 +113,7 @@ oom:
static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f, static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) { upb_handlertype_t type) {
upb_selector_t sel; upb_selector_t sel;
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) { if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) {
upb_status_seterrf( upb_status_seterrf(
&h->status_, "type mismatch: field %s does not belong to message %s", &h->status_, "type mismatch: field %s does not belong to message %s",
@ -133,7 +133,7 @@ static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f, static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) { upb_handlertype_t type) {
int32_t sel = trygetsel(h, f, type); int32_t sel = trygetsel(h, f, type);
assert(sel >= 0); UPB_ASSERT(sel >= 0);
return sel; return sel;
} }
@ -149,7 +149,7 @@ static bool doset(upb_handlers *h, int32_t sel, const upb_fielddef *f,
const void *closure_type; const void *closure_type;
const void **context_closure_type; const void **context_closure_type;
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
if (sel < 0) { if (sel < 0) {
upb_status_seterrmsg(&h->status_, upb_status_seterrmsg(&h->status_,
@ -229,7 +229,7 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f,
const void *ret; const void *ret;
upb_selector_t sel; upb_selector_t sel;
assert(type != UPB_HANDLER_STRING); UPB_ASSERT(type != UPB_HANDLER_STRING);
ret = h->top_closure_type; ret = h->top_closure_type;
if (upb_fielddef_isseq(f) && if (upb_fielddef_isseq(f) &&
@ -284,7 +284,7 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const void *owner) {
int extra; int extra;
upb_handlers *h; upb_handlers *h;
assert(upb_msgdef_isfrozen(md)); UPB_ASSERT(upb_msgdef_isfrozen(md));
extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1); extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1);
h = upb_calloc(sizeof(*h) + extra); h = upb_calloc(sizeof(*h) + extra);
@ -333,18 +333,18 @@ const upb_handlers *upb_handlers_newfrozen(const upb_msgdef *m,
r = upb_handlers_upcast_mutable(ret); r = upb_handlers_upcast_mutable(ret);
ok = upb_refcounted_freeze(&r, 1, NULL, UPB_MAX_HANDLER_DEPTH); ok = upb_refcounted_freeze(&r, 1, NULL, UPB_MAX_HANDLER_DEPTH);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return ret; return ret;
} }
const upb_status *upb_handlers_status(upb_handlers *h) { const upb_status *upb_handlers_status(upb_handlers *h) {
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
return &h->status_; return &h->status_;
} }
void upb_handlers_clearerr(upb_handlers *h) { void upb_handlers_clearerr(upb_handlers *h) {
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
upb_status_clear(&h->status_); upb_status_clear(&h->status_);
} }
@ -380,16 +380,16 @@ bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func, bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func,
upb_handlerattr *attr) { upb_handlerattr *attr) {
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32, return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32,
(upb_func *)func, attr); (upb_func *)func, attr);
} }
bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f,
const upb_handlers *sub) { const upb_handlers *sub) {
assert(sub); UPB_ASSERT(sub);
assert(!upb_handlers_isfrozen(h)); UPB_ASSERT(!upb_handlers_isfrozen(h));
assert(upb_fielddef_issubmsg(f)); UPB_ASSERT(upb_fielddef_issubmsg(f));
if (SUBH_F(h, f)) return false; /* Can't reset. */ if (SUBH_F(h, f)) return false; /* Can't reset. */
if (upb_msgdef_upcast(upb_handlers_msgdef(sub)) != upb_fielddef_subdef(f)) { if (upb_msgdef_upcast(upb_handlers_msgdef(sub)) != upb_fielddef_subdef(f)) {
return false; return false;
@ -401,7 +401,7 @@ bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f,
const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h, const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h,
const upb_fielddef *f) { const upb_fielddef *f) {
assert(upb_fielddef_issubmsg(f)); UPB_ASSERT(upb_fielddef_issubmsg(f));
return SUBH_F(h, f); return SUBH_F(h, f);
} }
@ -427,7 +427,7 @@ bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *func) {
return false; return false;
} }
ok = upb_inttable_insertptr(&h->cleanup_, p, upb_value_fptr(func)); ok = upb_inttable_insertptr(&h->cleanup_, p, upb_value_fptr(func));
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return true; return true;
} }
@ -528,7 +528,7 @@ upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) {
case UPB_TYPE_FLOAT: return UPB_HANDLER_FLOAT; case UPB_TYPE_FLOAT: return UPB_HANDLER_FLOAT;
case UPB_TYPE_DOUBLE: return UPB_HANDLER_DOUBLE; case UPB_TYPE_DOUBLE: return UPB_HANDLER_DOUBLE;
case UPB_TYPE_BOOL: return UPB_HANDLER_BOOL; case UPB_TYPE_BOOL: return UPB_HANDLER_BOOL;
default: assert(false); return -1; /* Invalid input. */ default: UPB_ASSERT(false); return -1; /* Invalid input. */
} }
} }
@ -591,7 +591,7 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
*s = f->selector_base; *s = f->selector_base;
break; break;
} }
assert((size_t)*s < upb_fielddef_containingtype(f)->selector_count); UPB_ASSERT((size_t)*s < upb_fielddef_containingtype(f)->selector_count);
return true; return true;
} }

@ -611,7 +611,7 @@ template <class T> class Handler {
void AddCleanup(Handlers* h) const { void AddCleanup(Handlers* h) const {
if (cleanup_func_) { if (cleanup_func_) {
bool ok = h->AddCleanup(cleanup_data_, cleanup_func_); bool ok = h->AddCleanup(cleanup_data_, cleanup_func_);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
} }
} }

@ -119,7 +119,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p,
upb_handlertype_t type) { upb_handlertype_t type) {
upb_selector_t sel; upb_selector_t sel;
bool ok = upb_handlers_getselector(p->top->f, type, &sel); bool ok = upb_handlers_getselector(p->top->f, type, &sel);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return sel; return sel;
} }
@ -141,7 +141,7 @@ static bool check_stack(upb_json_parser *p) {
static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) { static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) {
upb_value v; upb_value v;
bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v); bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
frame->name_table = upb_value_getptr(v); frame->name_table = upb_value_getptr(v);
} }
@ -264,7 +264,7 @@ otherchar:
val = b64lookup(ptr[0]) << 18 | val = b64lookup(ptr[0]) << 18 |
b64lookup(ptr[1]) << 12; b64lookup(ptr[1]) << 12;
assert(!(val & 0x80000000)); UPB_ASSERT(!(val & 0x80000000));
output = val >> 16; output = val >> 16;
upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL);
return true; return true;
@ -319,8 +319,8 @@ badpadding:
static void assert_accumulate_empty(upb_json_parser *p) { static void assert_accumulate_empty(upb_json_parser *p) {
UPB_UNUSED(p); UPB_UNUSED(p);
assert(p->accumulated == NULL); UPB_ASSERT(p->accumulated == NULL);
assert(p->accumulated_len == 0); UPB_ASSERT(p->accumulated_len == 0);
} }
static void accumulate_clear(upb_json_parser *p) { static void accumulate_clear(upb_json_parser *p) {
@ -386,7 +386,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len,
* call, and writes the length to *len. This with point either to the input * call, and writes the length to *len. This with point either to the input
* buffer or a temporary accumulate buffer. */ * buffer or a temporary accumulate buffer. */
static const char *accumulate_getptr(upb_json_parser *p, size_t *len) { static const char *accumulate_getptr(upb_json_parser *p, size_t *len) {
assert(p->accumulated); UPB_ASSERT(p->accumulated);
*len = p->accumulated_len; *len = p->accumulated_len;
return p->accumulated; return p->accumulated;
} }
@ -424,7 +424,7 @@ enum {
* the end. */ * the end. */
static void multipart_startaccum(upb_json_parser *p) { static void multipart_startaccum(upb_json_parser *p) {
assert_accumulate_empty(p); assert_accumulate_empty(p);
assert(p->multipart_state == MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_ACCUMULATE; p->multipart_state = MULTIPART_ACCUMULATE;
} }
@ -432,7 +432,7 @@ static void multipart_startaccum(upb_json_parser *p) {
* value with the given selector. */ * value with the given selector. */
static void multipart_start(upb_json_parser *p, upb_selector_t sel) { static void multipart_start(upb_json_parser *p, upb_selector_t sel) {
assert_accumulate_empty(p); assert_accumulate_empty(p);
assert(p->multipart_state == MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_PUSHEAGERLY; p->multipart_state = MULTIPART_PUSHEAGERLY;
p->string_selector = sel; p->string_selector = sel;
} }
@ -465,7 +465,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len,
/* Note: this invalidates the accumulate buffer! Call only after reading its /* Note: this invalidates the accumulate buffer! Call only after reading its
* contents. */ * contents. */
static void multipart_end(upb_json_parser *p) { static void multipart_end(upb_json_parser *p) {
assert(p->multipart_state != MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_INACTIVE; p->multipart_state = MULTIPART_INACTIVE;
accumulate_clear(p); accumulate_clear(p);
} }
@ -478,13 +478,13 @@ static void multipart_end(upb_json_parser *p) {
* region. */ * region. */
static void capture_begin(upb_json_parser *p, const char *ptr) { static void capture_begin(upb_json_parser *p, const char *ptr) {
assert(p->multipart_state != MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
assert(p->capture == NULL); UPB_ASSERT(p->capture == NULL);
p->capture = ptr; p->capture = ptr;
} }
static bool capture_end(upb_json_parser *p, const char *ptr) { static bool capture_end(upb_json_parser *p, const char *ptr) {
assert(p->capture); UPB_ASSERT(p->capture);
if (multipart_text(p, p->capture, ptr - p->capture, true)) { if (multipart_text(p, p->capture, ptr - p->capture, true)) {
p->capture = NULL; p->capture = NULL;
return true; return true;
@ -517,7 +517,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) {
static void capture_resume(upb_json_parser *p, const char *ptr) { static void capture_resume(upb_json_parser *p, const char *ptr) {
if (p->capture) { if (p->capture) {
assert(p->capture == &suspend_capture); UPB_ASSERT(p->capture == &suspend_capture);
p->capture = ptr; p->capture = ptr;
} }
} }
@ -539,7 +539,7 @@ static char escape_char(char in) {
case '"': return '"'; case '"': return '"';
case '\\': return '\\'; case '\\': return '\\';
default: default:
assert(0); UPB_ASSERT(0);
return 'x'; return 'x';
} }
} }
@ -563,7 +563,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) {
} else if (ch >= 'a' && ch <= 'f') { } else if (ch >= 'a' && ch <= 'f') {
p->digit += ((ch - 'a') + 10); p->digit += ((ch - 'a') + 10);
} else { } else {
assert(ch >= 'A' && ch <= 'F'); UPB_ASSERT(ch >= 'A' && ch <= 'F');
p->digit += ((ch - 'A') + 10); p->digit += ((ch - 'A') + 10);
} }
} }
@ -694,7 +694,7 @@ static bool parse_number(upb_json_parser *p) {
break; break;
} }
default: default:
assert(false); UPB_ASSERT(false);
} }
multipart_end(p); multipart_end(p);
@ -720,13 +720,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) {
} }
ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return true; return true;
} }
static bool start_stringval(upb_json_parser *p) { static bool start_stringval(upb_json_parser *p) {
assert(p->top->f); UPB_ASSERT(p->top->f);
if (upb_fielddef_isstring(p->top->f)) { if (upb_fielddef_isstring(p->top->f)) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
@ -816,7 +816,7 @@ static bool end_stringval(upb_json_parser *p) {
} }
default: default:
assert(false); UPB_ASSERT(false);
upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); upb_status_seterrmsg(&p->status, "Internal error in JSON decoder");
upb_env_reporterror(p->env, &p->status); upb_env_reporterror(p->env, &p->status);
ok = false; ok = false;
@ -829,7 +829,7 @@ static bool end_stringval(upb_json_parser *p) {
} }
static void start_member(upb_json_parser *p) { static void start_member(upb_json_parser *p) {
assert(!p->top->f); UPB_ASSERT(!p->top->f);
multipart_startaccum(p); multipart_startaccum(p);
} }
@ -958,7 +958,7 @@ static bool handle_mapentry(upb_json_parser *p) {
} }
static bool end_membername(upb_json_parser *p) { static bool end_membername(upb_json_parser *p) {
assert(!p->top->f); UPB_ASSERT(!p->top->f);
if (p->top->is_map) { if (p->top->is_map) {
return handle_mapentry(p); return handle_mapentry(p);
@ -990,7 +990,7 @@ static void end_member(upb_json_parser *p) {
bool ok; bool ok;
const upb_fielddef *mapfield; const upb_fielddef *mapfield;
assert(p->top > p->stack); UPB_ASSERT(p->top > p->stack);
/* send ENDMSG on submsg. */ /* send ENDMSG on submsg. */
upb_sink_endmsg(&p->top->sink, &s); upb_sink_endmsg(&p->top->sink, &s);
mapfield = p->top->mapfield; mapfield = p->top->mapfield;
@ -998,7 +998,7 @@ static void end_member(upb_json_parser *p) {
/* send ENDSUBMSG in repeated-field-of-mapentries frame. */ /* send ENDSUBMSG in repeated-field-of-mapentries frame. */
p->top--; p->top--;
ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
upb_sink_endsubmsg(&p->top->sink, sel); upb_sink_endsubmsg(&p->top->sink, sel);
} }
@ -1006,7 +1006,7 @@ static void end_member(upb_json_parser *p) {
} }
static bool start_subobject(upb_json_parser *p) { static bool start_subobject(upb_json_parser *p) {
assert(p->top->f); UPB_ASSERT(p->top->f);
if (upb_fielddef_ismap(p->top->f)) { if (upb_fielddef_ismap(p->top->f)) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
@ -1075,7 +1075,7 @@ static bool start_array(upb_json_parser *p) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
upb_selector_t sel; upb_selector_t sel;
assert(p->top->f); UPB_ASSERT(p->top->f);
if (!upb_fielddef_isseq(p->top->f)) { if (!upb_fielddef_isseq(p->top->f)) {
upb_status_seterrf(&p->status, upb_status_seterrf(&p->status,
@ -1103,7 +1103,7 @@ static bool start_array(upb_json_parser *p) {
static void end_array(upb_json_parser *p) { static void end_array(upb_json_parser *p) {
upb_selector_t sel; upb_selector_t sel;
assert(p->top > p->stack); UPB_ASSERT(p->top > p->stack);
p->top--; p->top--;
sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ);
@ -1634,7 +1634,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) {
buf = upb_grealloc(buf, 0, field_len); buf = upb_grealloc(buf, 0, field_len);
len = field_len; len = field_len;
len2 = upb_fielddef_getjsonname(f, buf, len); len2 = upb_fielddef_getjsonname(f, buf, len);
UPB_ASSERT_VAR(len2, len == len2); UPB_ASSERT(len == len2);
} }
upb_strtable_insert(t, buf, upb_value_constptr(f)); upb_strtable_insert(t, buf, upb_value_constptr(f));
@ -1678,7 +1678,8 @@ upb_json_parser *upb_json_parser_create(upb_env *env,
/* If this fails, uncomment and increase the value in parser.h. */ /* If this fails, uncomment and increase the value in parser.h. */
/* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */ /* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */
assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE); UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <=
UPB_JSON_PARSER_SIZE);
return p; return p;
} }

@ -117,7 +117,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p,
upb_handlertype_t type) { upb_handlertype_t type) {
upb_selector_t sel; upb_selector_t sel;
bool ok = upb_handlers_getselector(p->top->f, type, &sel); bool ok = upb_handlers_getselector(p->top->f, type, &sel);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return sel; return sel;
} }
@ -139,7 +139,7 @@ static bool check_stack(upb_json_parser *p) {
static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) { static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) {
upb_value v; upb_value v;
bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v); bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
frame->name_table = upb_value_getptr(v); frame->name_table = upb_value_getptr(v);
} }
@ -262,7 +262,7 @@ otherchar:
val = b64lookup(ptr[0]) << 18 | val = b64lookup(ptr[0]) << 18 |
b64lookup(ptr[1]) << 12; b64lookup(ptr[1]) << 12;
assert(!(val & 0x80000000)); UPB_ASSERT(!(val & 0x80000000));
output = val >> 16; output = val >> 16;
upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL);
return true; return true;
@ -316,9 +316,8 @@ badpadding:
* the true value in a contiguous buffer. */ * the true value in a contiguous buffer. */
static void assert_accumulate_empty(upb_json_parser *p) { static void assert_accumulate_empty(upb_json_parser *p) {
UPB_UNUSED(p); UPB_ASSERT(p->accumulated == NULL);
assert(p->accumulated == NULL); UPB_ASSERT(p->accumulated_len == 0);
assert(p->accumulated_len == 0);
} }
static void accumulate_clear(upb_json_parser *p) { static void accumulate_clear(upb_json_parser *p) {
@ -384,7 +383,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len,
* call, and writes the length to *len. This with point either to the input * call, and writes the length to *len. This with point either to the input
* buffer or a temporary accumulate buffer. */ * buffer or a temporary accumulate buffer. */
static const char *accumulate_getptr(upb_json_parser *p, size_t *len) { static const char *accumulate_getptr(upb_json_parser *p, size_t *len) {
assert(p->accumulated); UPB_ASSERT(p->accumulated);
*len = p->accumulated_len; *len = p->accumulated_len;
return p->accumulated; return p->accumulated;
} }
@ -422,7 +421,7 @@ enum {
* the end. */ * the end. */
static void multipart_startaccum(upb_json_parser *p) { static void multipart_startaccum(upb_json_parser *p) {
assert_accumulate_empty(p); assert_accumulate_empty(p);
assert(p->multipart_state == MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_ACCUMULATE; p->multipart_state = MULTIPART_ACCUMULATE;
} }
@ -430,7 +429,7 @@ static void multipart_startaccum(upb_json_parser *p) {
* value with the given selector. */ * value with the given selector. */
static void multipart_start(upb_json_parser *p, upb_selector_t sel) { static void multipart_start(upb_json_parser *p, upb_selector_t sel) {
assert_accumulate_empty(p); assert_accumulate_empty(p);
assert(p->multipart_state == MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_PUSHEAGERLY; p->multipart_state = MULTIPART_PUSHEAGERLY;
p->string_selector = sel; p->string_selector = sel;
} }
@ -463,7 +462,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len,
/* Note: this invalidates the accumulate buffer! Call only after reading its /* Note: this invalidates the accumulate buffer! Call only after reading its
* contents. */ * contents. */
static void multipart_end(upb_json_parser *p) { static void multipart_end(upb_json_parser *p) {
assert(p->multipart_state != MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_INACTIVE; p->multipart_state = MULTIPART_INACTIVE;
accumulate_clear(p); accumulate_clear(p);
} }
@ -476,13 +475,13 @@ static void multipart_end(upb_json_parser *p) {
* region. */ * region. */
static void capture_begin(upb_json_parser *p, const char *ptr) { static void capture_begin(upb_json_parser *p, const char *ptr) {
assert(p->multipart_state != MULTIPART_INACTIVE); UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
assert(p->capture == NULL); UPB_ASSERT(p->capture == NULL);
p->capture = ptr; p->capture = ptr;
} }
static bool capture_end(upb_json_parser *p, const char *ptr) { static bool capture_end(upb_json_parser *p, const char *ptr) {
assert(p->capture); UPB_ASSERT(p->capture);
if (multipart_text(p, p->capture, ptr - p->capture, true)) { if (multipart_text(p, p->capture, ptr - p->capture, true)) {
p->capture = NULL; p->capture = NULL;
return true; return true;
@ -515,7 +514,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) {
static void capture_resume(upb_json_parser *p, const char *ptr) { static void capture_resume(upb_json_parser *p, const char *ptr) {
if (p->capture) { if (p->capture) {
assert(p->capture == &suspend_capture); UPB_ASSERT(p->capture == &suspend_capture);
p->capture = ptr; p->capture = ptr;
} }
} }
@ -537,7 +536,7 @@ static char escape_char(char in) {
case '"': return '"'; case '"': return '"';
case '\\': return '\\'; case '\\': return '\\';
default: default:
assert(0); UPB_ASSERT(0);
return 'x'; return 'x';
} }
} }
@ -561,7 +560,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) {
} else if (ch >= 'a' && ch <= 'f') { } else if (ch >= 'a' && ch <= 'f') {
p->digit += ((ch - 'a') + 10); p->digit += ((ch - 'a') + 10);
} else { } else {
assert(ch >= 'A' && ch <= 'F'); UPB_ASSERT(ch >= 'A' && ch <= 'F');
p->digit += ((ch - 'A') + 10); p->digit += ((ch - 'A') + 10);
} }
} }
@ -692,7 +691,7 @@ static bool parse_number(upb_json_parser *p) {
break; break;
} }
default: default:
assert(false); UPB_ASSERT(false);
} }
multipart_end(p); multipart_end(p);
@ -718,13 +717,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) {
} }
ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return true; return true;
} }
static bool start_stringval(upb_json_parser *p) { static bool start_stringval(upb_json_parser *p) {
assert(p->top->f); UPB_ASSERT(p->top->f);
if (upb_fielddef_isstring(p->top->f)) { if (upb_fielddef_isstring(p->top->f)) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
@ -814,7 +813,7 @@ static bool end_stringval(upb_json_parser *p) {
} }
default: default:
assert(false); UPB_ASSERT(false);
upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); upb_status_seterrmsg(&p->status, "Internal error in JSON decoder");
upb_env_reporterror(p->env, &p->status); upb_env_reporterror(p->env, &p->status);
ok = false; ok = false;
@ -827,7 +826,7 @@ static bool end_stringval(upb_json_parser *p) {
} }
static void start_member(upb_json_parser *p) { static void start_member(upb_json_parser *p) {
assert(!p->top->f); UPB_ASSERT(!p->top->f);
multipart_startaccum(p); multipart_startaccum(p);
} }
@ -956,7 +955,7 @@ static bool handle_mapentry(upb_json_parser *p) {
} }
static bool end_membername(upb_json_parser *p) { static bool end_membername(upb_json_parser *p) {
assert(!p->top->f); UPB_ASSERT(!p->top->f);
if (p->top->is_map) { if (p->top->is_map) {
return handle_mapentry(p); return handle_mapentry(p);
@ -988,7 +987,7 @@ static void end_member(upb_json_parser *p) {
bool ok; bool ok;
const upb_fielddef *mapfield; const upb_fielddef *mapfield;
assert(p->top > p->stack); UPB_ASSERT(p->top > p->stack);
/* send ENDMSG on submsg. */ /* send ENDMSG on submsg. */
upb_sink_endmsg(&p->top->sink, &s); upb_sink_endmsg(&p->top->sink, &s);
mapfield = p->top->mapfield; mapfield = p->top->mapfield;
@ -996,7 +995,7 @@ static void end_member(upb_json_parser *p) {
/* send ENDSUBMSG in repeated-field-of-mapentries frame. */ /* send ENDSUBMSG in repeated-field-of-mapentries frame. */
p->top--; p->top--;
ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
upb_sink_endsubmsg(&p->top->sink, sel); upb_sink_endsubmsg(&p->top->sink, sel);
} }
@ -1004,7 +1003,7 @@ static void end_member(upb_json_parser *p) {
} }
static bool start_subobject(upb_json_parser *p) { static bool start_subobject(upb_json_parser *p) {
assert(p->top->f); UPB_ASSERT(p->top->f);
if (upb_fielddef_ismap(p->top->f)) { if (upb_fielddef_ismap(p->top->f)) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
@ -1073,7 +1072,7 @@ static bool start_array(upb_json_parser *p) {
upb_jsonparser_frame *inner; upb_jsonparser_frame *inner;
upb_selector_t sel; upb_selector_t sel;
assert(p->top->f); UPB_ASSERT(p->top->f);
if (!upb_fielddef_isseq(p->top->f)) { if (!upb_fielddef_isseq(p->top->f)) {
upb_status_seterrf(&p->status, upb_status_seterrf(&p->status,
@ -1101,7 +1100,7 @@ static bool start_array(upb_json_parser *p) {
static void end_array(upb_json_parser *p) { static void end_array(upb_json_parser *p) {
upb_selector_t sel; upb_selector_t sel;
assert(p->top > p->stack); UPB_ASSERT(p->top > p->stack);
p->top--; p->top--;
sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ);
@ -1369,7 +1368,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) {
buf = upb_grealloc(buf, 0, field_len); buf = upb_grealloc(buf, 0, field_len);
len = field_len; len = field_len;
len2 = upb_fielddef_getjsonname(f, buf, len); len2 = upb_fielddef_getjsonname(f, buf, len);
UPB_ASSERT_VAR(len2, len == len2); UPB_ASSERT(len == len2);
} }
upb_strtable_insert(t, buf, upb_value_constptr(f)); upb_strtable_insert(t, buf, upb_value_constptr(f));
@ -1413,7 +1412,8 @@ upb_json_parser *upb_json_parser_create(upb_env *env,
/* If this fails, uncomment and increase the value in parser.h. */ /* If this fails, uncomment and increase the value in parser.h. */
/* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */ /* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */
assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE); UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <=
UPB_JSON_PARSER_SIZE);
return p; return p;
} }

@ -54,7 +54,7 @@ strpc *newstrpc(upb_handlers *h, const upb_fielddef *f,
ret->len = upb_fielddef_getjsonname(f, NULL, 0); ret->len = upb_fielddef_getjsonname(f, NULL, 0);
ret->ptr = upb_gmalloc(ret->len); ret->ptr = upb_gmalloc(ret->len);
len = upb_fielddef_getjsonname(f, ret->ptr, ret->len); len = upb_fielddef_getjsonname(f, ret->ptr, ret->len);
UPB_ASSERT_VAR(len, len == ret->len); UPB_ASSERT(len == ret->len);
ret->len--; /* NULL */ ret->len--; /* NULL */
} }
@ -68,7 +68,7 @@ static void print_data(
upb_json_printer *p, const char *buf, unsigned int len) { upb_json_printer *p, const char *buf, unsigned int len) {
/* TODO: Will need to change if we support pushback from the sink. */ /* TODO: Will need to change if we support pushback from the sink. */
size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL); size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL);
UPB_ASSERT_VAR(n, n == len); UPB_ASSERT(n == len);
} }
static void print_comma(upb_json_printer *p) { static void print_comma(upb_json_printer *p) {
@ -418,7 +418,7 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
while (remaining > 2) { while (remaining > 2) {
/* TODO(haberman): handle encoded lengths > sizeof(data) */ /* TODO(haberman): handle encoded lengths > sizeof(data) */
UPB_ASSERT_VAR(limit, (limit - to) >= 4); UPB_ASSERT((limit - to) >= 4);
to[0] = base64[from[0] >> 2]; to[0] = base64[from[0] >> 2];
to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)]; to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)];
@ -622,7 +622,7 @@ void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames,
upb_handlers_setstring(h, key_field, mapkey_bytes, &empty_attr); upb_handlers_setstring(h, key_field, mapkey_bytes, &empty_attr);
break; break;
default: default:
assert(false); UPB_ASSERT(false);
break; break;
} }
@ -796,7 +796,8 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h,
upb_sink_reset(&p->input_, h, p); upb_sink_reset(&p->input_, h, p);
/* If this fails, increase the value in printer.h. */ /* If this fails, increase the value in printer.h. */
assert(upb_env_bytesallocated(e) - size_before <= UPB_JSON_PRINTER_SIZE); UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <=
UPB_JSON_PRINTER_SIZE);
return p; return p;
} }

@ -183,7 +183,7 @@ bool op_has_longofs(int32_t instruction) {
case OP_TAGN: case OP_TAGN:
return false; return false;
default: default:
assert(false); UPB_ASSERT(false);
return false; return false;
} }
} }
@ -202,7 +202,7 @@ static void setofs(uint32_t *instruction, int32_t ofs) {
} else { } else {
*instruction = (*instruction & ~0xff00) | ((ofs & 0xff) << 8); *instruction = (*instruction & ~0xff00) | ((ofs & 0xff) << 8);
} }
assert(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */ UPB_ASSERT(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */
} }
static uint32_t pcofs(compiler *c) { return c->pc - c->group->bytecode; } static uint32_t pcofs(compiler *c) { return c->pc - c->group->bytecode; }
@ -214,7 +214,7 @@ static void label(compiler *c, unsigned int label) {
int val; int val;
uint32_t *codep; uint32_t *codep;
assert(label < MAXLABEL); UPB_ASSERT(label < MAXLABEL);
val = c->fwd_labels[label]; val = c->fwd_labels[label];
codep = (val == EMPTYLABEL) ? NULL : c->group->bytecode + val; codep = (val == EMPTYLABEL) ? NULL : c->group->bytecode + val;
while (codep) { while (codep) {
@ -235,7 +235,7 @@ static void label(compiler *c, unsigned int label) {
* The returned value is the offset that should be written into the instruction. * The returned value is the offset that should be written into the instruction.
*/ */
static int32_t labelref(compiler *c, int label) { static int32_t labelref(compiler *c, int label) {
assert(label < MAXLABEL); UPB_ASSERT(label < MAXLABEL);
if (label == LABEL_DISPATCH) { if (label == LABEL_DISPATCH) {
/* No resolving required. */ /* No resolving required. */
return 0; return 0;
@ -335,7 +335,7 @@ static void putop(compiler *c, opcode op, ...) {
int label = va_arg(ap, int); int label = va_arg(ap, int);
uint64_t tag = va_arg(ap, uint64_t); uint64_t tag = va_arg(ap, uint64_t);
uint32_t instruction = op | (tag << 16); uint32_t instruction = op | (tag << 16);
assert(tag <= 0xffff); UPB_ASSERT(tag <= 0xffff);
setofs(&instruction, labelref(c, label)); setofs(&instruction, labelref(c, label));
put32(c, instruction); put32(c, instruction);
break; break;
@ -472,7 +472,7 @@ static uint64_t get_encoded_tag(const upb_fielddef *f, int wire_type) {
uint32_t tag = (upb_fielddef_number(f) << 3) | wire_type; uint32_t tag = (upb_fielddef_number(f) << 3) | wire_type;
uint64_t encoded_tag = upb_vencode32(tag); uint64_t encoded_tag = upb_vencode32(tag);
/* No tag should be greater than 5 bytes. */ /* No tag should be greater than 5 bytes. */
assert(encoded_tag <= 0xffffffffff); UPB_ASSERT(encoded_tag <= 0xffffffffff);
return encoded_tag; return encoded_tag;
} }
@ -495,7 +495,7 @@ static void putchecktag(compiler *c, const upb_fielddef *f,
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t selector; upb_selector_t selector;
bool ok = upb_handlers_getselector(f, type, &selector); bool ok = upb_handlers_getselector(f, type, &selector);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return selector; return selector;
} }
@ -507,7 +507,7 @@ static uint64_t repack(uint64_t dispatch, int new_wt2) {
uint8_t wt1; uint8_t wt1;
uint8_t old_wt2; uint8_t old_wt2;
upb_pbdecoder_unpackdispatch(dispatch, &ofs, &wt1, &old_wt2); upb_pbdecoder_unpackdispatch(dispatch, &ofs, &wt1, &old_wt2);
assert(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */ UPB_ASSERT(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */
return upb_pbdecoder_packdispatch(ofs, wt1, new_wt2); return upb_pbdecoder_packdispatch(ofs, wt1, new_wt2);
} }
@ -709,7 +709,7 @@ static void generate_primitivefield(compiler *c, const upb_fielddef *f,
* setting in the fielddef. This will favor (in speed) whichever was * setting in the fielddef. This will favor (in speed) whichever was
* specified. */ * specified. */
assert((int)parse_type >= 0 && parse_type <= OP_MAX); UPB_ASSERT((int)parse_type >= 0 && parse_type <= OP_MAX);
sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
wire_type = upb_pb_native_wire_types[upb_fielddef_descriptortype(f)]; wire_type = upb_pb_native_wire_types[upb_fielddef_descriptortype(f)];
if (upb_fielddef_isseq(f)) { if (upb_fielddef_isseq(f)) {
@ -751,7 +751,7 @@ static void compile_method(compiler *c, upb_pbdecodermethod *method) {
upb_msg_field_iter i; upb_msg_field_iter i;
upb_value val; upb_value val;
assert(method); UPB_ASSERT(method);
/* Clear all entries in the dispatch table. */ /* Clear all entries in the dispatch table. */
upb_inttable_uninit(&method->dispatch); upb_inttable_uninit(&method->dispatch);
@ -899,7 +899,7 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy,
compiler *c; compiler *c;
UPB_UNUSED(allowjit); UPB_UNUSED(allowjit);
assert(upb_handlers_isfrozen(dest)); UPB_ASSERT(upb_handlers_isfrozen(dest));
g = newgroup(owner); g = newgroup(owner);
c = newcompiler(g, lazy); c = newcompiler(g, lazy);
@ -920,13 +920,13 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy,
#ifdef UPB_DUMP_BYTECODE #ifdef UPB_DUMP_BYTECODE
{ {
FILE *f = fopen("/tmp/upb-bytecode", "w"); FILE *f = fopen("/tmp/upb-bytecode", "w");
assert(f); UPB_ASSERT(f);
dumpbc(g->bytecode, g->bytecode_end, stderr); dumpbc(g->bytecode, g->bytecode_end, stderr);
dumpbc(g->bytecode, g->bytecode_end, f); dumpbc(g->bytecode, g->bytecode_end, f);
fclose(f); fclose(f);
f = fopen("/tmp/upb-bytecode.bin", "wb"); f = fopen("/tmp/upb-bytecode.bin", "wb");
assert(f); UPB_ASSERT(f);
fwrite(g->bytecode, 1, g->bytecode_end - g->bytecode, f); fwrite(g->bytecode, 1, g->bytecode_end - g->bytecode, f);
fclose(f); fclose(f);
} }
@ -976,7 +976,7 @@ const upb_pbdecodermethod *upb_pbcodecache_getdecodermethod(
upb_inttable_push(&c->groups, upb_value_constptr(g)); upb_inttable_push(&c->groups, upb_value_constptr(g));
ok = upb_inttable_lookupptr(&g->methods, opts->handlers, &v); ok = upb_inttable_lookupptr(&g->methods, opts->handlers, &v);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return upb_value_getptr(v); return upb_value_getptr(v);
} }

@ -184,7 +184,7 @@ static char *upb_vasprintf(const char *fmt, va_list args) {
char *ret = malloc(len + 1); /* + 1 for NULL terminator. */ char *ret = malloc(len + 1); /* + 1 for NULL terminator. */
if (!ret) abort(); if (!ret) abort();
int written = _upb_vsnprintf(ret, len + 1, fmt, args); int written = _upb_vsnprintf(ret, len + 1, fmt, args);
UPB_ASSERT_VAR(written, written == len); UPB_ASSERT(written == len);
return ret; return ret;
} }
@ -221,9 +221,9 @@ static int getjmptarget(jitcompiler *jc, const void *key) {
int pclabel = 0; int pclabel = 0;
bool ok; bool ok;
assert(upb_inttable_lookupptr(&jc->jmpdefined, key, NULL)); UPB_ASSERT_DEBUGVAR(upb_inttable_lookupptr(&jc->jmpdefined, key, NULL));
ok = try_getjmptarget(jc, key, &pclabel); ok = try_getjmptarget(jc, key, &pclabel);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return pclabel; return pclabel;
} }
@ -289,10 +289,10 @@ uint32_t dispatchofs(jitcompiler *jc, const upb_pbdecodermethod *method,
int mc_target = machine_code_ofs2(jc, method, pcofs); int mc_target = machine_code_ofs2(jc, method, pcofs);
int ret; int ret;
assert(mc_base > 0); UPB_ASSERT(mc_base > 0);
assert(mc_target > 0); UPB_ASSERT(mc_target > 0);
ret = mc_target - mc_base; ret = mc_target - mc_base;
assert(ret > 0); UPB_ASSERT(ret > 0);
return ret; return ret;
} }
@ -327,7 +327,7 @@ static void patchdispatch(jitcompiler *jc) {
/* Update offset and repack. */ /* Update offset and repack. */
ofs = dispatchofs(jc, method, ofs); ofs = dispatchofs(jc, method, ofs);
newval = upb_pbdecoder_packdispatch(ofs, wt1, wt2); newval = upb_pbdecoder_packdispatch(ofs, wt1, wt2);
assert((int64_t)newval > 0); UPB_ASSERT((int64_t)newval > 0);
} else { } else {
/* Secondary slot. Since we have 64 bits for the value, we use an /* Secondary slot. Since we have 64 bits for the value, we use an
* absolute offset. */ * absolute offset. */
@ -335,7 +335,7 @@ static void patchdispatch(jitcompiler *jc) {
newval = (uint64_t)((char*)jc->group->jit_code + mcofs); newval = (uint64_t)((char*)jc->group->jit_code + mcofs);
} }
ok = upb_inttable_replace(dispatch, key, upb_value_uint64(newval)); ok = upb_inttable_replace(dispatch, key, upb_value_uint64(newval));
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
} }
/* Update entry point for this method to point at mc base instead of bc /* Update entry point for this method to point at mc base instead of bc
@ -467,7 +467,7 @@ void upb_pbdecoder_jit(mgroup *group) {
group->debug_info = NULL; group->debug_info = NULL;
group->dl = NULL; group->dl = NULL;
assert(group->bytecode); UPB_ASSERT(group->bytecode);
jc = newjitcompiler(group); jc = newjitcompiler(group);
emit_static_asm(jc); emit_static_asm(jc);
jitbytecode(jc); jitbytecode(jc);

@ -153,7 +153,7 @@ static upb_func *gethandler(const upb_handlers *h, upb_selector_t sel) {
static void asmlabel(jitcompiler *jc, const char *fmt, ...) { static void asmlabel(jitcompiler *jc, const char *fmt, ...) {
#ifndef NDEBUG #ifndef NDEBUG
int ofs = jc->dynasm->section->ofs; int ofs = jc->dynasm->section->ofs;
assert(ofs != jc->lastlabelofs); UPB_ASSERT(ofs != jc->lastlabelofs);
jc->lastlabelofs = ofs; jc->lastlabelofs = ofs;
#endif #endif
@ -183,7 +183,7 @@ static bool alwaysok(const upb_handlers *h, upb_selector_t sel) {
bool ok = upb_handlers_getattr(h, sel, &attr); bool ok = upb_handlers_getattr(h, sel, &attr);
bool ret; bool ret;
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
ret = upb_handlerattr_alwaysok(&attr); ret = upb_handlerattr_alwaysok(&attr);
upb_handlerattr_uninit(&attr); upb_handlerattr_uninit(&attr);
return ret; return ret;
@ -641,7 +641,7 @@ static void jitprimitive(jitcompiler *jc, opcode op,
case UPB_TYPE_STRING: case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: case UPB_TYPE_BYTES:
case UPB_TYPE_MESSAGE: case UPB_TYPE_MESSAGE:
assert(false); break; UPB_ASSERT(false); break;
} }
| sethas CLOSURE, data->hasbit | sethas CLOSURE, data->hasbit
} else if (handler) { } else if (handler) {
@ -790,7 +790,7 @@ static void jitdispatch(jitcompiler *jc,
| // Secondary wire type is a match, look up fn + UPB_MAX_FIELDNUMBER. | // Secondary wire type is a match, look up fn + UPB_MAX_FIELDNUMBER.
| add rdx, UPB_MAX_FIELDNUMBER | add rdx, UPB_MAX_FIELDNUMBER
| // This key will never be in the array part, so do a hash lookup. | // This key will never be in the array part, so do a hash lookup.
assert(has_hash_entries); UPB_ASSERT(has_hash_entries);
| ld64 dispatch | ld64 dispatch
| jmp ->hashlookup // Tail call. | jmp ->hashlookup // Tail call.
} }
@ -815,7 +815,7 @@ static void jittag(jitcompiler *jc, uint64_t tag, int n, int ofs,
uint32_t *delimend = (jc->pc - 1) + last_arg; uint32_t *delimend = (jc->pc - 1) + last_arg;
const size_t ptr_words = sizeof(void*) / sizeof(uint32_t); const size_t ptr_words = sizeof(void*) / sizeof(uint32_t);
assert((last_instruction & 0xff) == OP_CHECKDELIM); UPB_ASSERT((last_instruction & 0xff) == OP_CHECKDELIM);
if (getop(*(jc->pc - 1)) == OP_TAGN) { if (getop(*(jc->pc - 1)) == OP_TAGN) {
jc->pc += ptr_words; jc->pc += ptr_words;
@ -1131,7 +1131,7 @@ static void jitbytecode(jitcompiler *jc) {
| call =>jmptarget(jc, &method->dispatch) | call =>jmptarget(jc, &method->dispatch)
break; break;
case OP_HALT: case OP_HALT:
assert(false); UPB_ASSERT(false);
} }
} }

@ -338,7 +338,7 @@ static upb_func *gethandler(const upb_handlers *h, upb_selector_t sel) {
static void asmlabel(jitcompiler *jc, const char *fmt, ...) { static void asmlabel(jitcompiler *jc, const char *fmt, ...) {
#ifndef NDEBUG #ifndef NDEBUG
int ofs = jc->dynasm->section->ofs; int ofs = jc->dynasm->section->ofs;
assert(ofs != jc->lastlabelofs); UPB_ASSERT(ofs != jc->lastlabelofs);
jc->lastlabelofs = ofs; jc->lastlabelofs = ofs;
#endif #endif
@ -370,7 +370,7 @@ static bool alwaysok(const upb_handlers *h, upb_selector_t sel) {
bool ok = upb_handlers_getattr(h, sel, &attr); bool ok = upb_handlers_getattr(h, sel, &attr);
bool ret; bool ret;
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
ret = upb_handlerattr_alwaysok(&attr); ret = upb_handlerattr_alwaysok(&attr);
upb_handlerattr_uninit(&attr); upb_handlerattr_uninit(&attr);
return ret; return ret;
@ -964,7 +964,7 @@ static void jitprimitive(jitcompiler *jc, opcode op,
case UPB_TYPE_STRING: case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: case UPB_TYPE_BYTES:
case UPB_TYPE_MESSAGE: case UPB_TYPE_MESSAGE:
assert(false); break; UPB_ASSERT(false); break;
} }
/*| sethas CLOSURE, data->hasbit */ /*| sethas CLOSURE, data->hasbit */
if (data->hasbit >= 0) { if (data->hasbit >= 0) {
@ -1188,7 +1188,7 @@ static void jitdispatch(jitcompiler *jc,
/*| // This key will never be in the array part, so do a hash lookup. */ /*| // This key will never be in the array part, so do a hash lookup. */
dasm_put(Dst, 2035, UPB_MAX_FIELDNUMBER); dasm_put(Dst, 2035, UPB_MAX_FIELDNUMBER);
# 793 "upb/pb/compile_decoder_x64.dasc" # 793 "upb/pb/compile_decoder_x64.dasc"
assert(has_hash_entries); UPB_ASSERT(has_hash_entries);
/*| ld64 dispatch */ /*| ld64 dispatch */
{ {
uintptr_t v = (uintptr_t)dispatch; uintptr_t v = (uintptr_t)dispatch;
@ -1240,7 +1240,7 @@ static void jittag(jitcompiler *jc, uint64_t tag, int n, int ofs,
uint32_t *delimend = (jc->pc - 1) + last_arg; uint32_t *delimend = (jc->pc - 1) + last_arg;
const size_t ptr_words = sizeof(void*) / sizeof(uint32_t); const size_t ptr_words = sizeof(void*) / sizeof(uint32_t);
assert((last_instruction & 0xff) == OP_CHECKDELIM); UPB_ASSERT((last_instruction & 0xff) == OP_CHECKDELIM);
if (getop(*(jc->pc - 1)) == OP_TAGN) { if (getop(*(jc->pc - 1)) == OP_TAGN) {
jc->pc += ptr_words; jc->pc += ptr_words;
@ -1715,7 +1715,7 @@ static void jitbytecode(jitcompiler *jc) {
# 1132 "upb/pb/compile_decoder_x64.dasc" # 1132 "upb/pb/compile_decoder_x64.dasc"
break; break;
case OP_HALT: case OP_HALT:
assert(false); UPB_ASSERT(false);
} }
} }

@ -117,7 +117,7 @@ void upb_pbdecoder_seterr(upb_pbdecoder *d, const char *msg) {
/* How many bytes can be safely read from d->ptr without reading past end-of-buf /* How many bytes can be safely read from d->ptr without reading past end-of-buf
* or past the current delimited end. */ * or past the current delimited end. */
static size_t curbufleft(const upb_pbdecoder *d) { static size_t curbufleft(const upb_pbdecoder *d) {
assert(d->data_end >= d->ptr); UPB_ASSERT(d->data_end >= d->ptr);
return d->data_end - d->ptr; return d->data_end - d->ptr;
} }
@ -138,7 +138,7 @@ size_t delim_remaining(const upb_pbdecoder *d) {
/* Advances d->ptr. */ /* Advances d->ptr. */
static void advance(upb_pbdecoder *d, size_t len) { static void advance(upb_pbdecoder *d, size_t len) {
assert(curbufleft(d) >= len); UPB_ASSERT(curbufleft(d) >= len);
d->ptr += len; d->ptr += len;
} }
@ -171,7 +171,7 @@ static void switchtobuf(upb_pbdecoder *d, const char *buf, const char *end) {
} }
static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) { static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) {
assert(curbufleft(d) == 0); UPB_ASSERT(curbufleft(d) == 0);
d->bufstart_ofs += (d->end - d->buf); d->bufstart_ofs += (d->end - d->buf);
switchtobuf(d, buf, buf + len); switchtobuf(d, buf, buf + len);
} }
@ -180,7 +180,7 @@ static void checkpoint(upb_pbdecoder *d) {
/* The assertion here is in the interests of efficiency, not correctness. /* The assertion here is in the interests of efficiency, not correctness.
* We are trying to ensure that we don't checkpoint() more often than * We are trying to ensure that we don't checkpoint() more often than
* necessary. */ * necessary. */
assert(d->checkpoint != d->ptr); UPB_ASSERT(d->checkpoint != d->ptr);
d->checkpoint = d->ptr; d->checkpoint = d->ptr;
} }
@ -191,8 +191,8 @@ static void checkpoint(upb_pbdecoder *d) {
* won't actually be read. * won't actually be read.
*/ */
static int32_t skip(upb_pbdecoder *d, size_t bytes) { static int32_t skip(upb_pbdecoder *d, size_t bytes) {
assert(!in_residual_buf(d, d->ptr) || d->size_param == 0); UPB_ASSERT(!in_residual_buf(d, d->ptr) || d->size_param == 0);
assert(d->skip == 0); UPB_ASSERT(d->skip == 0);
if (bytes > delim_remaining(d)) { if (bytes > delim_remaining(d)) {
seterr(d, "Skipped value extended beyond enclosing submessage."); seterr(d, "Skipped value extended beyond enclosing submessage.");
return upb_pbdecoder_suspend(d); return upb_pbdecoder_suspend(d);
@ -220,7 +220,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf,
/* d->skip and d->residual_end could probably elegantly be represented /* d->skip and d->residual_end could probably elegantly be represented
* as a single variable, to more easily represent this invariant. */ * as a single variable, to more easily represent this invariant. */
assert(!(d->skip && d->residual_end > d->residual)); UPB_ASSERT(!(d->skip && d->residual_end > d->residual));
/* We need to remember the original size_param, so that the value we return /* We need to remember the original size_param, so that the value we return
* is relative to it, even if we do some skipping first. */ * is relative to it, even if we do some skipping first. */
@ -253,7 +253,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf,
if (d->residual_end > d->residual) { if (d->residual_end > d->residual) {
/* We have residual bytes from the last buffer. */ /* We have residual bytes from the last buffer. */
assert(d->ptr == d->residual); UPB_ASSERT(d->ptr == d->residual);
} else { } else {
switchtobuf(d, buf, buf + size); switchtobuf(d, buf, buf + size);
} }
@ -287,8 +287,8 @@ size_t upb_pbdecoder_suspend(upb_pbdecoder *d) {
return 0; return 0;
} else { } else {
size_t ret = d->size_param - (d->end - d->checkpoint); size_t ret = d->size_param - (d->end - d->checkpoint);
assert(!in_residual_buf(d, d->checkpoint)); UPB_ASSERT(!in_residual_buf(d, d->checkpoint));
assert(d->buf == d->buf_param || d->buf == &dummy_char); UPB_ASSERT(d->buf == d->buf_param || d->buf == &dummy_char);
d->bufstart_ofs += (d->checkpoint - d->buf); d->bufstart_ofs += (d->checkpoint - d->buf);
d->residual_end = d->residual; d->residual_end = d->residual;
@ -308,7 +308,7 @@ static size_t suspend_save(upb_pbdecoder *d) {
if (d->checkpoint == d->residual) { if (d->checkpoint == d->residual) {
/* Checkpoint was in residual buf; append user byte(s) to residual buf. */ /* Checkpoint was in residual buf; append user byte(s) to residual buf. */
assert((d->residual_end - d->residual) + d->size_param <= UPB_ASSERT((d->residual_end - d->residual) + d->size_param <=
sizeof(d->residual)); sizeof(d->residual));
if (!in_residual_buf(d, d->ptr)) { if (!in_residual_buf(d, d->ptr)) {
d->bufstart_ofs -= (d->residual_end - d->residual); d->bufstart_ofs -= (d->residual_end - d->residual);
@ -318,11 +318,11 @@ static size_t suspend_save(upb_pbdecoder *d) {
} else { } else {
/* Checkpoint was in user buf; old residual bytes not needed. */ /* Checkpoint was in user buf; old residual bytes not needed. */
size_t save; size_t save;
assert(!in_residual_buf(d, d->checkpoint)); UPB_ASSERT(!in_residual_buf(d, d->checkpoint));
d->ptr = d->checkpoint; d->ptr = d->checkpoint;
save = curbufleft(d); save = curbufleft(d);
assert(save <= sizeof(d->residual)); UPB_ASSERT(save <= sizeof(d->residual));
memcpy(d->residual, d->ptr, save); memcpy(d->residual, d->ptr, save);
d->residual_end = d->residual + save; d->residual_end = d->residual + save;
d->bufstart_ofs = offset(d); d->bufstart_ofs = offset(d);
@ -336,7 +336,7 @@ static size_t suspend_save(upb_pbdecoder *d) {
* Requires that this many bytes are available in the current buffer. */ * Requires that this many bytes are available in the current buffer. */
UPB_FORCEINLINE static void consumebytes(upb_pbdecoder *d, void *buf, UPB_FORCEINLINE static void consumebytes(upb_pbdecoder *d, void *buf,
size_t bytes) { size_t bytes) {
assert(bytes <= curbufleft(d)); UPB_ASSERT(bytes <= curbufleft(d));
memcpy(buf, d->ptr, bytes); memcpy(buf, d->ptr, bytes);
advance(d, bytes); advance(d, bytes);
} }
@ -349,7 +349,7 @@ UPB_NOINLINE static int32_t getbytes_slow(upb_pbdecoder *d, void *buf,
const size_t avail = curbufleft(d); const size_t avail = curbufleft(d);
consumebytes(d, buf, avail); consumebytes(d, buf, avail);
bytes -= avail; bytes -= avail;
assert(bytes > 0); UPB_ASSERT(bytes > 0);
if (in_residual_buf(d, d->ptr)) { if (in_residual_buf(d, d->ptr)) {
advancetobuf(d, d->buf_param, d->size_param); advancetobuf(d, d->buf_param, d->size_param);
} }
@ -532,7 +532,7 @@ UPB_NOINLINE int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d,
if (read == bytes && data == expected) { if (read == bytes && data == expected) {
/* Advance past matched bytes. */ /* Advance past matched bytes. */
int32_t ok = getbytes(d, &data, read); int32_t ok = getbytes(d, &data, read);
UPB_ASSERT_VAR(ok, ok < 0); UPB_ASSERT(ok < 0);
return DECODE_OK; return DECODE_OK;
} else if (read < bytes && memcmp(&data, &expected, read) == 0) { } else if (read < bytes && memcmp(&data, &expected, read) == 0) {
return suspend_save(d); return suspend_save(d);
@ -607,7 +607,7 @@ have_tag:
static void goto_endmsg(upb_pbdecoder *d) { static void goto_endmsg(upb_pbdecoder *d) {
upb_value v; upb_value v;
bool found = upb_inttable_lookup32(d->top->dispatch, DISPATCH_ENDMSG, &v); bool found = upb_inttable_lookup32(d->top->dispatch, DISPATCH_ENDMSG, &v);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
d->pc = d->top->base + upb_value_getuint64(v); d->pc = d->top->base + upb_value_getuint64(v);
} }
@ -641,7 +641,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
} else if (wire_type == ((v >> 8) & 0xff)) { } else if (wire_type == ((v >> 8) & 0xff)) {
bool found = bool found =
upb_inttable_lookup(dispatch, fieldnum + UPB_MAX_FIELDNUMBER, &val); upb_inttable_lookup(dispatch, fieldnum + UPB_MAX_FIELDNUMBER, &val);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
d->pc = d->top->base + upb_value_getuint64(val); d->pc = d->top->base + upb_value_getuint64(val);
return DECODE_OK; return DECODE_OK;
} }
@ -653,7 +653,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
* can re-check the delimited end. */ * can re-check the delimited end. */
d->last--; /* Necessary if we get suspended */ d->last--; /* Necessary if we get suspended */
d->pc = d->last; d->pc = d->last;
assert(getop(*d->last) == OP_CHECKDELIM); UPB_ASSERT(getop(*d->last) == OP_CHECKDELIM);
/* Unknown field or ENDGROUP. */ /* Unknown field or ENDGROUP. */
retval = upb_pbdecoder_skipunknown(d, fieldnum, wire_type); retval = upb_pbdecoder_skipunknown(d, fieldnum, wire_type);
@ -671,7 +671,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
/* Callers know that the stack is more than one deep because the opcodes that /* Callers know that the stack is more than one deep because the opcodes that
* call this only occur after PUSH operations. */ * call this only occur after PUSH operations. */
upb_pbdecoder_frame *outer_frame(upb_pbdecoder *d) { upb_pbdecoder_frame *outer_frame(upb_pbdecoder *d) {
assert(d->top != d->stack); UPB_ASSERT(d->top != d->stack);
return d->top - 1; return d->top - 1;
} }
@ -703,7 +703,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
op = getop(instruction); op = getop(instruction);
arg = instruction >> 8; arg = instruction >> 8;
longofs = arg; longofs = arg;
assert(d->ptr != d->residual_end); UPB_ASSERT(d->ptr != d->residual_end);
UPB_UNUSED(group); UPB_UNUSED(group);
#ifdef UPB_DUMP_BYTECODE #ifdef UPB_DUMP_BYTECODE
fprintf(stderr, "s_ofs=%d buf_ofs=%d data_rem=%d buf_rem=%d delim_rem=%d " fprintf(stderr, "s_ofs=%d buf_ofs=%d data_rem=%d buf_rem=%d delim_rem=%d "
@ -778,7 +778,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
} else { } else {
int32_t ret = skip(d, n); int32_t ret = skip(d, n);
/* This shouldn't return DECODE_OK, because n > len. */ /* This shouldn't return DECODE_OK, because n > len. */
assert(ret >= 0); UPB_ASSERT(ret >= 0);
return ret; return ret;
} }
} }
@ -800,7 +800,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
d->top->groupnum = *d->pc++; d->top->groupnum = *d->pc++;
) )
VMCASE(OP_POP, VMCASE(OP_POP,
assert(d->top > d->stack); UPB_ASSERT(d->top > d->stack);
decoder_pop(d); decoder_pop(d);
) )
VMCASE(OP_PUSHLENDELIM, VMCASE(OP_PUSHLENDELIM,
@ -816,7 +816,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
/* We are guaranteed of this assert because we never allow ourselves to /* We are guaranteed of this assert because we never allow ourselves to
* consume bytes beyond data_end, which covers delim_end when non-NULL. * consume bytes beyond data_end, which covers delim_end when non-NULL.
*/ */
assert(!(d->delim_end && d->ptr > d->delim_end)); UPB_ASSERT(!(d->delim_end && d->ptr > d->delim_end));
if (d->ptr == d->delim_end) if (d->ptr == d->delim_end)
d->pc += longofs; d->pc += longofs;
) )
@ -825,7 +825,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
d->pc += longofs; d->pc += longofs;
) )
VMCASE(OP_RET, VMCASE(OP_RET,
assert(d->call_len > 0); UPB_ASSERT(d->call_len > 0);
d->pc = d->callstack[--d->call_len]; d->pc = d->callstack[--d->call_len];
) )
VMCASE(OP_BRANCH, VMCASE(OP_BRANCH,
@ -952,7 +952,7 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) {
if (p != method->code_base.ptr) p--; if (p != method->code_base.ptr) p--;
if (getop(*p) == OP_CHECKDELIM) { if (getop(*p) == OP_CHECKDELIM) {
/* Rewind from OP_TAG* to OP_CHECKDELIM. */ /* Rewind from OP_TAG* to OP_CHECKDELIM. */
assert(getop(*d->pc) == OP_TAG1 || UPB_ASSERT(getop(*d->pc) == OP_TAG1 ||
getop(*d->pc) == OP_TAG2 || getop(*d->pc) == OP_TAG2 ||
getop(*d->pc) == OP_TAGN || getop(*d->pc) == OP_TAGN ||
getop(*d->pc) == OP_DISPATCH); getop(*d->pc) == OP_DISPATCH);
@ -1016,7 +1016,7 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m,
upb_pbdecoder_reset(d); upb_pbdecoder_reset(d);
upb_bytessink_reset(&d->input_, &m->input_handler_, d); upb_bytessink_reset(&d->input_, &m->input_handler_, d);
assert(sink); UPB_ASSERT(sink);
if (d->method_->dest_handlers_) { if (d->method_->dest_handlers_) {
if (sink->handlers != d->method_->dest_handlers_) if (sink->handlers != d->method_->dest_handlers_)
return NULL; return NULL;
@ -1024,7 +1024,8 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m,
upb_sink_reset(&d->top->sink, sink->handlers, sink->closure); upb_sink_reset(&d->top->sink, sink->handlers, sink->closure);
/* If this fails, increase the value in decoder.h. */ /* If this fails, increase the value in decoder.h. */
assert(upb_env_bytesallocated(e) - size_before <= UPB_PB_DECODER_SIZE); UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <=
UPB_PB_DECODER_SIZE);
return d; return d;
} }
@ -1045,7 +1046,7 @@ size_t upb_pbdecoder_maxnesting(const upb_pbdecoder *d) {
} }
bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) { bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) {
assert(d->top >= d->stack); UPB_ASSERT(d->top >= d->stack);
if (max < (size_t)(d->top - d->stack)) { if (max < (size_t)(d->top - d->stack)) {
/* Can't set a limit smaller than what we are currently at. */ /* Can't set a limit smaller than what we are currently at. */

@ -128,7 +128,7 @@ struct upb_pb_encoder {
/* TODO(haberman): handle pushback */ /* TODO(haberman): handle pushback */
static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) { static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) {
size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL); size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL);
UPB_ASSERT_VAR(n, n == len); UPB_ASSERT(n == len);
} }
static upb_pb_encoder_segment *top(upb_pb_encoder *e) { static upb_pb_encoder_segment *top(upb_pb_encoder *e) {
@ -168,7 +168,7 @@ static bool reserve(upb_pb_encoder *e, size_t bytes) {
/* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have /* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have
* previously called reserve() with at least this many bytes. */ * previously called reserve() with at least this many bytes. */
static void encoder_advance(upb_pb_encoder *e, size_t bytes) { static void encoder_advance(upb_pb_encoder *e, size_t bytes) {
assert((size_t)(e->limit - e->ptr) >= bytes); UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes);
e->ptr += bytes; e->ptr += bytes;
} }
@ -203,7 +203,7 @@ static bool encode_bytes(upb_pb_encoder *e, const void *data, size_t len) {
* length. */ * length. */
static void accumulate(upb_pb_encoder *e) { static void accumulate(upb_pb_encoder *e) {
size_t run_len; size_t run_len;
assert(e->ptr >= e->runbegin); UPB_ASSERT(e->ptr >= e->runbegin);
run_len = e->ptr - e->runbegin; run_len = e->ptr - e->runbegin;
e->segptr->seglen += run_len; e->segptr->seglen += run_len;
top(e)->msglen += run_len; top(e)->msglen += run_len;
@ -558,7 +558,8 @@ upb_pb_encoder *upb_pb_encoder_create(upb_env *env, const upb_handlers *h,
e->ptr = e->buf; e->ptr = e->buf;
/* If this fails, increase the value in encoder.h. */ /* If this fails, increase the value in encoder.h. */
assert(upb_env_bytesallocated(env) - size_before <= UPB_PB_ENCODER_SIZE); UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <=
UPB_PB_ENCODER_SIZE);
return e; return e;
} }

@ -112,7 +112,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) {
if (!str) return false; if (!str) return false;
written = vsprintf(str, fmt, args); written = vsprintf(str, fmt, args);
va_end(args); va_end(args);
UPB_ASSERT_VAR(written, written == len); UPB_ASSERT(written == len);
ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL); ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL);
upb_gfree(str); upb_gfree(str);

@ -154,9 +154,9 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) {
char buf[UPB_PB_VARINT_MAX_LEN]; char buf[UPB_PB_VARINT_MAX_LEN];
size_t bytes = upb_vencode64(val, buf); size_t bytes = upb_vencode64(val, buf);
uint64_t ret = 0; uint64_t ret = 0;
assert(bytes <= 5); UPB_ASSERT(bytes <= 5);
memcpy(&ret, buf, bytes); memcpy(&ret, buf, bytes);
assert(ret <= 0xffffffffffU); UPB_ASSERT(ret <= 0xffffffffffU);
return ret; return ret;
} }

@ -134,7 +134,7 @@ static trackedref *trackedref_new(bool is_ref2) {
static void track(const upb_refcounted *r, const void *owner, bool ref2) { static void track(const upb_refcounted *r, const void *owner, bool ref2) {
upb_value v; upb_value v;
assert(owner); UPB_ASSERT(owner);
if (owner == UPB_UNTRACKED_REF) return; if (owner == UPB_UNTRACKED_REF) return;
upb_lock(); upb_lock();
@ -145,8 +145,8 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) {
* tracking behavior we get with regular refs. Since ref2s only happen * tracking behavior we get with regular refs. Since ref2s only happen
* inside upb, we'll accept this limitation until/unless there is a really * inside upb, we'll accept this limitation until/unless there is a really
* difficult upb-internal bug that can't be figured out without it. */ * difficult upb-internal bug that can't be figured out without it. */
assert(ref2); UPB_ASSERT(ref2);
assert(ref->is_ref2); UPB_ASSERT(ref->is_ref2);
ref->count++; ref->count++;
} else { } else {
trackedref *ref = trackedref_new(ref2); trackedref *ref = trackedref_new(ref2);
@ -156,7 +156,7 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) {
/* We know this cast is safe when it is a ref2, because it's coming from /* We know this cast is safe when it is a ref2, because it's coming from
* another refcounted object. */ * another refcounted object. */
const upb_refcounted *from = owner; const upb_refcounted *from = owner;
assert(!upb_inttable_lookupptr(from->ref2s, r, NULL)); UPB_ASSERT(!upb_inttable_lookupptr(from->ref2s, r, NULL));
upb_inttable_insertptr2(from->ref2s, r, upb_value_ptr(NULL), upb_inttable_insertptr2(from->ref2s, r, upb_value_ptr(NULL),
&upb_alloc_debugrefs); &upb_alloc_debugrefs);
} }
@ -169,15 +169,15 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) {
bool found; bool found;
trackedref *ref; trackedref *ref;
assert(owner); UPB_ASSERT(owner);
if (owner == UPB_UNTRACKED_REF) return; if (owner == UPB_UNTRACKED_REF) return;
upb_lock(); upb_lock();
found = upb_inttable_lookupptr(r->refs, owner, &v); found = upb_inttable_lookupptr(r->refs, owner, &v);
/* This assert will fail if an owner attempts to release a ref it didn't have. */ /* This assert will fail if an owner attempts to release a ref it didn't have. */
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
ref = upb_value_getptr(v); ref = upb_value_getptr(v);
assert(ref->is_ref2 == ref2); UPB_ASSERT(ref->is_ref2 == ref2);
if (--ref->count == 0) { if (--ref->count == 0) {
free(ref); free(ref);
upb_inttable_removeptr(r->refs, owner, NULL); upb_inttable_removeptr(r->refs, owner, NULL);
@ -186,7 +186,7 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) {
* another refcounted object. */ * another refcounted object. */
const upb_refcounted *from = owner; const upb_refcounted *from = owner;
bool removed = upb_inttable_removeptr(from->ref2s, r, NULL); bool removed = upb_inttable_removeptr(from->ref2s, r, NULL);
assert(removed); UPB_ASSERT(removed);
} }
} }
upb_unlock(); upb_unlock();
@ -199,9 +199,9 @@ static void checkref(const upb_refcounted *r, const void *owner, bool ref2) {
upb_lock(); upb_lock();
found = upb_inttable_lookupptr(r->refs, owner, &v); found = upb_inttable_lookupptr(r->refs, owner, &v);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
ref = upb_value_getptr(v); ref = upb_value_getptr(v);
assert(ref->is_ref2 == ref2); UPB_ASSERT(ref->is_ref2 == ref2);
upb_unlock(); upb_unlock();
} }
@ -222,7 +222,7 @@ static void getref2s(const upb_refcounted *owner, upb_inttable *tab) {
/* To get the count we need to look in the target's table. */ /* To get the count we need to look in the target's table. */
found = upb_inttable_lookupptr(to->refs, owner, &v); found = upb_inttable_lookupptr(to->refs, owner, &v);
assert(found); UPB_ASSERT(found);
ref = upb_value_getptr(v); ref = upb_value_getptr(v);
count = upb_value_int32(ref->count); count = upb_value_int32(ref->count);
@ -244,12 +244,12 @@ static void visit_check(const upb_refcounted *obj, const upb_refcounted *subobj,
bool removed; bool removed;
int32_t newcount; int32_t newcount;
assert(obj == s->obj); UPB_ASSERT(obj == s->obj);
assert(subobj); UPB_ASSERT(subobj);
removed = upb_inttable_removeptr(ref2, subobj, &v); removed = upb_inttable_removeptr(ref2, subobj, &v);
/* The following assertion will fail if the visit() function visits a subobj /* The following assertion will fail if the visit() function visits a subobj
* that it did not have a ref2 on, or visits the same subobj too many times. */ * that it did not have a ref2 on, or visits the same subobj too many times. */
assert(removed); UPB_ASSERT(removed);
newcount = upb_value_getint32(v) - 1; newcount = upb_value_getint32(v) - 1;
if (newcount > 0) { if (newcount > 0) {
upb_inttable_insert2(ref2, (uintptr_t)subobj, upb_value_int32(newcount), upb_inttable_insert2(ref2, (uintptr_t)subobj, upb_value_int32(newcount),
@ -271,7 +271,7 @@ static void visit(const upb_refcounted *r, upb_refcounted_visit *v,
if (r->vtbl->visit) r->vtbl->visit(r, visit_check, &state); if (r->vtbl->visit) r->vtbl->visit(r, visit_check, &state);
/* This assertion will fail if the visit() function missed any children. */ /* This assertion will fail if the visit() function missed any children. */
assert(upb_inttable_count(&state.ref2) == 0); UPB_ASSERT(upb_inttable_count(&state.ref2) == 0);
upb_inttable_uninit2(&state.ref2, &upb_alloc_debugrefs); upb_inttable_uninit2(&state.ref2, &upb_alloc_debugrefs);
if (r->vtbl->visit) r->vtbl->visit(r, v, closure); if (r->vtbl->visit) r->vtbl->visit(r, v, closure);
} }
@ -378,7 +378,7 @@ static uint64_t trygetattr(const tarjan *t, const upb_refcounted *r) {
static uint64_t getattr(const tarjan *t, const upb_refcounted *r) { static uint64_t getattr(const tarjan *t, const upb_refcounted *r) {
upb_value v; upb_value v;
bool found = upb_inttable_lookupptr(&t->objattr, r, &v); bool found = upb_inttable_lookupptr(&t->objattr, r, &v);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
return upb_value_getuint64(v); return upb_value_getuint64(v);
} }
@ -392,13 +392,13 @@ static color_t color(tarjan *t, const upb_refcounted *r) {
} }
static void set_gray(tarjan *t, const upb_refcounted *r) { static void set_gray(tarjan *t, const upb_refcounted *r) {
assert(color(t, r) == BLACK); UPB_ASSERT(color(t, r) == BLACK);
setattr(t, r, GRAY); setattr(t, r, GRAY);
} }
/* Pushes an obj onto the Tarjan stack and sets it to GREEN. */ /* Pushes an obj onto the Tarjan stack and sets it to GREEN. */
static void push(tarjan *t, const upb_refcounted *r) { static void push(tarjan *t, const upb_refcounted *r) {
assert(color(t, r) == BLACK || color(t, r) == GRAY); UPB_ASSERT(color(t, r) == BLACK || color(t, r) == GRAY);
/* This defines the attr layout for the GREEN state. "index" and "lowlink" /* This defines the attr layout for the GREEN state. "index" and "lowlink"
* get 31 bits, which is plenty (limit of 2B objects frozen at a time). */ * get 31 bits, which is plenty (limit of 2B objects frozen at a time). */
setattr(t, r, GREEN | (t->index << 2) | (t->index << 33)); setattr(t, r, GREEN | (t->index << 2) | (t->index << 33));
@ -413,7 +413,7 @@ static void push(tarjan *t, const upb_refcounted *r) {
* SCC group. */ * SCC group. */
static upb_refcounted *pop(tarjan *t) { static upb_refcounted *pop(tarjan *t) {
upb_refcounted *r = upb_value_getptr(upb_inttable_pop(&t->stack)); upb_refcounted *r = upb_value_getptr(upb_inttable_pop(&t->stack));
assert(color(t, r) == GREEN); UPB_ASSERT(color(t, r) == GREEN);
/* This defines the attr layout for nodes in the WHITE state. /* This defines the attr layout for nodes in the WHITE state.
* Top of group stack is [group, NULL]; we point at group. */ * Top of group stack is [group, NULL]; we point at group. */
setattr(t, r, WHITE | (upb_inttable_count(&t->groups) - 2) << 8); setattr(t, r, WHITE | (upb_inttable_count(&t->groups) - 2) << 8);
@ -433,7 +433,7 @@ static void tarjan_newgroup(tarjan *t) {
} }
static uint32_t idx(tarjan *t, const upb_refcounted *r) { static uint32_t idx(tarjan *t, const upb_refcounted *r) {
assert(color(t, r) == GREEN); UPB_ASSERT(color(t, r) == GREEN);
return (getattr(t, r) >> 2) & 0x7FFFFFFF; return (getattr(t, r) >> 2) & 0x7FFFFFFF;
} }
@ -446,7 +446,7 @@ static uint32_t lowlink(tarjan *t, const upb_refcounted *r) {
} }
static void set_lowlink(tarjan *t, const upb_refcounted *r, uint32_t lowlink) { static void set_lowlink(tarjan *t, const upb_refcounted *r, uint32_t lowlink) {
assert(color(t, r) == GREEN); UPB_ASSERT(color(t, r) == GREEN);
setattr(t, r, ((uint64_t)lowlink << 33) | (getattr(t, r) & 0x1FFFFFFFF)); setattr(t, r, ((uint64_t)lowlink << 33) | (getattr(t, r) & 0x1FFFFFFFF));
} }
@ -455,10 +455,10 @@ static uint32_t *group(tarjan *t, upb_refcounted *r) {
upb_value v; upb_value v;
bool found; bool found;
assert(color(t, r) == WHITE); UPB_ASSERT(color(t, r) == WHITE);
groupnum = getattr(t, r) >> 8; groupnum = getattr(t, r) >> 8;
found = upb_inttable_lookup(&t->groups, groupnum, &v); found = upb_inttable_lookup(&t->groups, groupnum, &v);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
return upb_value_getptr(v); return upb_value_getptr(v);
} }
@ -469,10 +469,10 @@ static upb_refcounted *groupleader(tarjan *t, upb_refcounted *r) {
upb_value v; upb_value v;
bool found; bool found;
assert(color(t, r) == WHITE); UPB_ASSERT(color(t, r) == WHITE);
leader_slot = (getattr(t, r) >> 8) + 1; leader_slot = (getattr(t, r) >> 8) + 1;
found = upb_inttable_lookup(&t->groups, leader_slot, &v); found = upb_inttable_lookup(&t->groups, leader_slot, &v);
UPB_ASSERT_VAR(found, found); UPB_ASSERT(found);
if (upb_value_getptr(v)) { if (upb_value_getptr(v)) {
return upb_value_getptr(v); return upb_value_getptr(v);
} else { } else {
@ -532,7 +532,7 @@ static void do_tarjan(const upb_refcounted *obj, tarjan *t) {
static void crossref(const upb_refcounted *r, const upb_refcounted *subobj, static void crossref(const upb_refcounted *r, const upb_refcounted *subobj,
void *_t) { void *_t) {
tarjan *t = _t; tarjan *t = _t;
assert(color(t, r) > BLACK); UPB_ASSERT(color(t, r) > BLACK);
if (color(t, subobj) > BLACK && r->group != subobj->group) { if (color(t, subobj) > BLACK && r->group != subobj->group) {
/* Previously this ref was not reflected in subobj->group because they /* Previously this ref was not reflected in subobj->group because they
* were in the same group; now that they are split a ref must be taken. */ * were in the same group; now that they are split a ref must be taken. */
@ -600,13 +600,13 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s,
upb_refcounted *move = obj->next; upb_refcounted *move = obj->next;
if (obj == move) { if (obj == move) {
/* Removing the last object from a group. */ /* Removing the last object from a group. */
assert(*obj->group == obj->individual_count); UPB_ASSERT(*obj->group == obj->individual_count);
upb_gfree(obj->group); upb_gfree(obj->group);
} else { } else {
obj->next = move->next; obj->next = move->next;
/* This may decrease to zero; we'll collect GRAY objects (if any) that /* This may decrease to zero; we'll collect GRAY objects (if any) that
* remain in the group in the third pass. */ * remain in the group in the third pass. */
assert(*move->group >= move->individual_count); UPB_ASSERT(*move->group >= move->individual_count);
*move->group -= move->individual_count; *move->group -= move->individual_count;
} }
@ -619,7 +619,7 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s,
*move->group = move->individual_count; *move->group = move->individual_count;
} else { } else {
/* Group already has at least one object in it. */ /* Group already has at least one object in it. */
assert(leader->group == group(&t, move)); UPB_ASSERT(leader->group == group(&t, move));
move->group = group(&t, move); move->group = group(&t, move);
move->next = leader->next; move->next = leader->next;
leader->next = move; leader->next = move;
@ -726,7 +726,7 @@ static void release_ref2(const upb_refcounted *obj,
UPB_UNUSED(closure); UPB_UNUSED(closure);
untrack(subobj, obj, true); untrack(subobj, obj, true);
if (!merged(obj, subobj)) { if (!merged(obj, subobj)) {
assert(subobj->is_frozen); UPB_ASSERT(subobj->is_frozen);
unref(subobj); unref(subobj);
} }
} }
@ -745,7 +745,7 @@ static void unref(const upb_refcounted *r) {
o = r; o = r;
do { do {
const upb_refcounted *next = o->next; const upb_refcounted *next = o->next;
assert(o->is_frozen || o->individual_count == 0); UPB_ASSERT(o->is_frozen || o->individual_count == 0);
freeobj((upb_refcounted*)o); freeobj((upb_refcounted*)o);
o = next; o = next;
} while(o != r); } while(o != r);
@ -769,9 +769,9 @@ bool upb_refcounted_init(upb_refcounted *r,
* basically every program using upb. */ * basically every program using upb. */
const int x = 1; const int x = 1;
#ifdef UPB_BIG_ENDIAN #ifdef UPB_BIG_ENDIAN
assert(*(char*)&x != 1); UPB_ASSERT(*(char*)&x != 1);
#else #else
assert(*(char*)&x == 1); UPB_ASSERT(*(char*)&x == 1);
#endif #endif
#endif #endif
@ -806,7 +806,7 @@ void upb_refcounted_unref(const upb_refcounted *r, const void *owner) {
} }
void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) { void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) {
assert(!from->is_frozen); /* Non-const pointer implies this. */ UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */
track(r, from, true); track(r, from, true);
if (r->is_frozen) { if (r->is_frozen) {
refgroup(r->group); refgroup(r->group);
@ -816,18 +816,18 @@ void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) {
} }
void upb_refcounted_unref2(const upb_refcounted *r, upb_refcounted *from) { void upb_refcounted_unref2(const upb_refcounted *r, upb_refcounted *from) {
assert(!from->is_frozen); /* Non-const pointer implies this. */ UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */
untrack(r, from, true); untrack(r, from, true);
if (r->is_frozen) { if (r->is_frozen) {
unref(r); unref(r);
} else { } else {
assert(merged(r, from)); UPB_ASSERT(merged(r, from));
} }
} }
void upb_refcounted_donateref( void upb_refcounted_donateref(
const upb_refcounted *r, const void *from, const void *to) { const upb_refcounted *r, const void *from, const void *to) {
assert(from != to); UPB_ASSERT(from != to);
if (to != NULL) if (to != NULL)
upb_refcounted_ref(r, to); upb_refcounted_ref(r, to);
if (from != NULL) if (from != NULL)
@ -843,9 +843,9 @@ bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s,
int i; int i;
bool ret; bool ret;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
assert(!roots[i]->is_frozen); UPB_ASSERT(!roots[i]->is_frozen);
} }
ret = freeze(roots, n, s, maxdepth); ret = freeze(roots, n, s, maxdepth);
assert(!s || ret == upb_ok(s)); UPB_ASSERT(!s || ret == upb_ok(s));
return ret; return ret;
} }

@ -258,7 +258,7 @@ template <class T> class upb::reffed_ptr {
reffed_ptr(U* val, const void* ref_donor = NULL) reffed_ptr(U* val, const void* ref_donor = NULL)
: ptr_(upb::upcast(val)) { : ptr_(upb::upcast(val)) {
if (ref_donor) { if (ref_donor) {
assert(ptr_); UPB_ASSERT(ptr_);
ptr_->DonateRef(ref_donor, this); ptr_->DonateRef(ref_donor, this);
} else if (ptr_) { } else if (ptr_) {
ptr_->Ref(this); ptr_->Ref(this);
@ -303,12 +303,12 @@ template <class T> class upb::reffed_ptr {
} }
T& operator*() const { T& operator*() const {
assert(ptr_); UPB_ASSERT(ptr_);
return *ptr_; return *ptr_;
} }
T* operator->() const { T* operator->() const {
assert(ptr_); UPB_ASSERT(ptr_);
return ptr_; return ptr_;
} }

@ -50,7 +50,7 @@ bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
TYPE(DOUBLE, double); TYPE(DOUBLE, double);
TYPE(FLOAT, float); TYPE(FLOAT, float);
TYPE(BOOL, bool); TYPE(BOOL, bool);
default: assert(false); break; default: UPB_ASSERT(false); break;
} }
#undef TYPE #undef TYPE

@ -33,13 +33,13 @@ void upb_symtab_freeze(upb_symtab *s) {
upb_refcounted *r; upb_refcounted *r;
bool ok; bool ok;
assert(!upb_symtab_isfrozen(s)); UPB_ASSERT(!upb_symtab_isfrozen(s));
r = upb_symtab_upcast_mutable(s); r = upb_symtab_upcast_mutable(s);
/* The symtab does not take ref2's (see refcounted.h) on the defs, because /* The symtab does not take ref2's (see refcounted.h) on the defs, because
* defs cannot refer back to the table and therefore cannot create cycles. So * defs cannot refer back to the table and therefore cannot create cycles. So
* 0 will suffice for maxdepth here. */ * 0 will suffice for maxdepth here. */
ok = upb_refcounted_freeze(&r, 1, NULL, 0); ok = upb_refcounted_freeze(&r, 1, NULL, 0);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
} }
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) { const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) {
@ -77,7 +77,7 @@ static upb_def *upb_resolvename(const upb_strtable *t,
/* Remove components from base until we find an entry or run out. /* Remove components from base until we find an entry or run out.
* TODO: This branch is totally broken, but currently not used. */ * TODO: This branch is totally broken, but currently not used. */
(void)base; (void)base;
assert(false); UPB_ASSERT(false);
return NULL; return NULL;
} }
} }
@ -139,7 +139,7 @@ static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab,
upb_value v; upb_value v;
const upb_msgdef *m; const upb_msgdef *m;
assert(upb_def_isfrozen(def)); UPB_ASSERT(upb_def_isfrozen(def));
if (def->type == UPB_DEF_FIELD) continue; if (def->type == UPB_DEF_FIELD) continue;
if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) { if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) {
need_dup = true; need_dup = true;
@ -214,7 +214,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
return true; return true;
} }
assert(!upb_symtab_isfrozen(s)); UPB_ASSERT(!upb_symtab_isfrozen(s));
if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) { if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
upb_status_seterrmsg(status, "out of memory"); upb_status_seterrmsg(status, "out of memory");
return false; return false;
@ -230,7 +230,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
upb_status_seterrmsg(status, "added defs must be mutable"); upb_status_seterrmsg(status, "added defs must be mutable");
goto err; goto err;
} }
assert(!upb_def_isfrozen(def)); UPB_ASSERT(!upb_def_isfrozen(def));
fullname = upb_def_fullname(def); fullname = upb_def_fullname(def);
if (!fullname) { if (!fullname) {
upb_status_seterrmsg( upb_status_seterrmsg(
@ -274,7 +274,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
if (!f) continue; if (!f) continue;
msgname = upb_fielddef_containingtypename(f); msgname = upb_fielddef_containingtypename(f);
/* We validated this earlier in this function. */ /* We validated this earlier in this function. */
assert(msgname); UPB_ASSERT(msgname);
/* If the extendee name is absolutely qualified, move past the initial ".". /* If the extendee name is absolutely qualified, move past the initial ".".
* TODO(haberman): it is not obvious what it would mean if this was not * TODO(haberman): it is not obvious what it would mean if this was not
@ -405,7 +405,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
upb_def_unref(def, s); upb_def_unref(def, s);
} }
success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def)); success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
UPB_ASSERT_VAR(success, success == true); UPB_ASSERT(success == true);
} }
upb_gfree(add_defs); upb_gfree(add_defs);
return true; return true;
@ -429,7 +429,7 @@ err: {
} }
upb_strtable_uninit(&addtab); upb_strtable_uninit(&addtab);
upb_gfree(add_defs); upb_gfree(add_defs);
assert(!upb_ok(status)); UPB_ASSERT(!upb_ok(status));
return false; return false;
} }

@ -14,16 +14,11 @@
#define ARRAY_SIZE(x) \ #define ARRAY_SIZE(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#ifdef NDEBUG
static void upb_check_alloc(upb_table *t, upb_alloc *a) { static void upb_check_alloc(upb_table *t, upb_alloc *a) {
UPB_UNUSED(t); UPB_UNUSED(t);
UPB_UNUSED(a); UPB_UNUSED(a);
UPB_ASSERT_DEBUGVAR(t->alloc == a);
} }
#else
static void upb_check_alloc(upb_table *t, upb_alloc *a) {
assert(t->alloc == a);
}
#endif
static const double MAX_LOAD = 0.85; static const double MAX_LOAD = 0.85;
@ -132,7 +127,7 @@ static void uninit(upb_table *t, upb_alloc *a) {
static upb_tabent *emptyent(upb_table *t) { static upb_tabent *emptyent(upb_table *t) {
upb_tabent *e = mutable_entries(t) + upb_table_size(t); upb_tabent *e = mutable_entries(t) + upb_table_size(t);
while (1) { if (upb_tabent_isempty(--e)) return e; assert(e > t->entries); } while (1) { if (upb_tabent_isempty(--e)) return e; UPB_ASSERT(e > t->entries); }
} }
static upb_tabent *getentry_mutable(upb_table *t, uint32_t hash) { static upb_tabent *getentry_mutable(upb_table *t, uint32_t hash) {
@ -177,10 +172,8 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
upb_tabent *mainpos_e; upb_tabent *mainpos_e;
upb_tabent *our_e; upb_tabent *our_e;
UPB_UNUSED(eql); UPB_ASSERT(findentry(t, key, hash, eql) == NULL);
UPB_UNUSED(key); UPB_ASSERT_DEBUGVAR(val.ctype == t->ctype);
assert(findentry(t, key, hash, eql) == NULL);
assert(val.ctype == t->ctype);
t->count++; t->count++;
mainpos_e = getentry_mutable(t, hash); mainpos_e = getentry_mutable(t, hash);
@ -207,7 +200,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
*new_e = *mainpos_e; /* copies next. */ *new_e = *mainpos_e; /* copies next. */
while (chain->next != mainpos_e) { while (chain->next != mainpos_e) {
chain = (upb_tabent*)chain->next; chain = (upb_tabent*)chain->next;
assert(chain); UPB_ASSERT(chain);
} }
chain->next = new_e; chain->next = new_e;
our_e = mainpos_e; our_e = mainpos_e;
@ -216,7 +209,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
} }
our_e->key = tabkey; our_e->key = tabkey;
our_e->val.val = val.val; our_e->val.val = val.val;
assert(findentry(t, key, hash, eql) == our_e); UPB_ASSERT(findentry(t, key, hash, eql) == our_e);
} }
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
@ -397,19 +390,19 @@ bool upb_strtable_done(const upb_strtable_iter *i) {
} }
const char *upb_strtable_iter_key(const upb_strtable_iter *i) { const char *upb_strtable_iter_key(const upb_strtable_iter *i) {
assert(!upb_strtable_done(i)); UPB_ASSERT(!upb_strtable_done(i));
return upb_tabstr(str_tabent(i)->key, NULL); return upb_tabstr(str_tabent(i)->key, NULL);
} }
size_t upb_strtable_iter_keylength(const upb_strtable_iter *i) { size_t upb_strtable_iter_keylength(const upb_strtable_iter *i) {
uint32_t len; uint32_t len;
assert(!upb_strtable_done(i)); UPB_ASSERT(!upb_strtable_done(i));
upb_tabstr(str_tabent(i)->key, &len); upb_tabstr(str_tabent(i)->key, &len);
return len; return len;
} }
upb_value upb_strtable_iter_value(const upb_strtable_iter *i) { upb_value upb_strtable_iter_value(const upb_strtable_iter *i) {
assert(!upb_strtable_done(i)); UPB_ASSERT(!upb_strtable_done(i));
return _upb_value_val(str_tabent(i)->val.val, i->t->t.ctype); return _upb_value_val(str_tabent(i)->val.val, i->t->t.ctype);
} }
@ -468,9 +461,9 @@ static void check(upb_inttable *t) {
upb_inttable_iter i; upb_inttable_iter i;
upb_inttable_begin(&i, t); upb_inttable_begin(&i, t);
for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) { for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) {
assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); UPB_ASSERT(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL));
} }
assert(count == upb_inttable_count(t)); UPB_ASSERT(count == upb_inttable_count(t));
} }
#endif #endif
} }
@ -508,13 +501,12 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
upb_alloc *a) { upb_alloc *a) {
upb_tabval tabval; upb_tabval tabval;
tabval.val = val.val; tabval.val = val.val;
UPB_UNUSED(tabval); UPB_ASSERT(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */
assert(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */
upb_check_alloc(&t->t, a); upb_check_alloc(&t->t, a);
if (key < t->array_size) { if (key < t->array_size) {
assert(!upb_arrhas(t->array[key])); UPB_ASSERT(!upb_arrhas(t->array[key]));
t->array_count++; t->array_count++;
mutable_array(t)[key].val = val.val; mutable_array(t)[key].val = val.val;
} else { } else {
@ -537,7 +529,7 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql); insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
} }
assert(t->t.count == new_table.count); UPB_ASSERT(t->t.count == new_table.count);
uninit(&t->t, a); uninit(&t->t, a);
t->t = new_table; t->t = new_table;
@ -593,7 +585,7 @@ bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a) {
upb_value upb_inttable_pop(upb_inttable *t) { upb_value upb_inttable_pop(upb_inttable *t) {
upb_value val; upb_value val;
bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val); bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val);
UPB_ASSERT_VAR(ok, ok); UPB_ASSERT(ok);
return val; return val;
} }
@ -649,7 +641,7 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
arr_count -= counts[size_lg2]; arr_count -= counts[size_lg2];
} }
assert(arr_count <= upb_inttable_count(t)); UPB_ASSERT(arr_count <= upb_inttable_count(t));
{ {
/* Insert all elements into new, perfectly-sized table. */ /* Insert all elements into new, perfectly-sized table. */
@ -664,8 +656,8 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
uintptr_t k = upb_inttable_iter_key(&i); uintptr_t k = upb_inttable_iter_key(&i);
upb_inttable_insert2(&new_t, k, upb_inttable_iter_value(&i), a); upb_inttable_insert2(&new_t, k, upb_inttable_iter_value(&i), a);
} }
assert(new_t.array_size == arr_size); UPB_ASSERT(new_t.array_size == arr_size);
assert(new_t.t.size_lg2 == hashsize_lg2); UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2);
} }
upb_inttable_uninit2(t, a); upb_inttable_uninit2(t, a);
*t = new_t; *t = new_t;
@ -674,12 +666,12 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
/* Iteration. */ /* Iteration. */
static const upb_tabent *int_tabent(const upb_inttable_iter *i) { static const upb_tabent *int_tabent(const upb_inttable_iter *i) {
assert(!i->array_part); UPB_ASSERT(!i->array_part);
return &i->t->t.entries[i->index]; return &i->t->t.entries[i->index];
} }
static upb_tabval int_arrent(const upb_inttable_iter *i) { static upb_tabval int_arrent(const upb_inttable_iter *i) {
assert(i->array_part); UPB_ASSERT(i->array_part);
return i->t->array[i->index]; return i->t->array[i->index];
} }
@ -716,12 +708,12 @@ bool upb_inttable_done(const upb_inttable_iter *i) {
} }
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) { uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) {
assert(!upb_inttable_done(i)); UPB_ASSERT(!upb_inttable_done(i));
return i->array_part ? i->index : int_tabent(i)->key; return i->array_part ? i->index : int_tabent(i)->key;
} }
upb_value upb_inttable_iter_value(const upb_inttable_iter *i) { upb_value upb_inttable_iter_value(const upb_inttable_iter *i) {
assert(!upb_inttable_done(i)); UPB_ASSERT(!upb_inttable_done(i));
return _upb_value_val( return _upb_value_val(
i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val, i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val,
i->t->t.ctype); i->t->t.ctype);

@ -20,7 +20,6 @@
#ifndef UPB_TABLE_H_ #ifndef UPB_TABLE_H_
#define UPB_TABLE_H_ #define UPB_TABLE_H_
#include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "upb/upb.h" #include "upb/upb.h"
@ -103,7 +102,7 @@ UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) {
return ret; \ return ret; \
} \ } \
UPB_INLINE type_t upb_value_get ## name(upb_value val) { \ UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
assert(val.ctype == proto_type); \ UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \
return (type_t)(converter)val.val; \ return (type_t)(converter)val.val; \
} }

@ -21,7 +21,7 @@ bool upb_dumptostderr(void *closure, const upb_status* status) {
static void nullz(upb_status *status) { static void nullz(upb_status *status) {
const char *ellipsis = "..."; const char *ellipsis = "...";
size_t len = strlen(ellipsis); size_t len = strlen(ellipsis);
assert(sizeof(status->msg) > len); UPB_ASSERT(sizeof(status->msg) > len);
memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len); memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len);
} }

@ -196,10 +196,17 @@ template <int N> class InlinedEnvironment;
#define UPB_UNUSED(var) (void)var #define UPB_UNUSED(var) (void)var
/* For asserting something about a variable when the variable is not used for /* UPB_ASSERT(): in release mode, we use the expression without letting it be
* anything else. This prevents "unused variable" warnings when compiling in * evaluated. This prevents "unused variable" warnings. */
* debug mode. */ #ifdef NDEBUG
#define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate) #define UPB_ASSERT(expr) do {} while (false && (expr))
#else
#define UPB_ASSERT(expr) assert(expr)
#endif
/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
* exist in debug mode. This turns into regular assert. */
#define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
/* Generic function type. */ /* Generic function type. */
typedef void upb_func(); typedef void upb_func();
@ -434,13 +441,13 @@ struct upb_alloc {
}; };
UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) { UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
assert(size > 0); UPB_ASSERT(size > 0);
return alloc->func(alloc, NULL, 0, size); return alloc->func(alloc, NULL, 0, size);
} }
UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize, UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
size_t size) { size_t size) {
assert(size > 0); UPB_ASSERT(size > 0);
return alloc->func(alloc, ptr, oldsize, size); return alloc->func(alloc, ptr, oldsize, size);
} }

Loading…
Cancel
Save