The normal case of this is already rejected by the .proto parser, this additional check covers legacy_closed_enum cases. Those cases will otherwise reach a CHECK-fail, this just makes for a clearer error message that this is simply a disallowed combination.
PiperOrigin-RevId: 696648744
To implement extensions in Rust, we are going to need a symbol we can depend on
to force-link the C++ extension registration code. The `descriptor_table_xxxxx`
variable seems ideal for this: it already exists and is not public-facing, so
we can reuse it without increasing code size. This CL marks it `extern "C"` to
ensure that we can safely access it from Rust.
PiperOrigin-RevId: 696615312
The intent of these checks was that if the C++20 version of this feature
are enabled to execute the top codepath. libstdc++ 12 defines this
feature as:
```cpp
// in: /usr/include/c++/12/bits/basic_string.h
#ifdef __cpp_lib_is_constant_evaluated
// Support P0980R1 in C++20.
# define __cpp_lib_constexpr_string 201907L
#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
// Support P0426R1 changes to char_traits in C++17.
# define __cpp_lib_constexpr_string 201611L
#endif
```
So this codepath was always being hit even with -std=c++17 and then
resulted in a failure because the string wasn't actually constinit. This
matches the other use of this feature check in `inlined_string_field.h`
Closes#18890
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/18890 from keith:ks/fix-uses-of-__cpp_lib_constexpr_string edb4f5f6b6
PiperOrigin-RevId: 696526963
This will fix https://github.com/protocolbuffers/protobuf/issues/15957 by not trying to use CLOCK_UPTIME_RAW if the feature test macros are not currently set to make it available.
Since the build system is in charge of the feature test macros, and since this header might be included under any end user program's build system, we can't just #define the macros we would like.
Closes#16951
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16951 from adamnovak:patch-1 cebf44ed71
PiperOrigin-RevId: 696251619
The proto
message A {
SomeMessage text_field = 1;
SomeMessage text = 2;
}
will fail java compilation with a name clash: `method getTextFieldBuilder() is already defined in class...` This is because the `text` field creates a private method (`get{Text}{FieldBuilder}`) which conflicts with the public getter (`get{TextField}{Builder}`) for field 1.
Unlike some name clashes, this one is with a private method and we can just rename the method in this file. Other name clash issues:
- https://github.com/protocolbuffers/protobuf/issues/15411
- https://github.com/protocolbuffers/protobuf/issues/17367
There's some precedent for the `internal` prefix with the protected `internalGetFieldAccessorTable` method on GeneratedMessage.
PiperOrigin-RevId: 694108040
Considering that protobuf depends on absl already, we don't need protobuf's
version of PREDICT_TRUE|FALSE. This CL shrinks port_def.inc.
PiperOrigin-RevId: 694015588
Instead of fetching dependencies by default, we will first look for a local installation and only fetch as a fallback. Two new options are added for forcing either of these behaviors. protobuf_FORCE_FETCH_DEPENDENCIES will always fetch dependencies, and protobuf_PREVENT_FETCH_DEPENDENCIES will never do so.
#test-continuous
PiperOrigin-RevId: 693898394
Packed repeated fields without cached_size use static_cast<int32_t> that may be confused
with bad field names. This change fixes it by using ::int32_t.
PiperOrigin-RevId: 693884622
With C++17 being baseline, PROTOBUF_NODISCARD is no longer necessary. Directly
using [[nodiscard]] makes port_def.inc smaller.
PiperOrigin-RevId: 693808783
Some uses put the `inline` keyword before the attribute, some put it after the
attribute, some didn't put it at all.
Clang is very permissive and it allowed code to work where it breaks in other
compilers. GCC doesn't like if you don't put the keyword, MSVC doesn't like if
the keyword is in the wrong place.
By moving the keyword into the macro we prevent this issue altogether.
PiperOrigin-RevId: 693469310
This CL deletes the per-message C++ functions for operating on repeated fields
and replaces them with functions in the runtime that can work with arbitrary
messages.
Similar to what we did with maps, this required refactoring the code to make it
work with `RepeatedPtrFieldBase`, the untyped base class of
`RepeatedPtrField<T>`. I added a `RustRepeatedMessageHelper` class to allow us
access to the protected methods we need.
This should save a bit of linker input code size, but I think more importantly
we are going to need this eventually to enable tree shaking to work well.
PiperOrigin-RevId: 693394959
I noticed that the use of `unsafe` here was not really necessary, so I tweaked
the code to remove it. If we avoid using `__unstable_leak_raw_message()` then
we don't need to unsafely create a `NonNull`.
PiperOrigin-RevId: 693357956
Allocate extension number 536000000 to Buf
Extension numbers will be allocated one at a time by request.
Once extension declarations are open-sourced for extensions in descriptor.proto, we will move these declarations into a separate config file to declutter descriptor.proto.
PiperOrigin-RevId: 692315472