Skip to content

Commit

Permalink
Fix libprotobuf warnings
Browse files Browse the repository at this point in the history
Summary:
Updating to the 3.19 version of protobuf from upstream results
in some compiler errors about shadowing _cache_size_. This seems
related to protocolbuffers/protobuf#9378.

The code around this area in the latest versions contain some fixes
and those changes are applied here.

Reviewed By: luqun

Differential Revision: D37367670
  • Loading branch information
Herman Lee authored and inikep committed Mar 4, 2023
1 parent 0342269 commit 664d278
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// Prepare decls for _cached_size_ and _has_bits_. Their position in the
// output will be determined later.

bool need_to_emit_cached_size = true;
bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_);
const std::string cached_size_decl =
"mutable ::$proto_ns$::internal::CachedSize _cached_size_;\n";

Expand Down Expand Up @@ -1917,8 +1917,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// _cached_size_ together with _has_bits_ improves cache locality despite
// potential alignment padding.
format(has_bits_decl.c_str());
format(cached_size_decl.c_str());
need_to_emit_cached_size = false;
if (need_to_emit_cached_size) {
format(cached_size_decl.c_str());
need_to_emit_cached_size = false;
}
}

// Field members:
Expand Down

0 comments on commit 664d278

Please sign in to comment.