Fix shadowing warnings (#8926)

pull/8968/head^2
Sil3ntStorm 3 years ago committed by GitHub
parent fabb59448a
commit d6699989ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/google/protobuf/compiler/command_line_interface.cc
  2. 4
      src/google/protobuf/compiler/cpp/cpp_file.cc
  3. 4
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  4. 6
      src/google/protobuf/compiler/cpp/cpp_service.cc
  5. 1
      src/google/protobuf/compiler/objectivec/objectivec_enum.cc
  6. 12
      src/google/protobuf/compiler/php/php_generator.cc
  7. 4
      src/google/protobuf/compiler/python/python_generator.cc
  8. 4
      src/google/protobuf/dynamic_message.cc
  9. 8
      src/google/protobuf/generated_message_util.cc
  10. 6
      src/google/protobuf/reflection_ops.cc
  11. 4
      src/google/protobuf/stubs/strutil.cc
  12. 4
      src/google/protobuf/util/field_mask_util.cc
  13. 12
      src/google/protobuf/util/internal/protostream_objectsource.cc

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

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

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

@ -241,12 +241,12 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) { for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i); const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_); Formatter format_method(printer, vars_);
InitMethodVariables(method, options_, &format); InitMethodVariables(method, options_, &format_method);
// Note: down_cast does not work here because it only works on pointers, // Note: down_cast does not work here because it only works on pointers,
// not references. // not references.
format( format_method(
" case $1$:\n" " case $1$:\n"
" $name$(controller,\n" " $name$(controller,\n"
" ::$proto_ns$::internal::DownCast<const $input_type$*>(\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()) { if (alias_values_to_skip_.find(all_values_[i]) != alias_values_to_skip_.end()) {
continue; continue;
} }
SourceLocation location;
if (all_values_[i]->GetSourceLocation(&location)) { if (all_values_[i]->GetSourceLocation(&location)) {
std::string comments = BuildCommentsString(location, true).c_str(); std::string comments = BuildCommentsString(location, true).c_str();
if (comments.length() > 0) { if (comments.length() > 0) {

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

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

@ -747,9 +747,9 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
// hasbits. // hasbits.
type_info->has_bits_offset = size; type_info->has_bits_offset = size;
uint32_t* has_bits_indices = new uint32_t[type->field_count()]; 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. // 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); type_info->has_bits_indices.reset(has_bits_indices);
} }

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

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

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

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

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

Loading…
Cancel
Save