Merge branch 'master' into sync-stage

pull/8968/head
zhangskz 3 years ago committed by GitHub
commit 0fe47f3971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      cmake/extract_includes.bat.in
  2. 1
      cmake/libprotobuf.cmake
  3. 16
      cmake/libprotoc.cmake
  4. 4
      cmake/tests.cmake
  5. 21
      java/pom.xml
  6. 4
      src/google/protobuf/compiler/command_line_interface.cc
  7. 4
      src/google/protobuf/compiler/cpp/cpp_file.cc
  8. 4
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  9. 4
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  10. 6
      src/google/protobuf/compiler/cpp/cpp_service.cc
  11. 1
      src/google/protobuf/compiler/objectivec/objectivec_enum.cc
  12. 2
      src/google/protobuf/compiler/parser.cc
  13. 12
      src/google/protobuf/compiler/php/php_generator.cc
  14. 4
      src/google/protobuf/compiler/python/python_generator.cc
  15. 4
      src/google/protobuf/dynamic_message.cc
  16. 8
      src/google/protobuf/generated_message_util.cc
  17. 4
      src/google/protobuf/port_def.inc
  18. 6
      src/google/protobuf/reflection_ops.cc
  19. 4
      src/google/protobuf/stubs/strutil.cc
  20. 4
      src/google/protobuf/util/field_mask_util.cc
  21. 12
      src/google/protobuf/util/internal/protostream_objectsource.cc

@ -21,15 +21,19 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena_impl.h" include
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h" include\google\protobuf\arenastring.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h" include\google\protobuf\compiler\code_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h" include\google\protobuf\compiler\command_line_interface.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_file.h" include\google\protobuf\compiler\cpp\cpp_file.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h" include\google\protobuf\compiler\cpp\cpp_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_helpers.h" include\google\protobuf\compiler\cpp\cpp_helpers.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_names.h" include\google\protobuf\compiler\cpp\cpp_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_doc_comment.h" include\google\protobuf\compiler\csharp\csharp_doc_comment.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h" include\google\protobuf\compiler\csharp\csharp_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h" include\google\protobuf\compiler\csharp\csharp_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_options.h" include\google\protobuf\compiler\csharp\csharp_options.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h" include\google\protobuf\compiler\importer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h" include\google\protobuf\compiler\java\java_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_kotlin_generator.h" include\google\protobuf\compiler\java\java_kotlin_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h" include\google\protobuf\compiler\java\java_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h" include\google\protobuf\compiler\js\js_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h" include\google\protobuf\compiler\js\well_known_types_embed.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h" include\google\protobuf\compiler\objectivec\objectivec_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h" include\google\protobuf\compiler\objectivec\objectivec_helpers.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h" include\google\protobuf\compiler\parser.h
@ -53,6 +57,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_bases.h" include\google\protobuf\generated_message_bases.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven_lite.h" include\google\protobuf\generated_message_table_driven_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_decl.h" include\google\protobuf\generated_message_tctable_decl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.h" include\google\protobuf\generated_message_tctable_impl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.inc" include\google\protobuf\generated_message_tctable_impl.inc
@ -89,7 +94,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h" inc
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h" include\google\protobuf\repeated_field.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h" include\google\protobuf\service.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h" include\google\protobuf\source_context.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\string_member_robber.h" include\google\protobuf\string_member_robber.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h" include\google\protobuf\struct.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h" include\google\protobuf\stubs\bytestream.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h" include\google\protobuf\stubs\callback.h

