This allows us to check whether enum field is actually sent over the wire or missing.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/index/remote/Index.proto | ||
---|---|---|
15 | can we just switch to proto2 instead? apart from reserving the zero value, proto3 also requires you to explicitly handle zero in your code (vs being able to set a default in the proto definition) Offsetting enums by one isn't a big deal, but it can be in other cases (consider a number like num_refs where 0 is a meaningful value and offsetting by 1 is really confusing) | |
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp | ||
118–123 | this -1 and +1 everywhere makes me a bit leery. What about template <typename T> std::underlying_type_t<T> toProtobuf(T Value) { return static_cast<std::underlying_type_t<T>>(Value) + 1; } and the inverse? | |
291 | ?! this is a bitfield |
can we just switch to proto2 instead?
apart from reserving the zero value, proto3 also requires you to explicitly handle zero in your code (vs being able to set a default in the proto definition)
Offsetting enums by one isn't a big deal, but it can be in other cases (consider a number like num_refs where 0 is a meaningful value and offsetting by 1 is really confusing)