aboutsummaryrefslogtreecommitdiff
path: root/third_party/upb/upb/mini_descriptor/internal
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/upb/upb/mini_descriptor/internal')
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/base92.c32
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/base92.h36
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/decoder.h32
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/encode.c53
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/encode.h34
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/encode.hpp60
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/encode_test.cc45
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/modifiers.h34
-rw-r--r--third_party/upb/upb/mini_descriptor/internal/wire_constants.h33
9 files changed, 102 insertions, 257 deletions
diff --git a/third_party/upb/upb/mini_descriptor/internal/base92.c b/third_party/upb/upb/mini_descriptor/internal/base92.c
index ed7132f3cb..18783d92a6 100644
--- a/third_party/upb/upb/mini_descriptor/internal/base92.c
+++ b/third_party/upb/upb/mini_descriptor/internal/base92.c
@@ -1,29 +1,9 @@
-/*
- * Copyright (c) 2009-2021, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#include "upb/mini_descriptor/internal/base92.h"
diff --git a/third_party/upb/upb/mini_descriptor/internal/base92.h b/third_party/upb/upb/mini_descriptor/internal/base92.h
index 7628baccb1..4201c25c5b 100644
--- a/third_party/upb/upb/mini_descriptor/internal/base92.h
+++ b/third_party/upb/upb/mini_descriptor/internal/base92.h
@@ -1,34 +1,16 @@
-/*
- * Copyright (c) 2009-2022, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
-#include "upb/base/log2.h"
+#include <stdint.h>
+
+#include "upb/base/internal/log2.h"
// Must be last.
#include "upb/port/def.inc"
diff --git a/third_party/upb/upb/mini_descriptor/internal/decoder.h b/third_party/upb/upb/mini_descriptor/internal/decoder.h
index 7f94a5ea81..9ac3282004 100644
--- a/third_party/upb/upb/mini_descriptor/internal/decoder.h
+++ b/third_party/upb/upb/mini_descriptor/internal/decoder.h
@@ -1,29 +1,9 @@
-/*
- * Copyright (c) 2009-2021, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_DECODER_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_DECODER_H_
diff --git a/third_party/upb/upb/mini_descriptor/internal/encode.c b/third_party/upb/upb/mini_descriptor/internal/encode.c
index d7aeeddcc1..2193ffeb8f 100644
--- a/third_party/upb/upb/mini_descriptor/internal/encode.c
+++ b/third_party/upb/upb/mini_descriptor/internal/encode.c
@@ -1,33 +1,17 @@
-/*
- * Copyright (c) 2009-2021, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#include "upb/mini_descriptor/internal/encode.h"
-#include "upb/base/log2.h"
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "upb/base/internal/log2.h"
#include "upb/mini_descriptor/internal/base92.h"
#include "upb/mini_descriptor/internal/modifiers.h"
#include "upb/mini_descriptor/internal/wire_constants.h"
@@ -225,6 +209,19 @@ static char* _upb_MtDataEncoder_MaybePutModifiers(upb_MtDataEncoder* e,
}
}
+ if (type == kUpb_FieldType_String) {
+ bool field_validates_utf8 = field_mod & kUpb_FieldModifier_ValidateUtf8;
+ bool message_validates_utf8 =
+ in->state.msg_state.msg_modifiers & kUpb_MessageModifier_ValidateUtf8;
+ if (field_validates_utf8 != message_validates_utf8) {
+ // Old binaries do not recognize the field modifier. We need the failure
+ // mode to be too lax rather than too strict. Our caller should have
+ // handled this (see _upb_MessageDef_ValidateUtf8()).
+ assert(!message_validates_utf8);
+ encoded_modifiers |= kUpb_EncodedFieldModifier_FlipValidateUtf8;
+ }
+ }
+
if (field_mod & kUpb_FieldModifier_IsProto3Singular) {
encoded_modifiers |= kUpb_EncodedFieldModifier_IsProto3Singular;
}
@@ -295,7 +292,7 @@ static char* upb_MtDataEncoder_FlushDenseEnumMask(upb_MtDataEncoder* e,
char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr,
uint32_t val) {
- // TODO(b/229641772): optimize this encoding.
+ // TODO: optimize this encoding.
upb_MtDataEncoderInternal* in = upb_MtDataEncoder_GetInternal(e, ptr);
UPB_ASSERT(val >= in->state.enum_state.last_written_value);
uint32_t delta = val - in->state.enum_state.last_written_value;
diff --git a/third_party/upb/upb/mini_descriptor/internal/encode.h b/third_party/upb/upb/mini_descriptor/internal/encode.h
index 7d465289b2..3180f0bdc5 100644
--- a/third_party/upb/upb/mini_descriptor/internal/encode.h
+++ b/third_party/upb/upb/mini_descriptor/internal/encode.h
@@ -1,33 +1,15 @@
-/*
- * Copyright (c) 2009-2022, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_
+#include <stdint.h>
+
#include "upb/base/descriptor_constants.h"
// Must be last.
diff --git a/third_party/upb/upb/mini_descriptor/internal/encode.hpp b/third_party/upb/upb/mini_descriptor/internal/encode.hpp
index 1d22a76469..cfa3bed6cc 100644
--- a/third_party/upb/upb/mini_descriptor/internal/encode.hpp
+++ b/third_party/upb/upb/mini_descriptor/internal/encode.hpp
@@ -1,36 +1,16 @@
-/*
- * Copyright (c) 2009-2021, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_TABLE_ENCODE_INTERNAL_HPP_
#define UPB_MINI_TABLE_ENCODE_INTERNAL_HPP_
#include <string>
-#include "upb/base/log2.h"
+#include "upb/base/internal/log2.h"
#include "upb/mini_descriptor/internal/encode.h"
namespace upb {
@@ -40,49 +20,51 @@ class MtDataEncoder {
MtDataEncoder() : appender_(&encoder_) {}
bool StartMessage(uint64_t msg_mod) {
- return appender_([=](char* buf) {
+ return appender_([this, msg_mod](char* buf) {
return upb_MtDataEncoder_StartMessage(&encoder_, buf, msg_mod);
});
}
bool PutField(upb_FieldType type, uint32_t field_num, uint64_t field_mod) {
- return appender_([=](char* buf) {
+ return appender_([this, type, field_num, field_mod](char* buf) {
return upb_MtDataEncoder_PutField(&encoder_, buf, type, field_num,
field_mod);
});
}
bool StartOneof() {
- return appender_([=](char* buf) {
+ return appender_([this](char* buf) {
return upb_MtDataEncoder_StartOneof(&encoder_, buf);
});
}
bool PutOneofField(uint32_t field_num) {
- return appender_([=](char* buf) {
+ return appender_([this, field_num](char* buf) {
return upb_MtDataEncoder_PutOneofField(&encoder_, buf, field_num);
});
}
bool StartEnum() {
- return appender_(
- [=](char* buf) { return upb_MtDataEncoder_StartEnum(&encoder_, buf); });
+ return appender_([this](char* buf) {
+ return upb_MtDataEncoder_StartEnum(&encoder_, buf);
+ });
}
bool PutEnumValue(uint32_t enum_value) {
- return appender_([=](char* buf) {
+ return appender_([this, enum_value](char* buf) {
return upb_MtDataEncoder_PutEnumValue(&encoder_, buf, enum_value);
});
}
bool EndEnum() {
- return appender_(
- [=](char* buf) { return upb_MtDataEncoder_EndEnum(&encoder_, buf); });
+ return appender_([this](char* buf) {
+ return upb_MtDataEncoder_EndEnum(&encoder_, buf);
+ });
}
bool EncodeExtension(upb_FieldType type, uint32_t field_num,
uint64_t field_mod) {
- return appender_([=](char* buf) {
+ return appender_([this, type, field_num, field_mod](char* buf) {
return upb_MtDataEncoder_EncodeExtension(&encoder_, buf, type, field_num,
field_mod);
});
@@ -90,14 +72,14 @@ class MtDataEncoder {
bool EncodeMap(upb_FieldType key_type, upb_FieldType val_type,
uint64_t key_mod, uint64_t val_mod) {
- return appender_([=](char* buf) {
+ return appender_([this, key_type, val_type, key_mod, val_mod](char* buf) {
return upb_MtDataEncoder_EncodeMap(&encoder_, buf, key_type, val_type,
key_mod, val_mod);
});
}
bool EncodeMessageSet() {
- return appender_([=](char* buf) {
+ return appender_([this](char* buf) {
return upb_MtDataEncoder_EncodeMessageSet(&encoder_, buf);
});
}
diff --git a/third_party/upb/upb/mini_descriptor/internal/encode_test.cc b/third_party/upb/upb/mini_descriptor/internal/encode_test.cc
index 61127c5968..dcb33b5aae 100644
--- a/third_party/upb/upb/mini_descriptor/internal/encode_test.cc
+++ b/third_party/upb/upb/mini_descriptor/internal/encode_test.cc
@@ -1,45 +1,26 @@
-/*
- * Copyright (c) 2009-2021, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#include "upb/mini_descriptor/internal/encode.hpp"
#include <string_view>
#include <vector>
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
#include "absl/container/flat_hash_set.h"
#include "google/protobuf/descriptor.h"
-#include "upb/message/accessors_internal.h"
+#include "upb/base/status.hpp"
+#include "upb/mem/arena.hpp"
+#include "upb/message/internal/accessors.h"
#include "upb/mini_descriptor/decode.h"
#include "upb/mini_descriptor/internal/base92.h"
#include "upb/mini_descriptor/internal/modifiers.h"
#include "upb/mini_table/enum.h"
-#include "upb/upb.hpp"
#include "upb/wire/decode.h"
// begin:google_only
@@ -54,7 +35,7 @@ TEST_P(MiniTableTest, Empty) {
upb::Arena arena;
upb::Status status;
upb_MiniTable* table =
- _upb_MiniTable_Build(NULL, 0, GetParam(), arena.ptr(), status.ptr());
+ _upb_MiniTable_Build(nullptr, 0, GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(0, table->field_count);
EXPECT_EQ(0, table->required_count);
@@ -287,10 +268,8 @@ TEST_P(MiniTableTest, Extendible) {
upb::Arena arena;
upb::MtDataEncoder e;
ASSERT_TRUE(e.StartMessage(kUpb_MessageModifier_IsExtendable));
- int count = 0;
for (int i = kUpb_FieldType_Double; i < kUpb_FieldType_SInt64; i++) {
ASSERT_TRUE(e.PutField(static_cast<upb_FieldType>(i), i, 0));
- count++;
}
upb::Status status;
upb_MiniTable* table = _upb_MiniTable_Build(
diff --git a/third_party/upb/upb/mini_descriptor/internal/modifiers.h b/third_party/upb/upb/mini_descriptor/internal/modifiers.h
index 6f74344cdd..103b279cb6 100644
--- a/third_party/upb/upb/mini_descriptor/internal/modifiers.h
+++ b/third_party/upb/upb/mini_descriptor/internal/modifiers.h
@@ -1,29 +1,9 @@
-/*
- * Copyright (c) 2009-2022, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_MODIFIERS_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_MODIFIERS_H_
@@ -37,8 +17,10 @@ typedef enum {
kUpb_FieldModifier_IsClosedEnum = 1 << 2,
kUpb_FieldModifier_IsProto3Singular = 1 << 3,
kUpb_FieldModifier_IsRequired = 1 << 4,
+ kUpb_FieldModifier_ValidateUtf8 = 1 << 5,
} kUpb_FieldModifier;
+// These modifiers are also used on the wire.
typedef enum {
kUpb_MessageModifier_ValidateUtf8 = 1 << 0,
kUpb_MessageModifier_DefaultIsPacked = 1 << 1,
diff --git a/third_party/upb/upb/mini_descriptor/internal/wire_constants.h b/third_party/upb/upb/mini_descriptor/internal/wire_constants.h
index b9dff4ea66..569da57755 100644
--- a/third_party/upb/upb/mini_descriptor/internal/wire_constants.h
+++ b/third_party/upb/upb/mini_descriptor/internal/wire_constants.h
@@ -1,29 +1,9 @@
-/*
- * Copyright (c) 2009-2022, Google LLC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Google LLC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google LLC. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_WIRE_CONSTANTS_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_WIRE_CONSTANTS_H_
@@ -61,6 +41,7 @@ typedef enum {
kUpb_EncodedFieldModifier_FlipPacked = 1 << 0,
kUpb_EncodedFieldModifier_IsRequired = 1 << 1,
kUpb_EncodedFieldModifier_IsProto3Singular = 1 << 2,
+ kUpb_EncodedFieldModifier_FlipValidateUtf8 = 1 << 3,
} upb_EncodedFieldModifier;
enum {