@ -21,7 +21,6 @@ set(libprotobuf_files
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
${protobuf_source_dir}/src/google/protobuf/map_field.cc
${protobuf_source_dir}/src/google/protobuf/message.cc
${protobuf_source_dir}/src/google/protobuf/reflection_internal.h
${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
${protobuf_source_dir}/src/google/protobuf/service.cc
${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc

@ -36,7 +36,6 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc
@ -65,28 +64,17 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
@ -94,7 +82,6 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.h
)
set(libprotoc_headers
@ -108,14 +95,17 @@ set(libprotoc_headers
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_names.h
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_options.h
${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_kotlin_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_names.h
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.h
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.h
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.h
)

@ -119,10 +119,10 @@ set(common_lite_test_files
set(common_test_files
${common_lite_test_files}
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
${protobuf_source_dir}/src/google/protobuf/map_test_util.inc
${protobuf_source_dir}/src/google/protobuf/reflection_tester.cc
${protobuf_source_dir}/src/google/protobuf/test_util.cc
${protobuf_source_dir}/src/google/protobuf/test_util.inc
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc
)
@ -132,7 +132,6 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc
${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.cc
${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.h
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc
@ -145,6 +144,7 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/parser_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_plugin_unittest.cc

@ -166,6 +166,27 @@
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.20</version>
<configuration>
<signature>
<groupId>net.sf.androidscents.signature</groupId>
<artifactId>android-api-level-14</artifactId>
<version>4.0_r4</version>
</signature>
</configuration>
<executions>
<execution>
<id>android</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

@ -2423,8 +2423,8 @@ bool CommandLineInterface::WriteDescriptorSet(
to_output.insert(parsed_files.begin(), parsed_files.end());
for (int i = 0; i < parsed_files.size(); i++) {
const FileDescriptor* file = parsed_files[i];
for (int i = 0; i < file->dependency_count(); i++) {
const FileDescriptor* dependency = file->dependency(i);
for (int j = 0; j < file->dependency_count(); j++) {
const FileDescriptor* dependency = file->dependency(j);
// if the dependency isn't in parsed files, mark it as already seen
if (to_output.find(dependency) == to_output.end()) {
already_seen.insert(dependency);

@ -154,8 +154,8 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
for (int i = 0; i < fields.size(); i++) {
const std::string& name = fields[i]->name();
static const char* kMacroNames[] = {"major", "minor"};
for (int i = 0; i < GOOGLE_ARRAYSIZE(kMacroNames); ++i) {
if (name == kMacroNames[i]) {
for (int j = 0; j < GOOGLE_ARRAYSIZE(kMacroNames); ++j) {
if (name == kMacroNames[j]) {
names_to_undef.push_back(name);
break;
}

@ -1168,8 +1168,8 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) {
if (descriptor->extension_range_count() > 0) {
result.contains_extension = true;
}
for (int i = 0; i < descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
for (int j = 0; j < descriptor->field_count(); j++) {
const FieldDescriptor* field = descriptor->field(j);
if (field->is_required()) {
result.contains_required = true;
}

@ -63,8 +63,8 @@ inline std::string ProtobufNamespace(const Options& /* options */) {
return "PROTOBUF_NAMESPACE_ID";
}
inline std::string MacroPrefix(const Options& options) {
return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF";
inline std::string MacroPrefix(const Options& /* options */) {
return "GOOGLE_PROTOBUF";
}
inline std::string DeprecatedAttribute(const Options& /* options */,

@ -241,12 +241,12 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_);
InitMethodVariables(method, options_, &format);
Formatter format_method(printer, vars_);
InitMethodVariables(method, options_, &format_method);
// Note: down_cast does not work here because it only works on pointers,
// not references.
format(
format_method(
" case $1$:\n"
" $name$(controller,\n"
" ::$proto_ns$::internal::DownCast<const $input_type$*>(\n"

@ -127,7 +127,6 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
if (alias_values_to_skip_.find(all_values_[i]) != alias_values_to_skip_.end()) {
continue;
}
SourceLocation location;
if (all_values_[i]->GetSourceLocation(&location)) {
std::string comments = BuildCommentsString(location, true).c_str();
if (comments.length() > 0) {

@ -1549,7 +1549,7 @@ bool Parser::ParseOption(Message* options,
value_location.AddPath(
UninterpretedOption::kNegativeIntValueFieldNumber);
uninterpreted_option->set_negative_int_value(
static_cast<int64_t>(-value));
static_cast<int64_t>(0 - value));
} else {
value_location.AddPath(
UninterpretedOption::kPositiveIntValueFieldNumber);

@ -1119,9 +1119,9 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options,
file, &nodes_without_dependency, &deps, &dependency_count);
while (!nodes_without_dependency.empty()) {
auto file = *nodes_without_dependency.begin();
nodes_without_dependency.erase(file);
for (auto dependent : deps[file]) {
auto file_node = *nodes_without_dependency.begin();
nodes_without_dependency.erase(file_node);
for (auto dependent : deps[file_node]) {
if (dependency_count[dependent] == 1) {
dependency_count.erase(dependent);
nodes_without_dependency.insert(dependent);
@ -1130,11 +1130,11 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options,
}
}
bool needs_aggregate = NeedsUnwrapping(file, options);
bool needs_aggregate = NeedsUnwrapping(file_node, options);
if (needs_aggregate) {
auto file_proto = sorted_file_set.add_file();
file->CopyTo(file_proto);
file_node->CopyTo(file_proto);
// Filter out descriptor.proto as it cannot be depended on for now.
RepeatedPtrField<std::string>* dependency =
@ -1156,7 +1156,7 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options,
it->clear_extension();
}
} else {
std::string dependency_filename = GeneratedMetadataFileName(file, false);
std::string dependency_filename = GeneratedMetadataFileName(file_node, false);
printer->Print(
"\\^name^::initOnce();\n",
"name", FilenameToClassname(dependency_filename));

@ -799,11 +799,11 @@ void Generator::PrintCreateDescriptor(
printer_->Indent();
for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) {
const OneofDescriptor* desc = message_descriptor.oneof_decl(i);
std::map<std::string, std::string> m;
m.clear();
m["name"] = desc->name();
m["full_name"] = desc->full_name();
m["index"] = StrCat(desc->index());
std::string options_string =
options_string =
OptionsValue(desc->options().SerializeAsString());
if (options_string == "None") {
m["serialized_options"] = "";

@ -747,9 +747,9 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
// hasbits.
type_info->has_bits_offset = size;
uint32_t* has_bits_indices = new uint32_t[type->field_count()];
for (int i = 0; i < type->field_count(); i++) {
for (int j = 0; j < type->field_count(); j++) {
// Initialize to -1, fields that need a hasbit will overwrite.
has_bits_indices[i] = static_cast<uint32_t>(-1);
has_bits_indices[j] = static_cast<uint32_t>(-1);
}
type_info->has_bits_indices.reset(has_bits_indices);
}

@ -701,13 +701,13 @@ uint8_t* SerializeInternalToArray(const uint8_t* base,
// Special cases
case FieldMetadata::kSpecial: {
io::ArrayOutputStream array_stream(array_output.ptr, INT_MAX);
io::CodedOutputStream output(&array_stream);
output.SetSerializationDeterministic(is_deterministic);
io::CodedOutputStream output_stream(&array_stream);
output_stream.SetSerializationDeterministic(is_deterministic);
func = reinterpret_cast<SpecialSerializer>(
const_cast<void*>(field_metadata.ptr));
func(base, field_metadata.offset, field_metadata.tag,
field_metadata.has_offset, &output);
array_output.ptr += output.ByteCount();
field_metadata.has_offset, &output_stream);
array_output.ptr += output_stream.ByteCount();
} break;
default:
// __builtin_unreachable()

@ -773,7 +773,9 @@
// To silence the fact that we will pop this push from another file
#pragma warning(disable : 5031)
// Conditional expression is constant
#pragma warning(disable : 4127)
#pragma warning(disable: 4127)
// decimal digit terminates octal escape sequence
#pragma warning(disable: 4125)
#endif
// We don't want code outside port_def doing complex testing, so

@ -214,9 +214,9 @@ bool ReflectionOps::IsInitialized(const Message& message, bool check_fields,
reflection->GetMapData(message, field);
if (map_field->IsMapValid()) {
MapIterator it(const_cast<Message*>(&message), field);
MapIterator end(const_cast<Message*>(&message), field);
for (map_field->MapBegin(&it), map_field->MapEnd(&end);
it != end; ++it) {
MapIterator end_map(const_cast<Message*>(&message), field);
for (map_field->MapBegin(&it), map_field->MapEnd(&end_map);
it != end_map; ++it) {
if (!it.GetValueRef().GetMessageValue().IsInitialized()) {
return false;
}

@ -1272,7 +1272,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// truncated to a double.
volatile double parsed_value = internal::NoLocaleStrtod(buffer, nullptr);
if (parsed_value != value) {
int snprintf_result =
snprintf_result =
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
// Should never overflow; see above.
@ -1384,7 +1384,7 @@ char* FloatToBuffer(float value, char* buffer) {
float parsed_value;
if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
int snprintf_result =
snprintf_result =
snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+3, value);
// Should never overflow; see above.

@ -385,8 +385,8 @@ void FieldMaskTree::RemovePath(const std::string& path,
if (new_branch_node == nullptr) {
new_branch_node = node;
}
for (int i = 0; i < current_descriptor->field_count(); ++i) {
node->children[current_descriptor->field(i)->name()] = new Node();
for (int j = 0; j < current_descriptor->field_count(); ++j) {
node->children[current_descriptor->field(j)->name()] = new Node();
}
}
if (ContainsKey(node->children, parts[i])) {

@ -265,16 +265,16 @@ util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderMap(
std::string map_key;
for (uint32_t tag = stream_->ReadTag(); tag != 0;
tag = stream_->ReadTag()) {
const google::protobuf::Field* field =
const google::protobuf::Field* map_entry_field =
FindAndVerifyField(*field_type, tag);
if (field == nullptr) {
if (map_entry_field == nullptr) {
WireFormat::SkipField(stream_, tag, nullptr);
continue;
}
// Map field numbers are key = 1 and value = 2
if (field->number() == 1) {
map_key = ReadFieldValueAsString(*field);
} else if (field->number() == 2) {
if (map_entry_field->number() == 1) {
map_key = ReadFieldValueAsString(*map_entry_field);
} else if (map_entry_field->number() == 2) {
if (map_key.empty()) {
// An absent map key is treated as the default.
const google::protobuf::Field* key_field =
@ -286,7 +286,7 @@ util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderMap(
}
ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));
}
RETURN_IF_ERROR(RenderField(field, map_key, ow));
RETURN_IF_ERROR(RenderField(map_entry_field, map_key, ow));
} else {
// The Type info for this map entry is incorrect. It should contain
// exactly two fields with field number 1 and 2.

Loading…
Cancel
Save