Fix unused variable warnings Removing `_LIBCPP_DISABLE_UNUSED_STRUCT_WARNINGS` from libc++ enables `[[gnu::__warn_unused__]]` on standard library types (such as `std::string`), surfacing `-Wunused-variable` warnings in `//third_party/protobuf`. See [upstream LLVM commit](https://github.com/llvm/llvm-project/commit/ab8b037ef7b398aa864959a69f328fa69b567f74) for reference. - Remove unreferenced `std::string` declarations (`ext_scope` in `gen_extensions.cc` and `default_value` in `extension.cc`) whose initializers have no side effects. - Annotate `class_name`, `mini_table_name`, and `crate_name` with `[[maybe_unused]]` where their initializers invoke helper functions. PiperOrigin-RevId: 999636704
diff --git a/hpb_generator/gen_accessors.cc b/hpb_generator/gen_accessors.cc index 44534f9..0da4d65 100644 --- a/hpb_generator/gen_accessors.cc +++ b/hpb_generator/gen_accessors.cc
@@ -788,7 +788,6 @@ void WriteOneofAccessorsInHeader(const google::protobuf::Descriptor* desc, Context& ctx) { // Generate const methods. auto indent = ctx.printer().WithIndent(); - std::string class_name = ClassName(desc); auto field_names = CreateFieldNameMap(desc); for (int i = 0; i < desc->real_oneof_decl_count(); ++i) { const google::protobuf::OneofDescriptor* oneof = desc->oneof_decl(i);
diff --git a/hpb_generator/gen_extensions.cc b/hpb_generator/gen_extensions.cc index 2c7bea8..09ffd3f 100644 --- a/hpb_generator/gen_extensions.cc +++ b/hpb_generator/gen_extensions.cc
@@ -26,7 +26,6 @@ std::string ExtensionIdentifierBase(const google::protobuf::FieldDescriptor* ext) { assert(ext->is_extension()); - std::string ext_scope; if (ext->extension_scope()) { return upb::generator::CApiMessageType(ext->extension_scope()->full_name()); } else { @@ -55,8 +54,7 @@ {"extension_type", ext_type}, {"default_value", DefaultValue(ext)}, {"linkage", linkage}, - {"mini_table_name", - absl::StrCat(ExtensionIdentifierBase(ext), "_", ext->name(), "_ext")}, + {"mini_table_name", mini_table_name}, Sub("extension_name", ResolveKeywordConflict(ext->name())) .AnnotatedAs(ext), {"extension_number", ext->number()}},
diff --git a/src/google/protobuf/compiler/rust/generator.cc b/src/google/protobuf/compiler/rust/generator.cc index 3b83e9d..a9fe1b8 100644 --- a/src/google/protobuf/compiler/rust/generator.cc +++ b/src/google/protobuf/compiler/rust/generator.cc
@@ -55,7 +55,6 @@ // messages and enums of a `dep`. This should only be // called for 'import public' deps. void EmitPublicImportsForDepFile(Context& ctx, const FileDescriptor* dep) { - std::string crate_name = GetCrateName(ctx, *dep); for (int i = 0; i < dep->message_type_count(); ++i) { auto* msg = dep->message_type(i); auto path = RsTypePath(ctx, *msg);