Bug Summary

File:usr/include/google/protobuf/metadata_lite.h
Warning:line 92, column 14
Called function pointer is null (null dereference)

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name MonitoringService.pb.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-16/lib/clang/16.0.0 -D GOOGLE_PROTOBUF_NO_RTTI=1 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/tools/extra/clangd/index/remote -I /build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/clang-tools-extra/clangd/index/remote -I tools/clang/tools/extra/clangd/../clang-tidy -I /build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/clang/include -I tools/clang/include -I include -I /build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/llvm/include -I /build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/clang-tools-extra/clangd -I tools/clang/tools/extra/clangd -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/= -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20220904122748+c444af1c20b3/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-09-04-125545-48738-1 -x c++ tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc

tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc

1// Generated by the protocol buffer compiler. DO NOT EDIT!
2// source: MonitoringService.proto
3
4#include "MonitoringService.pb.h"
5
6#include <algorithm>
7
8#include <google/protobuf/io/coded_stream.h>
9#include <google/protobuf/extension_set.h>
10#include <google/protobuf/wire_format_lite.h>
11#include <google/protobuf/descriptor.h>
12#include <google/protobuf/generated_message_reflection.h>
13#include <google/protobuf/reflection_ops.h>
14#include <google/protobuf/wire_format.h>
15// @@protoc_insertion_point(includes)
16#include <google/protobuf/port_def.inc>
17namespace clang {
18namespace clangd {
19namespace remote {
20namespace v1 {
21class MonitoringInfoRequestDefaultTypeInternal {
22 public:
23 ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MonitoringInfoRequest> _instance;
24} _MonitoringInfoRequest_default_instance_;
25class MonitoringInfoReplyDefaultTypeInternal {
26 public:
27 ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MonitoringInfoReply> _instance;
28} _MonitoringInfoReply_default_instance_;
29} // namespace v1
30} // namespace remote
31} // namespace clangd
32} // namespace clang
33static void InitDefaultsscc_info_MonitoringInfoReply_MonitoringService_2eproto() {
34 GOOGLE_PROTOBUF_VERIFY_VERSION::google::protobuf::internal::VerifyVersion( 3012004, 3012000
, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
)
;
35
36 {
37 void* ptr = &::clang::clangd::remote::v1::_MonitoringInfoReply_default_instance_;
38 new (ptr) ::clang::clangd::remote::v1::MonitoringInfoReply();
39 ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
40 }
41 ::clang::clangd::remote::v1::MonitoringInfoReply::InitAsDefaultInstance();
42}
43
44::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MonitoringInfoReply_MonitoringService_2eproto =
45 {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized){ ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized
}
, 0, 0, InitDefaultsscc_info_MonitoringInfoReply_MonitoringService_2eproto}, {}};
46
47static void InitDefaultsscc_info_MonitoringInfoRequest_MonitoringService_2eproto() {
48 GOOGLE_PROTOBUF_VERIFY_VERSION::google::protobuf::internal::VerifyVersion( 3012004, 3012000
, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
)
;
49
50 {
51 void* ptr = &::clang::clangd::remote::v1::_MonitoringInfoRequest_default_instance_;
52 new (ptr) ::clang::clangd::remote::v1::MonitoringInfoRequest();
53 ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
54 }
55 ::clang::clangd::remote::v1::MonitoringInfoRequest::InitAsDefaultInstance();
56}
57
58::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MonitoringInfoRequest_MonitoringService_2eproto =
59 {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized){ ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized
}
, 0, 0, InitDefaultsscc_info_MonitoringInfoRequest_MonitoringService_2eproto}, {}};
60
61static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_MonitoringService_2eproto[2];
62static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_MonitoringService_2eproto = nullptr;
63static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_MonitoringService_2eproto = nullptr;
64
65const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_MonitoringService_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
66 ~0u, // no _has_bits_
67 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoRequest, _internal_metadata_),
68 ~0u, // no _extensions_
69 ~0u, // no _oneof_case_
70 ~0u, // no _weak_field_map_
71 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, _has_bits_),
72 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, _internal_metadata_),
73 ~0u, // no _extensions_
74 ~0u, // no _oneof_case_
75 ~0u, // no _weak_field_map_
76 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, uptime_seconds_),
77 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, index_age_seconds_),
78 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, index_commit_hash_),
79 PROTOBUF_FIELD_OFFSET(::clang::clangd::remote::v1::MonitoringInfoReply, index_link_),
80 2,
81 3,
82 0,
83 1,
84};
85static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
86 { 0, -1, sizeof(::clang::clangd::remote::v1::MonitoringInfoRequest)},
87 { 5, 14, sizeof(::clang::clangd::remote::v1::MonitoringInfoReply)},
88};
89
90static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
91 reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::clang::clangd::remote::v1::_MonitoringInfoRequest_default_instance_),
92 reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::clang::clangd::remote::v1::_MonitoringInfoReply_default_instance_),
93};
94
95const char descriptor_table_protodef_MonitoringService_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
96 "\n\027MonitoringService.proto\022\026clang.clangd."
97 "remote.v1\"\027\n\025MonitoringInfoRequest\"w\n\023Mo"
98 "nitoringInfoReply\022\026\n\016uptime_seconds\030\001 \001("
99 "\004\022\031\n\021index_age_seconds\030\002 \001(\004\022\031\n\021index_co"
100 "mmit_hash\030\003 \001(\t\022\022\n\nindex_link\030\004 \001(\t2y\n\007M"
101 "onitor\022n\n\016MonitoringInfo\022-.clang.clangd."
102 "remote.v1.MonitoringInfoRequest\032+.clang."
103 "clangd.remote.v1.MonitoringInfoReply\"\000"
104 ;
105static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_MonitoringService_2eproto_deps[1] = {
106};
107static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_MonitoringService_2eproto_sccs[2] = {
108 &scc_info_MonitoringInfoReply_MonitoringService_2eproto.base,
109 &scc_info_MonitoringInfoRequest_MonitoringService_2eproto.base,
110};
111static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_MonitoringService_2eproto_once;
112const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_MonitoringService_2eproto = {
113 false, false, descriptor_table_protodef_MonitoringService_2eproto, "MonitoringService.proto", 318,
114 &descriptor_table_MonitoringService_2eproto_once, descriptor_table_MonitoringService_2eproto_sccs, descriptor_table_MonitoringService_2eproto_deps, 2, 0,
115 schemas, file_default_instances, TableStruct_MonitoringService_2eproto::offsets,
116 file_level_metadata_MonitoringService_2eproto, 2, file_level_enum_descriptors_MonitoringService_2eproto, file_level_service_descriptors_MonitoringService_2eproto,
117};
118
119// Force running AddDescriptors() at dynamic initialization time.
120static bool dynamic_init_dummy_MonitoringService_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_MonitoringService_2eproto)), true);
121namespace clang {
122namespace clangd {
123namespace remote {
124namespace v1 {
125
126// ===================================================================
127
128void MonitoringInfoRequest::InitAsDefaultInstance() {
129}
130class MonitoringInfoRequest::_Internal {
131 public:
132};
133
134MonitoringInfoRequest::MonitoringInfoRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena)
135 : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
136 SharedCtor();
137 RegisterArenaDtor(arena);
138 // @@protoc_insertion_point(arena_constructor:clang.clangd.remote.v1.MonitoringInfoRequest)
139}
140MonitoringInfoRequest::MonitoringInfoRequest(const MonitoringInfoRequest& from)
141 : ::PROTOBUF_NAMESPACE_ID::Message() {
142 _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
1
Calling 'InternalMetadata::MergeFrom'
143 // @@protoc_insertion_point(copy_constructor:clang.clangd.remote.v1.MonitoringInfoRequest)
144}
145
146void MonitoringInfoRequest::SharedCtor() {
147}
148
149MonitoringInfoRequest::~MonitoringInfoRequest() {
150 // @@protoc_insertion_point(destructor:clang.clangd.remote.v1.MonitoringInfoRequest)
151 SharedDtor();
152 _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
153}
154
155void MonitoringInfoRequest::SharedDtor() {
156 GOOGLE_DCHECK(GetArena() == nullptr)!(!(GetArena() == nullptr)) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 156) << "CHECK failed: " "GetArena() == nullptr" ": "
;
157}
158
159void MonitoringInfoRequest::ArenaDtor(void* object) {
160 MonitoringInfoRequest* _this = reinterpret_cast< MonitoringInfoRequest* >(object);
161 (void)_this;
162}
163void MonitoringInfoRequest::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
164}
165void MonitoringInfoRequest::SetCachedSize(int size) const {
166 _cached_size_.Set(size);
167}
168const MonitoringInfoRequest& MonitoringInfoRequest::default_instance() {
169 ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MonitoringInfoRequest_MonitoringService_2eproto.base);
170 return *internal_default_instance();
171}
172
173
174void MonitoringInfoRequest::Clear() {
175// @@protoc_insertion_point(message_clear_start:clang.clangd.remote.v1.MonitoringInfoRequest)
176 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
177 // Prevent compiler warnings about cached_has_bits being unused
178 (void) cached_has_bits;
179
180 _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
181}
182
183const char* MonitoringInfoRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
184#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
185 ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
186 while (!ctx->Done(&ptr)) {
187 ::PROTOBUF_NAMESPACE_ID::uint32 tag;
188 ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
189 CHK_(ptr);
190 if ((tag & 7) == 4 || tag == 0) {
191 ctx->SetLastTag(tag);
192 goto success;
193 }
194 ptr = UnknownFieldParse(tag,
195 _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
196 ptr, ctx);
197 CHK_(ptr != nullptr);
198 continue;
199 } // while
200success:
201 return ptr;
202failure:
203 ptr = nullptr;
204 goto success;
205#undef CHK_
206}
207
208::PROTOBUF_NAMESPACE_ID::uint8* MonitoringInfoRequest::_InternalSerialize(
209 ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
210 // @@protoc_insertion_point(serialize_to_array_start:clang.clangd.remote.v1.MonitoringInfoRequest)
211 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
212 (void) cached_has_bits;
213
214 if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
215 target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
216 _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
217 }
218 // @@protoc_insertion_point(serialize_to_array_end:clang.clangd.remote.v1.MonitoringInfoRequest)
219 return target;
220}
221
222size_t MonitoringInfoRequest::ByteSizeLong() const {
223// @@protoc_insertion_point(message_byte_size_start:clang.clangd.remote.v1.MonitoringInfoRequest)
224 size_t total_size = 0;
225
226 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
227 // Prevent compiler warnings about cached_has_bits being unused
228 (void) cached_has_bits;
229
230 if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
231 return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
232 _internal_metadata_, total_size, &_cached_size_);
233 }
234 int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
235 SetCachedSize(cached_size);
236 return total_size;
237}
238
239void MonitoringInfoRequest::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
240// @@protoc_insertion_point(generalized_merge_from_start:clang.clangd.remote.v1.MonitoringInfoRequest)
241 GOOGLE_DCHECK_NE(&from, this)!(!((&from) != (this))) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 241) << "CHECK failed: " "(&from) != (this)" ": "
;
242 const MonitoringInfoRequest* source =
243 ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MonitoringInfoRequest>(
244 &from);
245 if (source == nullptr) {
246 // @@protoc_insertion_point(generalized_merge_from_cast_fail:clang.clangd.remote.v1.MonitoringInfoRequest)
247 ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
248 } else {
249 // @@protoc_insertion_point(generalized_merge_from_cast_success:clang.clangd.remote.v1.MonitoringInfoRequest)
250 MergeFrom(*source);
251 }
252}
253
254void MonitoringInfoRequest::MergeFrom(const MonitoringInfoRequest& from) {
255// @@protoc_insertion_point(class_specific_merge_from_start:clang.clangd.remote.v1.MonitoringInfoRequest)
256 GOOGLE_DCHECK_NE(&from, this)!(!((&from) != (this))) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 256) << "CHECK failed: " "(&from) != (this)" ": "
;
257 _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
258 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
259 (void) cached_has_bits;
260
261}
262
263void MonitoringInfoRequest::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
264// @@protoc_insertion_point(generalized_copy_from_start:clang.clangd.remote.v1.MonitoringInfoRequest)
265 if (&from == this) return;
266 Clear();
267 MergeFrom(from);
268}
269
270void MonitoringInfoRequest::CopyFrom(const MonitoringInfoRequest& from) {
271// @@protoc_insertion_point(class_specific_copy_from_start:clang.clangd.remote.v1.MonitoringInfoRequest)
272 if (&from == this) return;
273 Clear();
274 MergeFrom(from);
275}
276
277bool MonitoringInfoRequest::IsInitialized() const {
278 return true;
279}
280
281void MonitoringInfoRequest::InternalSwap(MonitoringInfoRequest* other) {
282 using std::swap;
283 _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
284}
285
286::PROTOBUF_NAMESPACE_ID::Metadata MonitoringInfoRequest::GetMetadata() const {
287 return GetMetadataStatic();
288}
289
290
291// ===================================================================
292
293void MonitoringInfoReply::InitAsDefaultInstance() {
294}
295class MonitoringInfoReply::_Internal {
296 public:
297 using HasBits = decltype(std::declval<MonitoringInfoReply>()._has_bits_);
298 static void set_has_uptime_seconds(HasBits* has_bits) {
299 (*has_bits)[0] |= 4u;
300 }
301 static void set_has_index_age_seconds(HasBits* has_bits) {
302 (*has_bits)[0] |= 8u;
303 }
304 static void set_has_index_commit_hash(HasBits* has_bits) {
305 (*has_bits)[0] |= 1u;
306 }
307 static void set_has_index_link(HasBits* has_bits) {
308 (*has_bits)[0] |= 2u;
309 }
310};
311
312MonitoringInfoReply::MonitoringInfoReply(::PROTOBUF_NAMESPACE_ID::Arena* arena)
313 : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
314 SharedCtor();
315 RegisterArenaDtor(arena);
316 // @@protoc_insertion_point(arena_constructor:clang.clangd.remote.v1.MonitoringInfoReply)
317}
318MonitoringInfoReply::MonitoringInfoReply(const MonitoringInfoReply& from)
319 : ::PROTOBUF_NAMESPACE_ID::Message(),
320 _has_bits_(from._has_bits_) {
321 _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
322 index_commit_hash_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
323 if (from._internal_has_index_commit_hash()) {
324 index_commit_hash_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_index_commit_hash(),
325 GetArena());
326 }
327 index_link_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
328 if (from._internal_has_index_link()) {
329 index_link_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_index_link(),
330 GetArena());
331 }
332 ::memcpy(&uptime_seconds_, &from.uptime_seconds_,
333 static_cast<size_t>(reinterpret_cast<char*>(&index_age_seconds_) -
334 reinterpret_cast<char*>(&uptime_seconds_)) + sizeof(index_age_seconds_));
335 // @@protoc_insertion_point(copy_constructor:clang.clangd.remote.v1.MonitoringInfoReply)
336}
337
338void MonitoringInfoReply::SharedCtor() {
339 ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MonitoringInfoReply_MonitoringService_2eproto.base);
340 index_commit_hash_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
341 index_link_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
342 ::memset(&uptime_seconds_, 0, static_cast<size_t>(
343 reinterpret_cast<char*>(&index_age_seconds_) -
344 reinterpret_cast<char*>(&uptime_seconds_)) + sizeof(index_age_seconds_));
345}
346
347MonitoringInfoReply::~MonitoringInfoReply() {
348 // @@protoc_insertion_point(destructor:clang.clangd.remote.v1.MonitoringInfoReply)
349 SharedDtor();
350 _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
351}
352
353void MonitoringInfoReply::SharedDtor() {
354 GOOGLE_DCHECK(GetArena() == nullptr)!(!(GetArena() == nullptr)) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 354) << "CHECK failed: " "GetArena() == nullptr" ": "
;
355 index_commit_hash_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
356 index_link_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
357}
358
359void MonitoringInfoReply::ArenaDtor(void* object) {
360 MonitoringInfoReply* _this = reinterpret_cast< MonitoringInfoReply* >(object);
361 (void)_this;
362}
363void MonitoringInfoReply::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
364}
365void MonitoringInfoReply::SetCachedSize(int size) const {
366 _cached_size_.Set(size);
367}
368const MonitoringInfoReply& MonitoringInfoReply::default_instance() {
369 ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MonitoringInfoReply_MonitoringService_2eproto.base);
370 return *internal_default_instance();
371}
372
373
374void MonitoringInfoReply::Clear() {
375// @@protoc_insertion_point(message_clear_start:clang.clangd.remote.v1.MonitoringInfoReply)
376 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
377 // Prevent compiler warnings about cached_has_bits being unused
378 (void) cached_has_bits;
379
380 cached_has_bits = _has_bits_[0];
381 if (cached_has_bits & 0x00000003u) {
382 if (cached_has_bits & 0x00000001u) {
383 index_commit_hash_.ClearNonDefaultToEmpty();
384 }
385 if (cached_has_bits & 0x00000002u) {
386 index_link_.ClearNonDefaultToEmpty();
387 }
388 }
389 if (cached_has_bits & 0x0000000cu) {
390 ::memset(&uptime_seconds_, 0, static_cast<size_t>(
391 reinterpret_cast<char*>(&index_age_seconds_) -
392 reinterpret_cast<char*>(&uptime_seconds_)) + sizeof(index_age_seconds_));
393 }
394 _has_bits_.Clear();
395 _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
396}
397
398const char* MonitoringInfoReply::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
399#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
400 _Internal::HasBits has_bits{};
401 ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
402 while (!ctx->Done(&ptr)) {
403 ::PROTOBUF_NAMESPACE_ID::uint32 tag;
404 ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
405 CHK_(ptr);
406 switch (tag >> 3) {
407 // optional uint64 uptime_seconds = 1;
408 case 1:
409 if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
410 _Internal::set_has_uptime_seconds(&has_bits);
411 uptime_seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
412 CHK_(ptr);
413 } else goto handle_unusual;
414 continue;
415 // optional uint64 index_age_seconds = 2;
416 case 2:
417 if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
418 _Internal::set_has_index_age_seconds(&has_bits);
419 index_age_seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
420 CHK_(ptr);
421 } else goto handle_unusual;
422 continue;
423 // optional string index_commit_hash = 3;
424 case 3:
425 if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
426 auto str = _internal_mutable_index_commit_hash();
427 ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
428 #ifndef NDEBUG
429 ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "clang.clangd.remote.v1.MonitoringInfoReply.index_commit_hash");
430 #endif // !NDEBUG
431 CHK_(ptr);
432 } else goto handle_unusual;
433 continue;
434 // optional string index_link = 4;
435 case 4:
436 if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
437 auto str = _internal_mutable_index_link();
438 ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
439 #ifndef NDEBUG
440 ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "clang.clangd.remote.v1.MonitoringInfoReply.index_link");
441 #endif // !NDEBUG
442 CHK_(ptr);
443 } else goto handle_unusual;
444 continue;
445 default: {
446 handle_unusual:
447 if ((tag & 7) == 4 || tag == 0) {
448 ctx->SetLastTag(tag);
449 goto success;
450 }
451 ptr = UnknownFieldParse(tag,
452 _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
453 ptr, ctx);
454 CHK_(ptr != nullptr);
455 continue;
456 }
457 } // switch
458 } // while
459success:
460 _has_bits_.Or(has_bits);
461 return ptr;
462failure:
463 ptr = nullptr;
464 goto success;
465#undef CHK_
466}
467
468::PROTOBUF_NAMESPACE_ID::uint8* MonitoringInfoReply::_InternalSerialize(
469 ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
470 // @@protoc_insertion_point(serialize_to_array_start:clang.clangd.remote.v1.MonitoringInfoReply)
471 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
472 (void) cached_has_bits;
473
474 cached_has_bits = _has_bits_[0];
475 // optional uint64 uptime_seconds = 1;
476 if (cached_has_bits & 0x00000004u) {
477 target = stream->EnsureSpace(target);
478 target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(1, this->_internal_uptime_seconds(), target);
479 }
480
481 // optional uint64 index_age_seconds = 2;
482 if (cached_has_bits & 0x00000008u) {
483 target = stream->EnsureSpace(target);
484 target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_index_age_seconds(), target);
485 }
486
487 // optional string index_commit_hash = 3;
488 if (cached_has_bits & 0x00000001u) {
489 ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
490 this->_internal_index_commit_hash().data(), static_cast<int>(this->_internal_index_commit_hash().length()),
491 ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
492 "clang.clangd.remote.v1.MonitoringInfoReply.index_commit_hash");
493 target = stream->WriteStringMaybeAliased(
494 3, this->_internal_index_commit_hash(), target);
495 }
496
497 // optional string index_link = 4;
498 if (cached_has_bits & 0x00000002u) {
499 ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
500 this->_internal_index_link().data(), static_cast<int>(this->_internal_index_link().length()),
501 ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
502 "clang.clangd.remote.v1.MonitoringInfoReply.index_link");
503 target = stream->WriteStringMaybeAliased(
504 4, this->_internal_index_link(), target);
505 }
506
507 if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
508 target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
509 _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
510 }
511 // @@protoc_insertion_point(serialize_to_array_end:clang.clangd.remote.v1.MonitoringInfoReply)
512 return target;
513}
514
515size_t MonitoringInfoReply::ByteSizeLong() const {
516// @@protoc_insertion_point(message_byte_size_start:clang.clangd.remote.v1.MonitoringInfoReply)
517 size_t total_size = 0;
518
519 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
520 // Prevent compiler warnings about cached_has_bits being unused
521 (void) cached_has_bits;
522
523 cached_has_bits = _has_bits_[0];
524 if (cached_has_bits & 0x0000000fu) {
525 // optional string index_commit_hash = 3;
526 if (cached_has_bits & 0x00000001u) {
527 total_size += 1 +
528 ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
529 this->_internal_index_commit_hash());
530 }
531
532 // optional string index_link = 4;
533 if (cached_has_bits & 0x00000002u) {
534 total_size += 1 +
535 ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
536 this->_internal_index_link());
537 }
538
539 // optional uint64 uptime_seconds = 1;
540 if (cached_has_bits & 0x00000004u) {
541 total_size += 1 +
542 ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
543 this->_internal_uptime_seconds());
544 }
545
546 // optional uint64 index_age_seconds = 2;
547 if (cached_has_bits & 0x00000008u) {
548 total_size += 1 +
549 ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
550 this->_internal_index_age_seconds());
551 }
552
553 }
554 if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
555 return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
556 _internal_metadata_, total_size, &_cached_size_);
557 }
558 int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
559 SetCachedSize(cached_size);
560 return total_size;
561}
562
563void MonitoringInfoReply::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
564// @@protoc_insertion_point(generalized_merge_from_start:clang.clangd.remote.v1.MonitoringInfoReply)
565 GOOGLE_DCHECK_NE(&from, this)!(!((&from) != (this))) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 565) << "CHECK failed: " "(&from) != (this)" ": "
;
566 const MonitoringInfoReply* source =
567 ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MonitoringInfoReply>(
568 &from);
569 if (source == nullptr) {
570 // @@protoc_insertion_point(generalized_merge_from_cast_fail:clang.clangd.remote.v1.MonitoringInfoReply)
571 ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
572 } else {
573 // @@protoc_insertion_point(generalized_merge_from_cast_success:clang.clangd.remote.v1.MonitoringInfoReply)
574 MergeFrom(*source);
575 }
576}
577
578void MonitoringInfoReply::MergeFrom(const MonitoringInfoReply& from) {
579// @@protoc_insertion_point(class_specific_merge_from_start:clang.clangd.remote.v1.MonitoringInfoReply)
580 GOOGLE_DCHECK_NE(&from, this)!(!((&from) != (this))) ? (void)0 : ::google::protobuf::internal
::LogFinisher() = ::google::protobuf::internal::LogMessage( ::
google::protobuf::LOGLEVEL_FATAL, "tools/clang/tools/extra/clangd/index/remote/MonitoringService.pb.cc"
, 580) << "CHECK failed: " "(&from) != (this)" ": "
;
581 _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
582 ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
583 (void) cached_has_bits;
584
585 cached_has_bits = from._has_bits_[0];
586 if (cached_has_bits & 0x0000000fu) {
587 if (cached_has_bits & 0x00000001u) {
588 _internal_set_index_commit_hash(from._internal_index_commit_hash());
589 }
590 if (cached_has_bits & 0x00000002u) {
591 _internal_set_index_link(from._internal_index_link());
592 }
593 if (cached_has_bits & 0x00000004u) {
594 uptime_seconds_ = from.uptime_seconds_;
595 }
596 if (cached_has_bits & 0x00000008u) {
597 index_age_seconds_ = from.index_age_seconds_;
598 }
599 _has_bits_[0] |= cached_has_bits;
600 }
601}
602
603void MonitoringInfoReply::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
604// @@protoc_insertion_point(generalized_copy_from_start:clang.clangd.remote.v1.MonitoringInfoReply)
605 if (&from == this) return;
606 Clear();
607 MergeFrom(from);
608}
609
610void MonitoringInfoReply::CopyFrom(const MonitoringInfoReply& from) {
611// @@protoc_insertion_point(class_specific_copy_from_start:clang.clangd.remote.v1.MonitoringInfoReply)
612 if (&from == this) return;
613 Clear();
614 MergeFrom(from);
615}
616
617bool MonitoringInfoReply::IsInitialized() const {
618 return true;
619}
620
621void MonitoringInfoReply::InternalSwap(MonitoringInfoReply* other) {
622 using std::swap;
623 _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
624 swap(_has_bits_[0], other->_has_bits_[0]);
625 index_commit_hash_.Swap(&other->index_commit_hash_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
626 index_link_.Swap(&other->index_link_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
627 ::PROTOBUF_NAMESPACE_ID::internal::memswap<
628 PROTOBUF_FIELD_OFFSET(MonitoringInfoReply, index_age_seconds_)
629 + sizeof(MonitoringInfoReply::index_age_seconds_)
630 - PROTOBUF_FIELD_OFFSET(MonitoringInfoReply, uptime_seconds_)>(
631 reinterpret_cast<char*>(&uptime_seconds_),
632 reinterpret_cast<char*>(&other->uptime_seconds_));
633}
634
635::PROTOBUF_NAMESPACE_ID::Metadata MonitoringInfoReply::GetMetadata() const {
636 return GetMetadataStatic();
637}
638
639
640// @@protoc_insertion_point(namespace_scope)
641} // namespace v1
642} // namespace remote
643} // namespace clangd
644} // namespace clang
645PROTOBUF_NAMESPACE_OPEN
646template<> PROTOBUF_NOINLINE ::clang::clangd::remote::v1::MonitoringInfoRequest* Arena::CreateMaybeMessage< ::clang::clangd::remote::v1::MonitoringInfoRequest >(Arena* arena) {
647 return Arena::CreateMessageInternal< ::clang::clangd::remote::v1::MonitoringInfoRequest >(arena);
648}
649template<> PROTOBUF_NOINLINE ::clang::clangd::remote::v1::MonitoringInfoReply* Arena::CreateMaybeMessage< ::clang::clangd::remote::v1::MonitoringInfoReply >(Arena* arena) {
650 return Arena::CreateMessageInternal< ::clang::clangd::remote::v1::MonitoringInfoReply >(arena);
651}
652PROTOBUF_NAMESPACE_CLOSE
653
654// @@protoc_insertion_point(global_scope)
655#include <google/protobuf/port_undef.inc>

