Automated rollback of commit 58f6216d8d.

PiperOrigin-RevId: 503240831
pull/11602/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent d538808032
commit f0c7559594
  1. 9
      src/google/protobuf/compiler/cpp/file.cc
  2. 14
      src/google/protobuf/descriptor.cc
  3. 7
      src/google/protobuf/descriptor.h
  4. 3
      src/google/protobuf/descriptor_unittest.cc
  5. 4
      src/google/protobuf/port_def.inc
  6. 1
      src/google/protobuf/port_undef.inc

@ -1100,11 +1100,10 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) {
} }
)cc"); )cc");
// For proto files included in the full runtime (i.e. descriptor.proto // For descriptor.proto we want to avoid doing any dynamic initialization,
// and extension_declarations.proto), we want to avoid doing any dynamic // because in some situations that would otherwise pull in a lot of
// initialization, because in some situations that would otherwise pull // unnecessary code that can't be stripped by --gc-sections. Descriptor
// in a lot of unnecessary code that can't be stripped by --gc-sections. // initialization will still be performed lazily when it's needed.
// Initialization will still be performed lazily when it's needed.
if (file_->name() == "net/proto2/proto/descriptor.proto") { if (file_->name() == "net/proto2/proto/descriptor.proto") {
return; return;
} }

@ -38,7 +38,6 @@
#include <array> #include <array>
#include <cstdlib> #include <cstdlib>
#include <functional> #include <functional>
#include <iterator>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
@ -63,11 +62,8 @@
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
#include "absl/types/optional.h"
#include "google/protobuf/any.h" #include "google/protobuf/any.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor_database.h" #include "google/protobuf/descriptor_database.h"
@ -1876,7 +1872,6 @@ void DescriptorPool::AddUnusedImportTrackFile(absl::string_view file_name,
unused_import_track_files_[file_name] = is_error; unused_import_track_files_[file_name] = is_error;
} }
void DescriptorPool::ClearUnusedImportTrackFiles() { void DescriptorPool::ClearUnusedImportTrackFiles() {
unused_import_track_files_.clear(); unused_import_track_files_.clear();
} }
@ -1917,11 +1912,7 @@ DescriptorPool* DescriptorPool::internal_generated_pool() {
const DescriptorPool* DescriptorPool::generated_pool() { const DescriptorPool* DescriptorPool::generated_pool() {
const DescriptorPool* pool = internal_generated_pool(); const DescriptorPool* pool = internal_generated_pool();
// Ensure that descriptor.proto and extension_declarations.proto get // Ensure that descriptor.proto has been registered in the generated pool.
// registered in the generated pool. These protos are a special case
// because they are included in the full runtime. We have to avoid
// registering them pre-main, because we need to ensure that the linker
// --gc-sections step can strip out the full runtime if it is unused.
DescriptorProto::descriptor(); DescriptorProto::descriptor();
return pool; return pool;
} }
@ -6482,7 +6473,6 @@ void DescriptorBuilder::CrossLinkExtensionRange(
} }
} }
void DescriptorBuilder::CrossLinkField(FieldDescriptor* field, void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
const FieldDescriptorProto& proto) { const FieldDescriptorProto& proto) {
if (field->options_ == nullptr) { if (field->options_ == nullptr) {
@ -7122,7 +7112,7 @@ void DescriptorBuilder::ValidateFieldOptions(
// determine whether the json_name option is set on the field. Here we // determine whether the json_name option is set on the field. Here we
// compare it against the default calculated json_name value and consider // compare it against the default calculated json_name value and consider
// the option set if they are different. This won't catch the case when // the option set if they are different. This won't catch the case when
// a user explicitly sets json_name to the default value, but should be // an user explicitly sets json_name to the default value, but should be
// good enough to catch common misuses. // good enough to catch common misuses.
if (field->is_extension() && if (field->is_extension() &&
(field->has_json_name() && (field->has_json_name() &&

@ -70,7 +70,6 @@
#include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
#include "absl/types/optional.h"
#include "google/protobuf/port.h" #include "google/protobuf/port.h"
// Must be included last. // Must be included last.
@ -84,9 +83,6 @@
namespace google { namespace google {
namespace protobuf { namespace protobuf {
// Defined in extension_declaration.proto.
class ExtensionMetadata;
// Defined in this file. // Defined in this file.
class Descriptor; class Descriptor;
class FieldDescriptor; class FieldDescriptor;
@ -144,7 +140,6 @@ class Formatter;
namespace descriptor_unittest { namespace descriptor_unittest {
class DescriptorTest; class DescriptorTest;
class ValidationErrorTest;
} // namespace descriptor_unittest } // namespace descriptor_unittest
// Defined in printer.h // Defined in printer.h
@ -2092,7 +2087,6 @@ class PROTOBUF_EXPORT DescriptorPool {
friend class FileDescriptor; friend class FileDescriptor;
friend class DescriptorBuilder; friend class DescriptorBuilder;
friend class FileDescriptorTables; friend class FileDescriptorTables;
friend class google::protobuf::descriptor_unittest::ValidationErrorTest;
// Return true if the given name is a sub-symbol of any non-package // Return true if the given name is a sub-symbol of any non-package
// descriptor that already exists in the descriptor pool. (The full // descriptor that already exists in the descriptor pool. (The full
@ -2168,7 +2162,6 @@ class PROTOBUF_EXPORT DescriptorPool {
// Set of files to track for unused imports. The bool value when true means // Set of files to track for unused imports. The bool value when true means
// unused imports are treated as errors (and as warnings when false). // unused imports are treated as errors (and as warnings when false).
absl::flat_hash_map<std::string, bool> unused_import_track_files_; absl::flat_hash_map<std::string, bool> unused_import_track_files_;
}; };

@ -45,7 +45,6 @@
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_custom_options.pb.h" #include "google/protobuf/unittest_custom_options.pb.h"
#include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/common.h"
@ -3934,7 +3933,6 @@ class ValidationErrorTest : public testing::Test {
return GOOGLE_CHECK_NOTNULL(pool_.BuildFile(file_proto)); return GOOGLE_CHECK_NOTNULL(pool_.BuildFile(file_proto));
} }
// Parse file_text as a FileDescriptorProto in text format and add it // Parse file_text as a FileDescriptorProto in text format and add it
// to the DescriptorPool. Expect errors to be produced which match the // to the DescriptorPool. Expect errors to be produced which match the
// given error text. // given error text.
@ -7080,7 +7078,6 @@ TEST_F(ValidationErrorTest, UnusedImportWithOtherError) {
} }
TEST_F(ValidationErrorTest, PackageTooLong) { TEST_F(ValidationErrorTest, PackageTooLong) {
BuildFileWithErrors( BuildFileWithErrors(
"name: \"foo.proto\" " "name: \"foo.proto\" "

@ -221,10 +221,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
// Owner: mkruskal@ // Owner: mkruskal@
#define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1 #define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1
// Used for descriptor proto extension declarations.
// Owner: shaod@, gberg@
#define PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL 1
#else #else
#define PROTOBUF_FUTURE_FINAL #define PROTOBUF_FUTURE_FINAL
#endif #endif

@ -121,7 +121,6 @@
#undef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE #undef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
#undef PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR #undef PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
#undef PROTOBUF_FUTURE_REMOVE_CLEARED_API #undef PROTOBUF_FUTURE_REMOVE_CLEARED_API
#undef PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL
#endif #endif
#undef PROTOBUF_FUTURE_FINAL #undef PROTOBUF_FUTURE_FINAL

Loading…
Cancel
Save