Skip to content

Commit

Permalink
Add no-op condition change in preparation for adding branch hints.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 721476135
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 30, 2025
1 parent 12dea29 commit 59bbdb8
Show file tree
Hide file tree
Showing 7 changed files with 630 additions and 630 deletions.
4 changes: 2 additions & 2 deletions editions/golden/compare_cpp_codegen_failure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
cached_has_bits = this_._impl_._has_bits_[0];
- // optional int32 int32_field = 1;
+ // int32 int32_field = 1;
if (cached_has_bits & 0x00000001u) {
if ((cached_has_bits & 0x00000001u) != 0) {
target =
::proto2::internal::WireFormatLite::WriteInt32ToArrayWithField<1>(
@@ @@
Expand All @@ -31,7 +31,7 @@
- // optional int32 int32_field = 1;
+ // int32 int32_field = 1;
cached_has_bits = this_._impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
if ((cached_has_bits & 0x00000001u) != 0) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
[ FAILED ] third_party/protobuf/editions/golden/simple_proto3.pb.cc
[ RUN ] third_party/protobuf/editions/golden/simple_proto3.pb.h
Expand Down
2 changes: 1 addition & 1 deletion editions/golden/compare_cpp_codegen_failure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<testsuites tests="1" name="AllTests">
<testsuite name="EditionsCodegenTests">
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.cc" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; target =&#x0A; ::proto2::internal::WireFormatLite::WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if ((cached_has_bits &amp; 0x00000001u) != 0) {&#x0A; target =&#x0A; ::proto2::internal::WireFormatLite::WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if ((cached_has_bits &amp; 0x00000001u) != 0) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
</testcase>
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.h" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.h&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#ifndef third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;#define third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;&#x0A;#include &lt;limits&gt;&#x0A;#include &lt;string&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &lt;utility&gt;&#x0A;&#x0A;#include &quot;third_party/protobuf/runtime_version.h&quot;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/arena.h&quot;&#x0A;#include &quot;third_party/protobuf/arenastring.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_decl.h&quot;&#x0A;#include &quot;third_party/protobuf/v2/generated_message_table.h&quot;&#x0A;#include &quot;third_party/protobuf/v2/generated_message_table_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/metadata_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/message_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;&#x0A;#endif // third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;, with the difference:&#x0A;@@ @@&#x0A; enum : int {&#x0A; kInt32FieldFieldNumber = 1,&#x0A; };&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; bool has_int32_field() const;&#x0A; void clear_int32_field() ;&#x0A; ::int32_t int32_field() const;&#x0A;@@ @@&#x0A; &#x0A; // SimpleProto3&#x0A; &#x0A;-// optional int32 int32_field = 1;&#x0A;+// int32 int32_field = 1;&#x0A; inline bool SimpleProto3::has_int32_field() const {&#x0A; bool value = (_impl_._has_bits_[0] &amp; 0x00000001u) != 0;&#x0A; return value;" type=""></failure>
Expand Down
16 changes: 8 additions & 8 deletions src/google/protobuf/compiler/cpp/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void PrintPresenceCheck(const FieldDescriptor* field,
}
p->Emit({{"mask", absl::StrFormat("0x%08xu", 1u << (has_bit_index % 32))}},
R"cc(
if (cached_has_bits & $mask$) {
if ((cached_has_bits & $mask$) != 0) {
)cc");
} else {
p->Emit(R"cc(
Expand Down Expand Up @@ -1330,7 +1330,7 @@ void MessageGenerator::EmitCheckAndUpdateByteSizeForField(
/*with_enclosing_braces_always=*/false);
}}},
R"cc(
if (cached_has_bits & $mask$) {
if ((cached_has_bits & $mask$) != 0) {
$check_nondefault_and_emit_body$;
}
)cc");
Expand Down Expand Up @@ -3188,7 +3188,7 @@ void MessageGenerator::GenerateCopyInitFields(io::Printer* p) const {
} else {
int index = has_bit_indices_[field->index()];
std::string mask = absl::StrFormat("0x%08xu", 1u << (index % 32));
p->Emit({{"mask", mask}}, "cached_has_bits & $mask$");
p->Emit({{"mask", mask}}, "(cached_has_bits & $mask$) != 0");
}
};

Expand Down Expand Up @@ -3619,7 +3619,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
cached_has_word_index = HasWordIndex(fields.front());
format("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index);
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format("if ((cached_has_bits & 0x$1$u) != 0) {\n", chunk_mask_str);
format.Indent();
}

Expand Down Expand Up @@ -4285,7 +4285,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
ABSL_DCHECK_LE(2, popcnt(chunk_mask));
ABSL_DCHECK_GE(8, popcnt(chunk_mask));

format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format("if ((cached_has_bits & 0x$1$u) != 0) {\n", chunk_mask_str);
format.Indent();
}

Expand Down Expand Up @@ -4319,7 +4319,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
int has_bit_index = has_bit_indices_[field->index()];
const std::string mask = absl::StrCat(
absl::Hex(1u << (has_bit_index % 32), absl::kZeroPad8));
format("if (cached_has_bits & 0x$1$u) {\n", mask);
format("if ((cached_has_bits & 0x$1$u) != 0) {\n", mask);
format.Indent();

if (GetFieldHasbitMode(field) == HasbitMode::kHintHasbit) {
Expand Down Expand Up @@ -4570,7 +4570,7 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* p,
auto v = p->WithVars(HasBitVars(field));
// Attempt to use the state of cached_has_bits, if possible.
if (cached_has_bits_index == has_bit_index / 32) {
p->Emit("cached_has_bits & $has_mask$");
p->Emit("(cached_has_bits & $has_mask$) != 0");
} else {
p->Emit(
"(this_.$has_bits$[$has_array_index$] & $has_mask$) != 0");
Expand Down Expand Up @@ -5223,7 +5223,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) {

p->Emit(
{{"mask", absl::StrFormat("0x%08xu", chunk_mask)}},
"if (cached_has_bits & $mask$)");
"if ((cached_has_bits & $mask$) != 0)");
}}},
R"cc(
$may_update_cached_has_word_index$;
Expand Down
18 changes: 9 additions & 9 deletions src/google/protobuf/compiler/java/java_features.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 59bbdb8

Please sign in to comment.