Skip to content

Commit

Permalink
Remove option to disable the table-driven parser in protoc.
Browse files Browse the repository at this point in the history
It is now the default and only codegen parser implementation.

Also, remove the newly dead code.

PiperOrigin-RevId: 556873863
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Aug 14, 2023
1 parent 740d314 commit 6d03f9b
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 847 deletions.
9 changes: 3 additions & 6 deletions src/google/protobuf/compiler/cpp/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,7 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* p) {
IncludeFile("third_party/protobuf/wire_format.h", p);
}

if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
if (HasGeneratedMethods(file_, options_)) {
IncludeFile("third_party/protobuf/generated_message_tctable_impl.h", p);
}

Expand Down Expand Up @@ -703,8 +702,7 @@ void FileGenerator::GenerateSourcePrelude(io::Printer* p) {
namespace _pbi = ::$proto_ns$::internal;
)cc");

if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
if (HasGeneratedMethods(file_, options_)) {
p->Emit(R"cc(
namespace _fl = ::$proto_ns$::internal::field_layout;
)cc");
Expand Down Expand Up @@ -1554,8 +1552,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* p) {
if (HasSimpleBaseClasses(file_, options_)) {
IncludeFile("third_party/protobuf/generated_message_bases.h", p);
}
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
if (HasGeneratedMethods(file_, options_)) {
IncludeFile("third_party/protobuf/generated_message_tctable_decl.h", p);
}
IncludeFile("third_party/protobuf/generated_message_util.h", p);
Expand Down
10 changes: 0 additions & 10 deletions src/google/protobuf/compiler/cpp/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,6 @@ bool CppGenerator::Generate(const FileDescriptor* file,
} while (pos < value.size());
} else if (key == "force_eagerly_verified_lazy") {
file_options.force_eagerly_verified_lazy = true;
} else if (key == "experimental_tail_call_table_mode") {
if (value == "never") {
file_options.tctable_mode = Options::kTCTableNever;
} else if (value == "always") {
file_options.tctable_mode = Options::kTCTableAlways;
} else {
*error = absl::StrCat(
"Unknown value for experimental_tail_call_table_mode: ", value);
return false;
}
} else if (key == "experimental_strip_nonfunctional_codegen") {
file_options.strip_nonfunctional_codegen = true;
} else {
Expand Down
15 changes: 0 additions & 15 deletions src/google/protobuf/compiler/cpp/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,6 @@ class PROTOC_EXPORT Formatter {
vars_[key] = ToString(value);
}

void AddMap(const absl::flat_hash_map<absl::string_view, std::string>& vars) {
for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
}

template <typename... Args>
void operator()(const char* format, const Args&... args) const {
printer_->FormatInternal({ToString(args)...}, vars_, format);
Expand Down Expand Up @@ -868,17 +864,6 @@ class PROTOC_EXPORT Formatter {
return ScopedIndenter(this);
}

class PROTOC_EXPORT SaveState {
public:
explicit SaveState(Formatter* format)
: format_(format), vars_(format->vars_) {}
~SaveState() { format_->vars_.swap(vars_); }

private:
Formatter* format_;
absl::flat_hash_map<absl::string_view, std::string> vars_;
};

private:
io::Printer* printer_;
absl::flat_hash_map<absl::string_view, std::string> vars_;
Expand Down
1 change: 0 additions & 1 deletion src/google/protobuf/compiler/cpp/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct Options {
std::string annotation_guard_name;
FieldListenerOptions field_listener_options;
EnforceOptimizeMode enforce_mode = EnforceOptimizeMode::kNoEnforcement;
enum { kTCTableNever, kTCTableAlways } tctable_mode = kTCTableAlways;
int num_cc_files = 0;
bool safe_boundary_check = false;
bool proto_h = false;
Expand Down
Loading

0 comments on commit 6d03f9b

Please sign in to comment.