Besides unnecessary inconsistency on our C symbols, double underscores anywhere in the name are reserved for stdlib use. In practice its unlikely these symbols would ever hit a collision problem (maybe the prior name 'utf8_debug_string' with no prefix as having some risk), but safer to just standardize on this and have no concerns going forward.
PiperOrigin-RevId: 648709299
runtime that does not change observable behavior of the APIs. For example, fast-vs-slow path decisions.
Has to be turned on at compile time, and otherwise it is a noop.
PiperOrigin-RevId: 648412330
make the TcParseTable point to the ClassData.
This will allow the parser to use more information from the class in the
future.
PiperOrigin-RevId: 648377537
- In most cases, migrate to `absl::string_view`.
- When capturing a temporary string in a variable, use `const std::string` without the ref.
We avoid changing virtual function parameters in this CL, since that is a breaking change.
PiperOrigin-RevId: 647686085
error message from Dynamic/DownCastMessage when trying to downcast a
DynamicMessage to a generated type.
Previously the error message would say "can't down cast Foo to Foo", which is
confusing.
PiperOrigin-RevId: 647363909
**Description**
Added a cmake option to enable Unity builds for libprotobuf-lite.
Added missing symmetric include for port_def.inc
Added preproc guards for PROTOBUF_PRAGMA_INIT_SEG so it does not get included multiple times in unity build.
**Motivation and Context**
For large code base, especially in the game dev industry, Unity builds (https://en.wikipedia.org/wiki/Unity_build) are used to speed up the compilations.
Special care must be taken to enable Unity builds for a project, since many translation units will be merged togheter.
Closes#16454
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16454 from jslap-ubi:enable-unity-build a387ffd862
PiperOrigin-RevId: 646581094
We change InferLegacyProtoFeatures to set ctype based on string_type when string_type is set. We need to update CppGenerator::ValidateFeatures to allow both ctype and string_type to be set because it runs after InferLegacyProtoFeatures.
PiperOrigin-RevId: 645480157
This class is preferred over using `typeid` for a few reasons:
- It works with RTTI disabled.
- It works for `DynamicMessage` types.
- It works in custom vtable mode.
PiperOrigin-RevId: 645145751
`Vec<u8>` is a more idiomatic Rust type to return for serialization.
For the C++ kernel, we are able to return this type with no extra copying. We
still use `SerializedData` type for FFI, but convert the result into a
`Vec<u8>` using a new `into_vec` method.
The upb kernel serializes onto an arena, so for upb we do need to copy the data
to get it into a `Vec<u8>`.
PiperOrigin-RevId: 644444571
Hi,
We get a compiler warning in MSVC that a signed/unsigned comparison is executed.
The warning is at around line 1073 in src/google/protobuf/map.h
```cpp
ABSL_DCHECK_GE(new_num_buckets, kMinTableSize); // <-- signed/unsigned comparison
const auto old_table = table_;
const map_index_t old_table_size = num_buckets_;
num_buckets_ = new_num_buckets;
```
This is due to `kMinTableSize` is a enum value. Probably a C++98 way to enforce constexpr.
This PR changes `kMinTableSize` to be a constexpr unsigned `map_index_t` and removes the casts instead of fixing the warning with a cast at ne 1073.
It seems like `kMinTableSize` is correlated with the `TableSize` of this class, which is map_index_t. Therefore the min value can at maximum the max value of map_index_t. And the min value of `kMinTableSize` can also not be negative, as this makes no sense.
It is also nicer to have fewer casts.
Closes#17013
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/17013 from TinyTinni:removes-msvc-warning-map 4f954e8c9b
PiperOrigin-RevId: 644207177
If we have a `oneof Foo` in a message `Bar`, we should access the discriminator as `Bar.Builder.fooCase` rather than `Bar.Builder.getFooCase()`.
PiperOrigin-RevId: 644107242
New code should prefer `features.(pb.cpp).string_type`. We can't use the `deprecated=true` option for now due to failing tests.
PiperOrigin-RevId: 643036543
The noop code was causing big .proto files to time out even though it had no
effect in the compilation after optimizing.
We tried avoiding the extra complexity of preprocessor checks on each use, but
it seems necessary for now.
PiperOrigin-RevId: 642691974
For some reason it seems that `pb::*` does not match the type info symbol for
`pb::CppFeatures`. Ordinarily this does not seem to cause problems, but we
received a report about it causing issues with sanitizers:
https://groups.google.com/g/protobuf/c/ytkvjXXdG2g/m/hk7a5JnCAwAJ
For clarity I made the same change for `upb::`, though I don't think this is
strictly necessary since it is covered by the `*pb::*` glob.
PiperOrigin-RevId: 642390692
In translation units relying heavily on protobufs, this leads to a reduction of around 1% of the number of nodes in the AST.
PiperOrigin-RevId: 641170174
Because we parse options into the generated pool for *all* descriptor pool builds, it's important that it's properly initialized. Notably, if the C++ feature extensions haven't been registered we can end up with crashes from files that specify them.
PiperOrigin-RevId: 641043996
The recent github runner image update changes the MSVC version, and InitializeLog now crashes in optimized builds. Until Abseil works with MSVC, we can just log to stderr in protoc.
PiperOrigin-RevId: 641024759