Merge pull request #10059 from shaod2/sync-stage

Integrate from Piper for C++, Java, and Python
pull/10083/head
Dennis Shao 3 years ago committed by GitHub
commit a11fa4529f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
  2. 69
      java/core/src/main/java/com/google/protobuf/MessageLite.java
  3. 1
      java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
  4. 2
      java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java
  5. 7
      java/core/src/test/java/com/google/protobuf/TestUtil.java
  6. 47
      src/google/protobuf/arena.h
  7. 20
      src/google/protobuf/arena_unittest.cc
  8. 2
      src/google/protobuf/compiler/cpp/generator.cc
  9. 1
      src/google/protobuf/compiler/cpp/options.h
  10. 4
      src/google/protobuf/generated_message_reflection_unittest.cc
  11. 81
      src/google/protobuf/generated_message_tctable_impl.h
  12. 3
      src/google/protobuf/map.h
  13. 10
      src/google/protobuf/repeated_field.h
  14. 13
      src/google/protobuf/repeated_ptr_field.h
  15. 2
      src/google/protobuf/stubs/common.cc
  16. 3
      src/google/protobuf/util/internal/protostream_objectsource.h

@ -151,7 +151,7 @@ public class ProtoCaliperBenchmark {
}
}
@SuppressWarnings("IgnoredPureGetter")
@SuppressWarnings({"IgnoredPureGetter", "CheckReturnValue"})
@Benchmark
void serializeToByteArray(int reps) throws IOException {
if (sampleMessageList.size() == 0) {

@ -59,6 +59,7 @@ import java.io.OutputStream;
*
* @author kenton@google.com Kenton Varda
*/
@CheckReturnValue
public interface MessageLite extends MessageLiteOrBuilder {
/**
@ -138,6 +139,7 @@ public interface MessageLite extends MessageLiteOrBuilder {
/** Abstract interface implemented by Protocol Message builders. */
interface Builder extends MessageLiteOrBuilder, Cloneable {
/** Resets all fields to their default values. */
@CanIgnoreReturnValue
Builder clear();
/**
@ -181,11 +183,12 @@ public interface MessageLite extends MessageLiteOrBuilder {
* <p>Note: The caller should call {@link CodedInputStream#checkLastTagWas(int)} after calling
* this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.
*
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
* a protobuf in the first place.
* @throws IOException an I/O error reading from the stream
*/
@CanIgnoreReturnValue
Builder mergeFrom(CodedInputStream input) throws IOException;
/**
@ -193,11 +196,12 @@ public interface MessageLite extends MessageLiteOrBuilder {
* that you want to be able to parse must be registered in {@code extensionRegistry}. Extensions
* not in the registry will be treated as unknown fields.
*
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
* a protobuf in the first place.
* @throws IOException an I/O error reading from the stream
*/
@CanIgnoreReturnValue
Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws IOException;
@ -209,10 +213,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException;
/**
@ -220,10 +225,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException;
@ -232,10 +238,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException;
/**
@ -243,10 +250,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException;
/**
@ -254,10 +262,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException;
@ -266,10 +275,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
*
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
* was never a protobuf in the first place.
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException;
@ -283,12 +293,13 @@ public interface MessageLite extends MessageLiteOrBuilder {
*
* <p>Despite usually reading the entire input, this does not close the stream.
*
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
* a protobuf in the first place.
* @throws IOException an I/O error reading from the stream
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(InputStream input) throws IOException;
/**
@ -298,6 +309,7 @@ public interface MessageLite extends MessageLiteOrBuilder {
*
* @return this
*/
@CanIgnoreReturnValue
Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
throws IOException;
@ -317,6 +329,7 @@ public interface MessageLite extends MessageLiteOrBuilder {
*
* <p>This is equivalent to the {@code Message::MergeFrom} method in C++.
*/
@CanIgnoreReturnValue
Builder mergeFrom(MessageLite other);
/**
@ -326,11 +339,12 @@ public interface MessageLite extends MessageLiteOrBuilder {
*
* @return true if successful, or false if the stream is at EOF when the method starts. Any
* other error (including reaching EOF during parsing) causes an exception to be thrown.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
* a protobuf in the first place.
* @throws IOException an I/O error reading from the stream
*/
@CanIgnoreReturnValue // TODO(kak): should this be @CheckReturnValue instead?
boolean mergeDelimitedFrom(InputStream input) throws IOException;
/**
@ -338,11 +352,12 @@ public interface MessageLite extends MessageLiteOrBuilder {
*
* @return true if successful, or false if the stream is at EOF when the method starts. Any
* other error (including reaching EOF during parsing) causes an exception to be thrown.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
* according to the protobuf wire format specification. The data is corrupt, incomplete,
* or was never a protobuf in the first place.
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
* a protobuf in the first place.
* @throws IOException an I/O error reading from the stream
*/
@CanIgnoreReturnValue // TODO(kak): should this be @CheckReturnValue instead?
boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
throws IOException;
}

@ -36,6 +36,7 @@ package com.google.protobuf;
*
* @author jonp@google.com (Jon Perlow)
*/
@CheckReturnValue
public interface MessageLiteOrBuilder {
/**
* Get an instance of the type with no fields set. Because no fields are set, all getters for

@ -1529,7 +1529,7 @@ public class GeneratedMessageTest {
assertThat(builder.getFooInt()).isEqualTo(123);
TestOneof2 message = builder.buildPartial();
assertThat(message.hasFooInt()).isTrue();
assertThat(123).isEqualTo(message.getFooInt());
assertThat(message.getFooInt()).isEqualTo(123);
assertThat(builder.clearFooInt().hasFooInt()).isFalse();
TestOneof2 message2 = builder.build();

@ -235,6 +235,7 @@ import protobuf_unittest.UnittestProto.TestRequired;
import protobuf_unittest.UnittestProto.TestUnpackedTypes;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collections;
@ -3842,7 +3843,11 @@ public final class TestUtil {
private static ByteString readBytesFromResource(String name) {
try {
return ByteString.readFrom(TestUtil.class.getResourceAsStream(name));
InputStream in = TestUtil.class.getResourceAsStream(name);
if (in == null) { //
throw new RuntimeException("Tests data file " + name + " is missing.");
}
return ByteString.readFrom(in);
} catch (IOException e) {
throw new RuntimeException(e);
}

@ -315,6 +315,15 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
static_cast<Args&&>(args)...);
}
// API to delete any objects not on an arena. This can be used to safely
// clean up messages or repeated fields without knowing whether or not they're
// owned by an arena. The pointer passed to this function should not be used
// again.
template <typename T>
PROTOBUF_ALWAYS_INLINE static void Destroy(T* obj) {
if (InternalGetOwningArena(obj) == nullptr) delete obj;
}
// Allocates memory with the specific size and alignment.
void* AllocateAligned(size_t size, size_t align = 8) {
if (align <= 8) {
@ -411,8 +420,23 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
template <typename T>
class InternalHelper {
private:
// Provides access to protected GetOwningArena to generated messages.
static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); }
struct Rank1 {};
struct Rank0 : Rank1 {};
static Arena* GetOwningArena(const T* p) {
return GetOwningArena(Rank0{}, p);
}
template <typename U>
static auto GetOwningArena(Rank0, const U* p)
-> decltype(p->GetOwningArena()) {
return p->GetOwningArena();
}
template <typename U>
static Arena* GetOwningArena(Rank1, const U* p) {
return nullptr;
}
static void InternalSwap(T* a, T* b) { a->InternalSwap(b); }
@ -771,25 +795,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
return nullptr;
}
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArena(const T* value) {
return GetOwningArenaInternal(
value, std::is_convertible<T*, MessageLite*>());
}
// Implementation for GetOwningArena(). All and only message objects have
// GetOwningArena() method.
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
const T* value, std::true_type) {
return InternalHelper<T>::GetOwningArena(value);
}
template <typename T>
PROTOBUF_ALWAYS_INLINE static Arena* GetOwningArenaInternal(
const T* /* value */, std::false_type) {
return nullptr;
}
void* AllocateAlignedWithHookForArray(size_t n, size_t align,
const std::type_info* type) {
if (align <= 8) {

@ -307,6 +307,26 @@ TEST(ArenaTest, InitialBlockTooSmall) {
}
}
TEST(ArenaTest, CreateDestroy) {
TestAllTypes original;
TestUtil::SetAllFields(&original);
// Test memory leak.
Arena arena;
TestAllTypes* heap_message = Arena::CreateMessage<TestAllTypes>(nullptr);
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
*heap_message = original;
*arena_message = original;
Arena::Destroy(heap_message);
Arena::Destroy(arena_message);
// The arena message should still exist.
EXPECT_EQ(strlen(original.optional_string().c_str()),
strlen(arena_message->optional_string().c_str()));
}
TEST(ArenaTest, Parsing) {
TestAllTypes original;
TestUtil::SetAllFields(&original);

@ -135,8 +135,6 @@ bool CppGenerator::Generate(const FileDescriptor* file,
.insert(options[i].second.substr(pos, next_pos - pos));
pos = next_pos + 1;
} while (pos < options[i].second.size());
} else if (options[i].first == "verified_lazy") {
file_options.unverified_lazy = false;
} else if (options[i].first == "unverified_lazy_message_sets") {
file_options.unverified_lazy_message_sets = true;
} else if (options[i].first == "message_owned_arena_trial") {

@ -80,7 +80,6 @@ struct Options {
bool annotate_accessor = false;
bool unused_field_stripping = false;
bool unverified_lazy_message_sets = false;
bool unverified_lazy = false;
bool profile_driven_inline_string = true;
bool message_owned_arena_trial = false;
bool force_split = false;

@ -1261,8 +1261,6 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) {
const Reflection* reflection = message.GetReflection();
const Descriptor* descriptor = message.GetDescriptor();
#define f(NAME) descriptor->FindFieldByName(NAME)
// Testing every single failure mode would be too much work. Let's just
// check a few.
EXPECT_DEATH(
@ -1301,8 +1299,6 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) {
" Message type: protobuf_unittest.TestAllTypes\n"
" Field : protobuf_unittest.ForeignMessage.c\n"
" Problem : Field does not match message type.");
#undef f
}
#endif // PROTOBUF_HAS_DEATH_TEST

@ -187,48 +187,48 @@ static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
// Convenience aliases (16 bits, with format):
enum FieldType : uint16_t {
// Numeric types:
kBool = kFkVarint | kRep8Bits,
kFixed32 = kFkFixed | kRep32Bits | kFmtUnsigned,
kUInt32 = kFkVarint | kRep32Bits | kFmtUnsigned,
kSFixed32 = kFkFixed | kRep32Bits | kFmtSigned,
kInt32 = kFkVarint | kRep32Bits | kFmtSigned,
kSInt32 = kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag,
kFloat = kFkFixed | kRep32Bits | kFmtFloating,
kEnum = kFkVarint | kRep32Bits | kFmtEnum | kTvEnum,
kEnumRange = kFkVarint | kRep32Bits | kFmtEnum | kTvRange,
kOpenEnum = kFkVarint | kRep32Bits | kFmtEnum,
kFixed64 = kFkFixed | kRep64Bits | kFmtUnsigned,
kUInt64 = kFkVarint | kRep64Bits | kFmtUnsigned,
kSFixed64 = kFkFixed | kRep64Bits | kFmtSigned,
kInt64 = kFkVarint | kRep64Bits | kFmtSigned,
kSInt64 = kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag,
kDouble = kFkFixed | kRep64Bits | kFmtFloating,
kPackedBool = kFkPackedVarint | kRep8Bits,
kPackedFixed32 = kFkPackedFixed | kRep32Bits | kFmtUnsigned,
kPackedUInt32 = kFkPackedVarint | kRep32Bits | kFmtUnsigned,
kPackedSFixed32 = kFkPackedFixed | kRep32Bits | kFmtSigned,
kPackedInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned,
kPackedSInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag,
kPackedFloat = kFkPackedFixed | kRep32Bits | kFmtFloating,
kPackedEnum = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum,
kPackedEnumRange = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange,
kPackedOpenEnum = kFkPackedVarint | kRep32Bits | kFmtEnum,
kPackedFixed64 = kFkPackedFixed | kRep64Bits | kFmtUnsigned,
kPackedUInt64 = kFkPackedVarint | kRep64Bits | kFmtUnsigned,
kPackedSFixed64 = kFkPackedFixed | kRep64Bits | kFmtSigned,
kPackedInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned,
kPackedSInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag,
kPackedDouble = kFkPackedFixed | kRep64Bits | kFmtFloating,
kBool = 0 | kFkVarint | kRep8Bits,
kFixed32 = 0 | kFkFixed | kRep32Bits | kFmtUnsigned,
kUInt32 = 0 | kFkVarint | kRep32Bits | kFmtUnsigned,
kSFixed32 = 0 | kFkFixed | kRep32Bits | kFmtSigned,
kInt32 = 0 | kFkVarint | kRep32Bits | kFmtSigned,
kSInt32 = 0 | kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag,
kFloat = 0 | kFkFixed | kRep32Bits | kFmtFloating,
kEnum = 0 | kFkVarint | kRep32Bits | kFmtEnum | kTvEnum,
kEnumRange = 0 | kFkVarint | kRep32Bits | kFmtEnum | kTvRange,
kOpenEnum = 0 | kFkVarint | kRep32Bits | kFmtEnum,
kFixed64 = 0 | kFkFixed | kRep64Bits | kFmtUnsigned,
kUInt64 = 0 | kFkVarint | kRep64Bits | kFmtUnsigned,
kSFixed64 = 0 | kFkFixed | kRep64Bits | kFmtSigned,
kInt64 = 0 | kFkVarint | kRep64Bits | kFmtSigned,
kSInt64 = 0 | kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag,
kDouble = 0 | kFkFixed | kRep64Bits | kFmtFloating,
kPackedBool = 0 | kFkPackedVarint | kRep8Bits,
kPackedFixed32 = 0 | kFkPackedFixed | kRep32Bits | kFmtUnsigned,
kPackedUInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtUnsigned,
kPackedSFixed32 = 0 | kFkPackedFixed | kRep32Bits | kFmtSigned,
kPackedInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtSigned,
kPackedSInt32 = 0 | kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag,
kPackedFloat = 0 | kFkPackedFixed | kRep32Bits | kFmtFloating,
kPackedEnum = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum,
kPackedEnumRange = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange,
kPackedOpenEnum = 0 | kFkPackedVarint | kRep32Bits | kFmtEnum,
kPackedFixed64 = 0 | kFkPackedFixed | kRep64Bits | kFmtUnsigned,
kPackedUInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtUnsigned,
kPackedSFixed64 = 0 | kFkPackedFixed | kRep64Bits | kFmtSigned,
kPackedInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtSigned,
kPackedSInt64 = 0 | kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag,
kPackedDouble = 0 | kFkPackedFixed | kRep64Bits | kFmtFloating,
// String types:
kBytes = kFkString | kFmtArray,
kRawString = kFkString | kFmtUtf8 | kTvUtf8Debug,
kUtf8String = kFkString | kFmtUtf8 | kTvUtf8,
kBytes = 0 | kFkString | kFmtArray,
kRawString = 0 | kFkString | kFmtUtf8 | kTvUtf8Debug,
kUtf8String = 0 | kFkString | kFmtUtf8 | kTvUtf8,
// Message types:
kMessage = kFkMessage,
@ -236,7 +236,6 @@ enum FieldType : uint16_t {
// Map types:
kMap = kFkMap,
};
// clang-format on
} // namespace field_layout

@ -1364,7 +1364,8 @@ class Map {
template <class InputIt>
void insert(InputIt first, InputIt last) {
for (; first != last; ++first) {
try_emplace(first->first, first->second);
auto&& pair = *first;
try_emplace(pair.first, pair.second);
}
}
void insert(std::initializer_list<value_type> values) {

@ -246,7 +246,7 @@ class RepeatedField final {
Element* mutable_data();
const Element* data() const;
// Swaps entire contents with "other". If they are separate arenas then,
// Swaps entire contents with "other". If they are separate arenas, then
// copies data between each other.
void Swap(RepeatedField* other);
@ -313,8 +313,14 @@ class RepeatedField final {
iterator erase(const_iterator first, const_iterator last);
// Gets the Arena on which this RepeatedField stores its elements.
// Message-owned arenas are not exposed by this method, which will return
// nullptr for messages owned by MOAs.
inline Arena* GetArena() const {
return GetOwningArena();
Arena* arena = GetOwningArena();
if (arena == nullptr || arena->InternalIsMessageOwnedArena()) {
return nullptr;
}
return arena;
}
// For internal use only.

@ -612,7 +612,16 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena.
}
inline Arena* GetArena() const { return arena_; }
// Gets the Arena on which this RepeatedPtrField stores its elements.
// Message-owned arenas are not exposed by this method, which will return
// nullptr for messages owned by MOAs.
inline Arena* GetArena() const {
Arena* arena = GetOwningArena();
if (arena == nullptr || arena->InternalIsMessageOwnedArena()) {
return nullptr;
}
return arena;
}
protected:
inline Arena* GetOwningArena() const { return arena_; }
@ -762,7 +771,7 @@ class GenericTypeHandler {
}
}
static inline Arena* GetOwningArena(GenericType* value) {
return Arena::GetOwningArena<Type>(value);
return Arena::InternalGetOwningArena(value);
}
static inline void Clear(GenericType* value) { value->Clear(); }

@ -178,7 +178,7 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */,
}
static LogHandler* log_handler_ = &DefaultLogHandler;
static std::atomic<int> log_silencer_count_ = ATOMIC_VAR_INIT(0);
static std::atomic<int> log_silencer_count_{0};
LogMessage& LogMessage::operator<<(const std::string& value) {
message_ += value;

@ -77,9 +77,6 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
public:
struct RenderOptions {
RenderOptions() = default;
RenderOptions(const RenderOptions&) = default;
// Sets whether or not to use lowerCamelCase casing for enum values. If set
// to false, enum values are output without any case conversions.
//

Loading…
Cancel
Save