/usr/include/google/protobuf/metadata_lite.h

1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31#ifndef GOOGLE_PROTOBUF_METADATA_LITE_H__
32#define GOOGLE_PROTOBUF_METADATA_LITE_H__
33
34#include <string>
35#include <google/protobuf/stubs/common.h>
36#include <google/protobuf/arena.h>
37#include <google/protobuf/port.h>
38
39#include <google/protobuf/port_def.inc>
40
41#ifdef SWIG
42#error "You cannot SWIG proto headers"
43#endif
44
45namespace google {
46namespace protobuf {
47namespace internal {
48
49// This is the representation for messages that support arena allocation. It
50// uses a tagged pointer to either store the Arena pointer, if there are no
51// unknown fields, or a pointer to a block of memory with both the Arena pointer
52// and the UnknownFieldSet, if there are unknown fields. This optimization
53// allows for "zero-overhead" storage of the Arena pointer, relative to the
54// above baseline implementation.
55//
56// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
57// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container
58// pointer.
59class InternalMetadata {
60 public:
61 InternalMetadata() : ptr_(nullptr) {}
62 explicit InternalMetadata(Arena* arena) : ptr_(arena) {}
63
64 template <typename T>
65 void Delete() {
66 // Note that Delete<> should be called not more than once.
67 if (have_unknown_fields() && arena() == NULL__null) {
68 delete PtrValue<Container<T>>();
69 }
70 }
71
72 PROTOBUF_ALWAYS_INLINE Arena* arena() const {
73 if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
74 return PtrValue<ContainerBase>()->arena;
75 } else {
76 return PtrValue<Arena>();
77 }
78 }
79
80 PROTOBUF_ALWAYS_INLINE bool have_unknown_fields() const {
81 return PtrTag() == kTagContainer;
82 }
83
84 PROTOBUF_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; }
85
86 template <typename T>
87 PROTOBUF_ALWAYS_INLINE const T& unknown_fields(
88 const T& (*default_instance)()) const {
89 if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
6
Assuming the condition is false
7
Taking false branch
90 return PtrValue<Container<T>>()->unknown_fields;
91 } else {
92 return default_instance();
8
Called function pointer is null (null dereference)
93 }
94 }
95
96 template <typename T>
97 PROTOBUF_ALWAYS_INLINE T* mutable_unknown_fields() {
98 if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) {
99 return &PtrValue<Container<T>>()->unknown_fields;
100 } else {
101 return mutable_unknown_fields_slow<T>();
102 }
103 }
104
105 template <typename T>
106 PROTOBUF_ALWAYS_INLINE void Swap(InternalMetadata* other) {
107 // Semantics here are that we swap only the unknown fields, not the arena
108 // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
109 // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
110 // different states (direct arena pointer vs. container with UFS) so we
111 // cannot simply swap ptr_ and then restore the arena pointers. We reuse
112 // UFS's swap implementation instead.
113 if (have_unknown_fields() || other->have_unknown_fields()) {
114 DoSwap<T>(other->mutable_unknown_fields<T>());
115 }
116 }
117
118 template <typename T>
119 PROTOBUF_ALWAYS_INLINE void MergeFrom(const InternalMetadata& other) {
120 if (other.have_unknown_fields()) {
2
Assuming the condition is true
3
Taking true branch
121 DoMergeFrom<T>(other.unknown_fields<T>(nullptr));
4
Passing null pointer value via 1st parameter 'default_instance'
5
Calling 'InternalMetadata::unknown_fields'
122 }
123 }
124
125 template <typename T>
126 PROTOBUF_ALWAYS_INLINE void Clear() {
127 if (have_unknown_fields()) {
128 DoClear<T>();
129 }
130 }
131
132 private:
133 void* ptr_;
134
135 // Tagged pointer implementation.
136 enum {
137 // ptr_ is an Arena*.
138 kTagArena = 0,
139 // ptr_ is a Container*.
140 kTagContainer = 1,
141 };
142 static constexpr intptr_t kPtrTagMask = 1;
143 static constexpr intptr_t kPtrValueMask = ~kPtrTagMask;
144
145 // Accessors for pointer tag and pointer value.
146 PROTOBUF_ALWAYS_INLINE int PtrTag() const {
147 return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
148 }
149
150 template <typename U>
151 U* PtrValue() const {
152 return reinterpret_cast<U*>(reinterpret_cast<intptr_t>(ptr_) &
153 kPtrValueMask);
154 }
155
156 // If ptr_'s tag is kTagContainer, it points to an instance of this struct.
157 struct ContainerBase {
158 Arena* arena;
159 };
160
161 template <typename T>
162 struct Container : public ContainerBase {
163 T unknown_fields;
164 };
165
166 template <typename T>
167 PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() {
168 Arena* my_arena = arena();
169 Container<T>* container = Arena::Create<Container<T>>(my_arena);
170 // Two-step assignment works around a bug in clang's static analyzer:
171 // https://bugs.llvm.org/show_bug.cgi?id=34198.
172 ptr_ = container;
173 ptr_ = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(ptr_) |
174 kTagContainer);
175 container->arena = my_arena;
176 return &(container->unknown_fields);
177 }
178
179 // Templated functions.
180
181 template <typename T>
182 void DoClear() {
183 mutable_unknown_fields<T>()->Clear();
184 }
185
186 template <typename T>
187 void DoMergeFrom(const T& other) {
188 mutable_unknown_fields<T>()->MergeFrom(other);
189 }
190
191 template <typename T>
192 void DoSwap(T* other) {
193 mutable_unknown_fields<T>()->Swap(other);
194 }
195};
196
197// String Template specializations.
198
199template <>
200inline void InternalMetadata::DoClear<std::string>() {
201 mutable_unknown_fields<std::string>()->clear();
202}
203
204template <>
205inline void InternalMetadata::DoMergeFrom<std::string>(
206 const std::string& other) {
207 mutable_unknown_fields<std::string>()->append(other);
208}
209
210template <>
211inline void InternalMetadata::DoSwap<std::string>(std::string* other) {
212 mutable_unknown_fields<std::string>()->swap(*other);
213}
214
215// This helper RAII class is needed to efficiently parse unknown fields. We
216// should only call mutable_unknown_fields if there are actual unknown fields.
217// The obvious thing to just use a stack string and swap it at the end of
218// the parse won't work, because the destructor of StringOutputStream needs to
219// be called before we can modify the string (it check-fails). Using
220// LiteUnknownFieldSetter setter(&_internal_metadata_);
221// StringOutputStream stream(setter.buffer());
222// guarantees that the string is only swapped after stream is destroyed.
223class PROTOBUF_EXPORT LiteUnknownFieldSetter {
224 public:
225 explicit LiteUnknownFieldSetter(InternalMetadata* metadata)
226 : metadata_(metadata) {
227 if (metadata->have_unknown_fields()) {
228 buffer_.swap(*metadata->mutable_unknown_fields<std::string>());
229 }
230 }
231 ~LiteUnknownFieldSetter() {
232 if (!buffer_.empty())
233 metadata_->mutable_unknown_fields<std::string>()->swap(buffer_);
234 }
235 std::string* buffer() { return &buffer_; }
236
237 private:
238 InternalMetadata* metadata_;
239 std::string buffer_;
240};
241
242} // namespace internal
243} // namespace protobuf
244} // namespace google
245
246#include <google/protobuf/port_undef.inc>
247
248#endif // GOOGLE_PROTOBUF_METADATA_LITE_H__