Correct HasBitVars logic to reflect the fact that stripped fields may return

true for HasHasbit.

PiperOrigin-RevId: 498258269
pull/11421/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 49589719e2
commit 88ec26fe07
  1. 5
      src/google/protobuf/compiler/cpp/field.cc

@ -210,13 +210,14 @@ std::unique_ptr<FieldGeneratorBase> MakeGenerator(const FieldDescriptor* field,
void HasBitVars(const FieldDescriptor* field, const Options& opts,
absl::optional<uint32_t> idx, std::vector<Sub>& vars) {
if (!internal::cpp::HasHasbit(field)) {
GOOGLE_ABSL_CHECK(!idx.has_value());
if (!idx.has_value()) {
vars.emplace_back("set_hasbit", "");
vars.emplace_back("clear_hasbit", "");
return;
}
GOOGLE_ABSL_CHECK(internal::cpp::HasHasbit(field));
int32_t index = *idx / 32;
std::string mask = absl::StrFormat("0x%08xu", 1u << (*idx % 32));

Loading…
Cancel
Save