From bcd41429c9d92a90eecd8ed2200ccd5372582a4e Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 30 Nov 2023 13:26:55 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 586770525 --- .../protobuf/compiler/allowlists/BUILD.bazel | 1 - .../protobuf/compiler/allowlists/editions.cc | 32 ------------------- .../compiler/command_line_interface.cc | 11 ++++--- 3 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 src/google/protobuf/compiler/allowlists/editions.cc diff --git a/src/google/protobuf/compiler/allowlists/BUILD.bazel b/src/google/protobuf/compiler/allowlists/BUILD.bazel index e5ca2c8e27..dc84829b21 100644 --- a/src/google/protobuf/compiler/allowlists/BUILD.bazel +++ b/src/google/protobuf/compiler/allowlists/BUILD.bazel @@ -21,7 +21,6 @@ cc_library( cc_library( name = "allowlists", srcs = [ - "editions.cc", "empty_package.cc", "open_enum.cc", ], diff --git a/src/google/protobuf/compiler/allowlists/editions.cc b/src/google/protobuf/compiler/allowlists/editions.cc deleted file mode 100644 index f883ece02a..0000000000 --- a/src/google/protobuf/compiler/allowlists/editions.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google LLC. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -#include "absl/strings/string_view.h" -#include "google/protobuf/compiler/allowlists/allowlist.h" -#include "google/protobuf/compiler/allowlists/allowlists.h" - -namespace google { -namespace protobuf { -namespace compiler { - -// NOTE: These files have early default access to go/editions. The protoc flag -// `--experimental_editions` can also be used to enable editions. - -static constexpr auto kEarlyEditionsFile = internal::MakeAllowlist( - { -// Intentionally left blank. - "google/protobuf/", - "upb/", - }, - internal::AllowlistFlags::kMatchPrefix); - -bool IsEarlyEditionsFile(absl::string_view file) { - return kEarlyEditionsFile.Allows(file); -} -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 1bba987a44..46bbb23fa3 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1598,7 +1598,9 @@ bool CommandLineInterface::ParseInputFiles( } parsed_files->push_back(parsed_file); - if (!experimental_editions_ && !IsEarlyEditionsFile(parsed_file->name())) { + if (!experimental_editions_ && + !absl::StartsWith(parsed_file->name(), "google/protobuf/") && + !absl::StartsWith(parsed_file->name(), "upb/")) { if (FileDescriptorLegacy(parsed_file).syntax() == FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) { std::cerr @@ -2563,9 +2565,10 @@ bool CommandLineInterface::EnforceEditionsSupport( continue; } - // Skip enforcement for allowlisted files. - if (IsEarlyEditionsFile(fd->name())) continue; - + if (absl::StartsWith(fd->name(), "google/protobuf/") || + absl::StartsWith(fd->name(), "upb/")) { + continue; + } if ((supported_features & CodeGenerator::FEATURE_SUPPORTS_EDITIONS) == 0) { std::cerr << absl::Substitute( "$0: is an editions file, but code generator $1 hasn't been "