Skip to content

Commit 187f324

Browse files
Internal change
PiperOrigin-RevId: 892545502
1 parent 199a436 commit 187f324

23 files changed

+5640
-4261
lines changed

editions/golden/compare_cpp_codegen_failure.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[ RUN ] third_party/protobuf/editions/golden/simple_proto3.pb.cc
22
@@ @@
3-
::_pbi::TcParser::GetTable<::protobuf_editions_test::golden::SimpleProto3>(), // to_prefetch
4-
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
5-
}, {{
6-
- // optional int32 int32_field = 1;
7-
+ // int32 int32_field = 1;
8-
{::_pbi::TcParser::FastV32S1,
9-
{8, 0, 0,
10-
PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},
11-
}}, {{
12-
65535, 65535
13-
}}, {{
14-
- // optional int32 int32_field = 1;
15-
+ // int32 int32_field = 1;
16-
{PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
17-
}},
18-
// no aux_entries
3+
::_pbi::TcParser::GetTable<::protobuf_editions_test::golden::SimpleProto3>(), // to_prefetch
4+
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
5+
}, {{
6+
- // optional int32 int32_field = 1;
7+
+ // int32 int32_field = 1;
8+
{::_pbi::TcParser::FastV32S1,
9+
{8, 0, 0,
10+
PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},
11+
}}, {{
12+
65535, 65535
13+
}}, {{
14+
- // optional int32 int32_field = 1;
15+
+ // int32 int32_field = 1;
16+
{PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
17+
}},
18+
// no aux_entries
1919
@@ @@
2020
(void)cached_has_bits;
2121

editions/golden/compare_cpp_codegen_failure.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<testsuites tests="1" name="AllTests">
33
<testsuite name="EditionsCodegenTests">
44
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.cc" status="run" result="completed" classname="DiffTest">
5-
<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/internal_visibility.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,&#x0A; 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, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A; // no aux_entries&#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 (CheckHasBit(cached_has_bits, 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 (CheckHasBit(cached_has_bits, 0x00000001U)) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
5+
<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/internal_visibility.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,&#x0A; 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, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A; // no aux_entries&#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 (CheckHasBit(cached_has_bits, 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 (CheckHasBit(cached_has_bits, 0x00000001U)) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
66
</testcase>
77
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.h" status="run" result="completed" classname="DiffTest">
88
<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;// clang-format off&#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/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;// clang-format on&#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; [[nodiscard]] bool has_int32_field()&#x0A; const;&#x0A; void clear_int32_field() ;&#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 = CheckHasBit(_impl_._has_bits_[0], 0x00000001U);&#x0A; return value;" type=""></failure>

src/google/protobuf/compiler/cpp/helpers.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,12 @@ bool IsProfileDriven(const Options& options) {
10401040
options.access_info_map != nullptr;
10411041
}
10421042

1043+
absl::optional<std::string> MaybeDedicateSection(const Descriptor* descriptor,
1044+
const Options& options,
1045+
int index_in_file_messages) {
1046+
return absl::nullopt;
1047+
}
1048+
10431049
bool IsRarelyPresent(const FieldDescriptor* field, const Options& options) {
10441050
return false;
10451051
}
@@ -1327,7 +1333,6 @@ bool HasMapFields(const FileDescriptor* file) {
13271333
return false;
13281334
}
13291335

1330-
13311336
static bool HasEnumDefinitions(const Descriptor* message_type) {
13321337
if (message_type->enum_type_count() > 0) return true;
13331338
for (int i = 0; i < message_type->nested_type_count(); ++i) {

src/google/protobuf/compiler/cpp/helpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ bool IsMicroString(const FieldDescriptor* field, const Options& opts);
380380

381381
bool IsProfileDriven(const Options& options);
382382

383+
// Returns the dedicated section name if message hotness profile is available.
384+
absl::optional<std::string> MaybeDedicateSection(const Descriptor* desc,
385+
const Options& options,
386+
int index_in_file_messages);
387+
383388
// Returns true if `field` is unlikely to be present based on PDProto profile.
384389
PROTOC_EXPORT bool IsRarelyPresent(const FieldDescriptor* field,
385390
const Options& options);

0 commit comments

Comments
 (0)