Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/google/protobuf/compiler/cpp/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1394,9 +1394,7 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) {
}},
{"decl_annotate", [&] { GenerateAnnotationDecl(p); }},
{"alias_parse_table_type",
[&] { parse_function_generator_->GenerateAliasParseTableType(p); }},
{"parse_decls",
[&] { parse_function_generator_->GenerateDataDecls(p); }}},
[&] { parse_function_generator_->GenerateAliasParseTableType(p); }}},
R"cc(
class $unused $$Msg$ final
: public $pbi$::MapEntry<$key_cpp$, $val_cpp$,
Expand Down Expand Up @@ -1431,7 +1429,6 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) {
$alias_parse_table_type$;
static constexpr ParseTableT_ InternalGenerateParseTable_(
const $pbi$::ClassData* $nonnull$ class_data);
$parse_decls$;
$decl_annotate$;

const $pbi$::ClassData* $nonnull$ GetClassData() const PROTOBUF_FINAL;
Expand Down Expand Up @@ -2080,7 +2077,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
}},
{"alias_parse_table_type",
[&] { parse_function_generator_->GenerateAliasParseTableType(p); }},
{"decl_data", [&] { parse_function_generator_->GenerateDataDecls(p); }},
{"post_loop_handler",
[&] {
if (!NeedsPostLoopHandler(descriptor_, options_)) return;
Expand Down Expand Up @@ -2250,7 +2246,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
$alias_parse_table_type$;
static constexpr ParseTableT_ InternalGenerateParseTable_(
const $pbi$::ClassData* $nonnull$ class_data);
$decl_data$;
$post_loop_handler$;

friend class $pb$::MessageLite;
Expand Down
10 changes: 1 addition & 9 deletions src/google/protobuf/compiler/cpp/parse_function_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ void ParseFunctionGenerator::GenerateAliasParseTableType(io::Printer* p) {
)cc");
}

void ParseFunctionGenerator::GenerateDataDecls(io::Printer* p) {
auto v = p->WithVars(variables_);
// TODO: Remove this once we remove TcParser::GetTable.
p->Emit(R"cc(
friend class $pbi$::TcParser;
)cc");
}

static std::string TcParseFunctionName(internal::TcParseFunction func) {
#define PROTOBUF_TC_PARSE_FUNCTION_X(value) #value,
static constexpr absl::string_view kNames[] = {
Expand Down Expand Up @@ -260,7 +252,7 @@ void ParseFunctionGenerator::GenerateParseTableHelperDefinition(
options_)}},
R"cc(
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<$hot_type$>(), // to_prefetch
::_pbi::MessageTraits<$hot_type$>::tc_table(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE)cc");
}}},
// clang-format off
Expand Down
3 changes: 0 additions & 3 deletions src/google/protobuf/compiler/cpp/parse_function_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ class ParseFunctionGenerator {
// Emit alias parse table type.
void GenerateAliasParseTableType(io::Printer* printer);

// Emits class-level data member declarations to `printer`:
void GenerateDataDecls(io::Printer* printer);

// Emits the helper function definition to `printer`:
void GenerateParseTableHelperDefinition(io::Printer* printer);

Expand Down
18 changes: 3 additions & 15 deletions src/google/protobuf/edition_message_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,13 @@ namespace internal {
namespace {


template <typename T>
static const TcParseTableBase* GetTableIfAvailable(...) {
return nullptr;
}

template <typename T>
static const TcParseTableBase* GetTableIfAvailable(
decltype(TcParser::GetTable<T>())) {
return TcParser::GetTable<T>();
}

TEST(EditionMessageTest,
TestRegressionInlinedStringAuxIdxMismatchOnFastParser) {
using Proto = UNITTEST::InlinedStringIdxRegressionProto;

auto* table = GetTableIfAvailable<Proto>(nullptr);
// Only test when TDP is on, and we have these fields inlined.
if (table != nullptr &&
table->fast_entry(1)->target() == TcParser::FastBiS1) {
auto* table = MessageTraits<Proto>::tc_table();
// Only test when we have these fields inlined.
if (table->fast_entry(1)->target() == TcParser::FastBiS1) {
// optional string str1 = 1;
// The aux_idx points to the inlined_string_idx and not the actual aux_idx.
EXPECT_EQ(table->fast_entry(1)->bits.aux_idx(), 1);
Expand Down
11 changes: 0 additions & 11 deletions src/google/protobuf/generated_message_tctable_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,6 @@ enum class TcParseFunction : uint8_t { kNone, PROTOBUF_TC_PARSE_FUNCTION_LIST };
// TcParser implements most of the parsing logic for tailcall tables.
class PROTOBUF_EXPORT TcParser final {
public:
template <typename T>
#ifndef PROTOBUF_MESSAGE_GLOBALS
static constexpr auto GetTable() -> decltype(&T::_table_.header) {
return &T::_table_.header;
}
#else
static const TcParseTableBase* GetTable() {
return MessageTraits<T>::tc_table();
}
#endif

static PROTOBUF_ALWAYS_INLINE const char* ParseMessage(
MessageLite* msg, const char* ptr, ParseContext* ctx,
const TcParseTableBase* tc_table) {
Expand Down
11 changes: 0 additions & 11 deletions src/google/protobuf/message_unittest_legacy_apis.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,7 @@ TEST(MESSAGE_TEST_NAME, LegacyAddMethodsOnRepeatedStringField) {
}


namespace {
template <typename T>
static const internal::TcParseTableBase* GetTableIfAvailable(...) {
return nullptr;
}

template <typename T>
static const internal::TcParseTableBase* GetTableIfAvailable(
decltype(internal::TcParser::GetTable<T>())) {
return internal::TcParser::GetTable<T>();
}
} // namespace

} // namespace protobuf
} // namespace google
Expand Down
Loading