Skip to content

Commit

Permalink
Merge pull request protocolbuffers#9525 from dlj-NaN/sync-stage
Browse files Browse the repository at this point in the history
Integrate from Piper for C++, Java, and Python
  • Loading branch information
jorgbrown authored Feb 18, 2022
2 parents ddfc233 + 20c5b6f commit 763d852
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
* Remove GetPointer() and explicit nullptr defaults.
* add proto_h flag for speeding up large builds
* Add missing overload for reference wrapped fields.
* Add MergedDescriptorDatabase::FindAllFileNames()


2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Expand Down
4 changes: 2 additions & 2 deletions src/google/protobuf/any.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/google/protobuf/api.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/google/protobuf/arenastring.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ static_assert(std::is_trivial<TaggedStringPtr>::value,
// held, and the mutable and ownership invariants for each type.
struct PROTOBUF_EXPORT ArenaStringPtr {
ArenaStringPtr() = default;
explicit constexpr ArenaStringPtr(
ExplicitlyConstructedArenaString* default_value)
constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value,
ConstantInitialized)
: tagged_ptr_(default_value) {}

// Called from generated code / reflection runtime only. Resets value to point
Expand Down
6 changes: 4 additions & 2 deletions src/google/protobuf/compiler/cpp/cpp_string_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,11 @@ void StringFieldGenerator::GenerateConstinitInitializer(
return;
}
if (descriptor_->default_value_string().empty()) {
format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)");
format(
"$name$_(&::_pbi::fixed_address_empty_string, "
"::_pbi::ConstantInitialized{})");
} else {
format("$name$_(nullptr)");
format("$name$_(nullptr, ::_pbi::ConstantInitialized{})");
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/google/protobuf/compiler/plugin.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 33 additions & 33 deletions src/google/protobuf/descriptor.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/google/protobuf/descriptor_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <google/protobuf/descriptor_database.h>

#include <algorithm>
#include <set>

#include <google/protobuf/descriptor.pb.h>
Expand Down Expand Up @@ -1027,5 +1028,21 @@ bool MergedDescriptorDatabase::FindAllExtensionNumbers(
}


bool MergedDescriptorDatabase::FindAllFileNames(
std::vector<std::string>* output) {
bool implemented = false;
for (DescriptorDatabase* source : sources_) {
std::vector<std::string> source_output;
if (source->FindAllFileNames(&source_output)) {
output->reserve(output->size() + source_output.size());
for (auto& source : source_output) {
output->push_back(std::move(source));
}
implemented = true;
}
}
return implemented;
}

} // namespace protobuf
} // namespace google
4 changes: 4 additions & 0 deletions src/google/protobuf/descriptor_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
std::vector<int>* output) override;


// This function is best-effort. Returns true if at least one underlying
// DescriptorDatabase returns true.
bool FindAllFileNames(std::vector<std::string>* output) override;

private:
std::vector<DescriptorDatabase*> sources_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
Expand Down
7 changes: 7 additions & 0 deletions src/google/protobuf/descriptor_database_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,13 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
}
}

TEST_F(MergedDescriptorDatabaseTest, FindAllFileNames) {
std::vector<std::string> files;
EXPECT_TRUE(forward_merged_.FindAllFileNames(&files));
EXPECT_THAT(files, ::testing::UnorderedElementsAre("foo.proto", "bar.proto",
"baz.proto", "baz.proto"));
}


} // anonymous namespace
} // namespace protobuf
Expand Down
9 changes: 6 additions & 3 deletions src/google/protobuf/map_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ class PROTOBUF_EXPORT MapFieldBase {
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
// Except in MSVC, where we can't have a constinit mutex.
explicit constexpr MapFieldBase(ConstantInitialized)
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr MapFieldBase(ConstantInitialized)
: arena_(nullptr),
repeated_field_(nullptr),
mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED),
Expand Down Expand Up @@ -497,7 +498,8 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
// This constructor is for constant initialized global instances.
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
explicit constexpr TypeDefinedMapFieldBase(ConstantInitialized tag)
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr TypeDefinedMapFieldBase(ConstantInitialized tag)
: MapFieldBase(tag) {}
explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}

Expand Down Expand Up @@ -567,7 +569,8 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
// This constructor is for constant initialized global instances.
// It uses a linker initialized mutex, so it is not compatible with regular
// runtime instances.
explicit constexpr MapField(ConstantInitialized tag)
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr MapField(ConstantInitialized tag)
: TypeDefinedMapFieldBase<Key, T>(tag), impl_() {}
explicit MapField(Arena* arena)
: TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
Expand Down
3 changes: 2 additions & 1 deletion src/google/protobuf/map_type_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::IsInitialized(
constexpr auto \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Constinit() \
->TypeOnMemory { \
return TypeOnMemory(&internal::fixed_address_empty_string); \
return TypeOnMemory(&internal::fixed_address_empty_string, \
ConstantInitialized{}); \
} \
template <typename Type> \
inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
Expand Down
Loading

0 comments on commit 763d852

Please sign in to comment.