protobuf/src/google/protobuf/parse_context.h
Go to the documentation of this file.
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_PARSE_CONTEXT_H__
32 #define GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
33 
34 #include <cstdint>
35 #include <cstring>
36 #include <string>
37 
38 #include <google/protobuf/io/coded_stream.h>
39 #include <google/protobuf/io/zero_copy_stream.h>
40 #include <google/protobuf/arena.h>
41 #include <google/protobuf/arenastring.h>
42 #include <google/protobuf/implicit_weak_message.h>
43 #include <google/protobuf/inlined_string_field.h>
44 #include <google/protobuf/metadata_lite.h>
45 #include <google/protobuf/port.h>
46 #include <google/protobuf/repeated_field.h>
47 #include <google/protobuf/wire_format_lite.h>
48 #include <google/protobuf/stubs/strutil.h>
49 
50 #include <google/protobuf/port_def.inc>
51 
52 
53 namespace google {
54 namespace protobuf {
55 
56 class UnknownFieldSet;
57 class DescriptorPool;
58 class MessageFactory;
59 
60 namespace internal {
61 
62 // Template code below needs to know about the existence of these functions.
63 PROTOBUF_EXPORT void WriteVarint(uint32_t num, uint64_t val, std::string* s);
64 PROTOBUF_EXPORT void WriteLengthDelimited(uint32_t num, StringPiece val,
65  std::string* s);
66 // Inline because it is just forwarding to s->WriteVarint
67 inline void WriteVarint(uint32_t num, uint64_t val, UnknownFieldSet* s);
68 inline void WriteLengthDelimited(uint32_t num, StringPiece val,
69  UnknownFieldSet* s);
70 
71 
72 // The basic abstraction the parser is designed for is a slight modification
73 // of the ZeroCopyInputStream (ZCIS) abstraction. A ZCIS presents a serialized
74 // stream as a series of buffers that concatenate to the full stream.
75 // Pictorially a ZCIS presents a stream in chunks like so
76 // [---------------------------------------------------------------]
77 // [---------------------] chunk 1
78 // [----------------------------] chunk 2
79 // chunk 3 [--------------]
80 //
81 // Where the '-' represent the bytes which are vertically lined up with the
82 // bytes of the stream. The proto parser requires its input to be presented
83 // similarly with the extra
84 // property that each chunk has kSlopBytes past its end that overlaps with the
85 // first kSlopBytes of the next chunk, or if there is no next chunk at least its
86 // still valid to read those bytes. Again, pictorially, we now have
87 //
88 // [---------------------------------------------------------------]
89 // [-------------------....] chunk 1
90 // [------------------------....] chunk 2
91 // chunk 3 [------------------..**]
92 // chunk 4 [--****]
93 // Here '-' mean the bytes of the stream or chunk and '.' means bytes past the
94 // chunk that match up with the start of the next chunk. Above each chunk has
95 // 4 '.' after the chunk. In the case these 'overflow' bytes represents bytes
96 // past the stream, indicated by '*' above, their values are unspecified. It is
97 // still legal to read them (ie. should not segfault). Reading past the
98 // end should be detected by the user and indicated as an error.
99 //
100 // The reason for this, admittedly, unconventional invariant is to ruthlessly
101 // optimize the protobuf parser. Having an overlap helps in two important ways.
102 // Firstly it alleviates having to performing bounds checks if a piece of code
103 // is guaranteed to not read more than kSlopBytes. Secondly, and more
104 // importantly, the protobuf wireformat is such that reading a key/value pair is
105 // always less than 16 bytes. This removes the need to change to next buffer in
106 // the middle of reading primitive values. Hence there is no need to store and
107 // load the current position.
108 
109 class PROTOBUF_EXPORT EpsCopyInputStream {
110  public:
111  enum { kSlopBytes = 16, kMaxCordBytesToCopy = 512 };
112 
113  explicit EpsCopyInputStream(bool enable_aliasing)
114  : aliasing_(enable_aliasing ? kOnPatch : kNoAliasing) {}
115 
116  void BackUp(const char* ptr) {
117  GOOGLE_DCHECK(ptr <= buffer_end_ + kSlopBytes);
118  int count;
119  if (next_chunk_ == buffer_) {
120  count = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
121  } else {
122  count = size_ + static_cast<int>(buffer_end_ - ptr);
123  }
124  if (count > 0) StreamBackUp(count);
125  }
126 
127  // If return value is negative it's an error
128  PROTOBUF_NODISCARD int PushLimit(const char* ptr, int limit) {
129  GOOGLE_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes);
130  // This add is safe due to the invariant above, because
131  // ptr - buffer_end_ <= kSlopBytes.
132  limit += static_cast<int>(ptr - buffer_end_);
133  limit_end_ = buffer_end_ + (std::min)(0, limit);
134  auto old_limit = limit_;
135  limit_ = limit;
136  return old_limit - limit;
137  }
138 
139  PROTOBUF_NODISCARD bool PopLimit(int delta) {
140  if (PROTOBUF_PREDICT_FALSE(!EndedAtLimit())) return false;
141  limit_ = limit_ + delta;
142  // TODO(gerbens) We could remove this line and hoist the code to
143  // DoneFallback. Study the perf/bin-size effects.
144  limit_end_ = buffer_end_ + (std::min)(0, limit_);
145  return true;
146  }
147 
148  PROTOBUF_NODISCARD const char* Skip(const char* ptr, int size) {
149  if (size <= buffer_end_ + kSlopBytes - ptr) {
150  return ptr + size;
151  }
152  return SkipFallback(ptr, size);
153  }
154  PROTOBUF_NODISCARD const char* ReadString(const char* ptr, int size,
155  std::string* s) {
156  if (size <= buffer_end_ + kSlopBytes - ptr) {
157  s->assign(ptr, size);
158  return ptr + size;
159  }
160  return ReadStringFallback(ptr, size, s);
161  }
162  PROTOBUF_NODISCARD const char* AppendString(const char* ptr, int size,
163  std::string* s) {
164  if (size <= buffer_end_ + kSlopBytes - ptr) {
165  s->append(ptr, size);
166  return ptr + size;
167  }
168  return AppendStringFallback(ptr, size, s);
169  }
170  // Implemented in arenastring.cc
171  PROTOBUF_NODISCARD const char* ReadArenaString(const char* ptr,
172  ArenaStringPtr* s,
173  Arena* arena);
174 
175  template <typename Tag, typename T>
176  PROTOBUF_NODISCARD const char* ReadRepeatedFixed(const char* ptr,
177  Tag expected_tag,
179 
180  template <typename T>
181  PROTOBUF_NODISCARD const char* ReadPackedFixed(const char* ptr, int size,
183  template <typename Add>
184  PROTOBUF_NODISCARD const char* ReadPackedVarint(const char* ptr, Add add);
185 
186  uint32_t LastTag() const { return last_tag_minus_1_ + 1; }
187  bool ConsumeEndGroup(uint32_t start_tag) {
188  bool res = last_tag_minus_1_ == start_tag;
189  last_tag_minus_1_ = 0;
190  return res;
191  }
192  bool EndedAtLimit() const { return last_tag_minus_1_ == 0; }
193  bool EndedAtEndOfStream() const { return last_tag_minus_1_ == 1; }
194  void SetLastTag(uint32_t tag) { last_tag_minus_1_ = tag - 1; }
195  void SetEndOfStream() { last_tag_minus_1_ = 1; }
196  bool IsExceedingLimit(const char* ptr) {
197  return ptr > limit_end_ &&
198  (next_chunk_ == nullptr || ptr - buffer_end_ > limit_);
199  }
200  int BytesUntilLimit(const char* ptr) const {
201  return limit_ + static_cast<int>(buffer_end_ - ptr);
202  }
203  // Returns true if more data is available, if false is returned one has to
204  // call Done for further checks.
205  bool DataAvailable(const char* ptr) { return ptr < limit_end_; }
206 
207  protected:
208  // Returns true is limit (either an explicit limit or end of stream) is
209  // reached. It aligns *ptr across buffer seams.
210  // If limit is exceeded it returns true and ptr is set to null.
211  bool DoneWithCheck(const char** ptr, int d) {
212  GOOGLE_DCHECK(*ptr);
213  if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false;
214  int overrun = static_cast<int>(*ptr - buffer_end_);
215  GOOGLE_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop.
216  if (overrun ==
217  limit_) { // No need to flip buffers if we ended on a limit.
218  // If we actually overrun the buffer and next_chunk_ is null. It means
219  // the stream ended and we passed the stream end.
220  if (overrun > 0 && next_chunk_ == nullptr) *ptr = nullptr;
221  return true;
222  }
223  auto res = DoneFallback(overrun, d);
224  *ptr = res.first;
225  return res.second;
226  }
227 
228  const char* InitFrom(StringPiece flat) {
229  overall_limit_ = 0;
230  if (flat.size() > kSlopBytes) {
231  limit_ = kSlopBytes;
232  limit_end_ = buffer_end_ = flat.data() + flat.size() - kSlopBytes;
233  next_chunk_ = buffer_;
234  if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
235  return flat.data();
236  } else {
237  std::memcpy(buffer_, flat.data(), flat.size());
238  limit_ = 0;
239  limit_end_ = buffer_end_ = buffer_ + flat.size();
240  next_chunk_ = nullptr;
241  if (aliasing_ == kOnPatch) {
242  aliasing_ = reinterpret_cast<std::uintptr_t>(flat.data()) -
243  reinterpret_cast<std::uintptr_t>(buffer_);
244  }
245  return buffer_;
246  }
247  }
248 
249  const char* InitFrom(io::ZeroCopyInputStream* zcis);
250 
251  const char* InitFrom(io::ZeroCopyInputStream* zcis, int limit) {
252  if (limit == -1) return InitFrom(zcis);
253  overall_limit_ = limit;
254  auto res = InitFrom(zcis);
255  limit_ = limit - static_cast<int>(buffer_end_ - res);
256  limit_end_ = buffer_end_ + (std::min)(0, limit_);
257  return res;
258  }
259 
260  private:
261  const char* limit_end_; // buffer_end_ + min(limit_, 0)
262  const char* buffer_end_;
263  const char* next_chunk_;
264  int size_;
265  int limit_; // relative to buffer_end_;
266  io::ZeroCopyInputStream* zcis_ = nullptr;
267  char buffer_[2 * kSlopBytes] = {};
268  enum { kNoAliasing = 0, kOnPatch = 1, kNoDelta = 2 };
269  std::uintptr_t aliasing_ = kNoAliasing;
270  // This variable is used to communicate how the parse ended, in order to
271  // completely verify the parsed data. A wire-format parse can end because of
272  // one of the following conditions:
273  // 1) A parse can end on a pushed limit.
274  // 2) A parse can end on End Of Stream (EOS).
275  // 3) A parse can end on 0 tag (only valid for toplevel message).
276  // 4) A parse can end on an end-group tag.
277  // This variable should always be set to 0, which indicates case 1. If the
278  // parse terminated due to EOS (case 2), it's set to 1. In case the parse
279  // ended due to a terminating tag (case 3 and 4) it's set to (tag - 1).
280  // This var doesn't really belong in EpsCopyInputStream and should be part of
281  // the ParseContext, but case 2 is most easily and optimally implemented in
282  // DoneFallback.
283  uint32_t last_tag_minus_1_ = 0;
284  int overall_limit_ = INT_MAX; // Overall limit independent of pushed limits.
285  // Pretty random large number that seems like a safe allocation on most
286  // systems. TODO(gerbens) do we need to set this as build flag?
287  enum { kSafeStringSize = 50000000 };
288 
289  // Advances to next buffer chunk returns a pointer to the same logical place
290  // in the stream as set by overrun. Overrun indicates the position in the slop
291  // region the parse was left (0 <= overrun <= kSlopBytes). Returns true if at
292  // limit, at which point the returned pointer maybe null if there was an
293  // error. The invariant of this function is that it's guaranteed that
294  // kSlopBytes bytes can be accessed from the returned ptr. This function might
295  // advance more buffers than one in the underlying ZeroCopyInputStream.
296  std::pair<const char*, bool> DoneFallback(int overrun, int depth);
297  // Advances to the next buffer, at most one call to Next() on the underlying
298  // ZeroCopyInputStream is made. This function DOES NOT match the returned
299  // pointer to where in the slop region the parse ends, hence no overrun
300  // parameter. This is useful for string operations where you always copy
301  // to the end of the buffer (including the slop region).
302  const char* Next();
303  // overrun is the location in the slop region the stream currently is
304  // (0 <= overrun <= kSlopBytes). To prevent flipping to the next buffer of
305  // the ZeroCopyInputStream in the case the parse will end in the last
306  // kSlopBytes of the current buffer. depth is the current depth of nested
307  // groups (or negative if the use case does not need careful tracking).
308  inline const char* NextBuffer(int overrun, int depth);
309  const char* SkipFallback(const char* ptr, int size);
310  const char* AppendStringFallback(const char* ptr, int size, std::string* str);
311  const char* ReadStringFallback(const char* ptr, int size, std::string* str);
312  bool StreamNext(const void** data) {
313  bool res = zcis_->Next(data, &size_);
314  if (res) overall_limit_ -= size_;
315  return res;
316  }
317  void StreamBackUp(int count) {
318  zcis_->BackUp(count);
319  overall_limit_ += count;
320  }
321 
322  template <typename A>
323  const char* AppendSize(const char* ptr, int size, const A& append) {
324  int chunk_size = buffer_end_ + kSlopBytes - ptr;
325  do {
326  GOOGLE_DCHECK(size > chunk_size);
327  if (next_chunk_ == nullptr) return nullptr;
328  append(ptr, chunk_size);
329  ptr += chunk_size;
330  size -= chunk_size;
331  // TODO(gerbens) Next calls NextBuffer which generates buffers with
332  // overlap and thus incurs cost of copying the slop regions. This is not
333  // necessary for reading strings. We should just call Next buffers.
334  if (limit_ <= kSlopBytes) return nullptr;
335  ptr = Next();
336  if (ptr == nullptr) return nullptr; // passed the limit
337  ptr += kSlopBytes;
338  chunk_size = buffer_end_ + kSlopBytes - ptr;
339  } while (size > chunk_size);
340  append(ptr, size);
341  return ptr + size;
342  }
343 
344  // AppendUntilEnd appends data until a limit (either a PushLimit or end of
345  // stream. Normal payloads are from length delimited fields which have an
346  // explicit size. Reading until limit only comes when the string takes
347  // the place of a protobuf, ie RawMessage/StringRawMessage, lazy fields and
348  // implicit weak messages. We keep these methods private and friend them.
349  template <typename A>
350  const char* AppendUntilEnd(const char* ptr, const A& append) {
351  if (ptr - buffer_end_ > limit_) return nullptr;
352  while (limit_ > kSlopBytes) {
353  size_t chunk_size = buffer_end_ + kSlopBytes - ptr;
354  append(ptr, chunk_size);
355  ptr = Next();
356  if (ptr == nullptr) return limit_end_;
357  ptr += kSlopBytes;
358  }
359  auto end = buffer_end_ + limit_;
360  GOOGLE_DCHECK(end >= ptr);
361  append(ptr, end - ptr);
362  return end;
363  }
364 
365  PROTOBUF_NODISCARD const char* AppendString(const char* ptr,
366  std::string* str) {
367  return AppendUntilEnd(
368  ptr, [str](const char* p, ptrdiff_t s) { str->append(p, s); });
369  }
370  friend class ImplicitWeakMessage;
371 };
372 
373 // ParseContext holds all data that is global to the entire parse. Most
374 // importantly it contains the input stream, but also recursion depth and also
375 // stores the end group tag, in case a parser ended on a endgroup, to verify
376 // matching start/end group tags.
377 class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
378  public:
379  struct Data {
380  const DescriptorPool* pool = nullptr;
381  MessageFactory* factory = nullptr;
382  Arena* arena = nullptr;
383  };
384 
385  template <typename... T>
386  ParseContext(int depth, bool aliasing, const char** start, T&&... args)
387  : EpsCopyInputStream(aliasing), depth_(depth) {
388  *start = InitFrom(std::forward<T>(args)...);
389  }
390 
391  void TrackCorrectEnding() { group_depth_ = 0; }
392 
393  bool Done(const char** ptr) { return DoneWithCheck(ptr, group_depth_); }
394 
395  int depth() const { return depth_; }
396 
397  Data& data() { return data_; }
398  const Data& data() const { return data_; }
399 
400  const char* ParseMessage(MessageLite* msg, const char* ptr);
401 
402  // This overload supports those few cases where ParseMessage is called
403  // on a class that is not actually a proto message.
404  // TODO(jorg): Eliminate this use case.
405  template <typename T,
407  bool>::type = true>
408  PROTOBUF_NODISCARD const char* ParseMessage(T* msg, const char* ptr);
409 
410  template <typename T>
411  PROTOBUF_NODISCARD PROTOBUF_NDEBUG_INLINE const char* ParseGroup(
412  T* msg, const char* ptr, uint32_t tag) {
413  if (--depth_ < 0) return nullptr;
414  group_depth_++;
415  ptr = msg->_InternalParse(ptr, this);
416  group_depth_--;
417  depth_++;
418  if (PROTOBUF_PREDICT_FALSE(!ConsumeEndGroup(tag))) return nullptr;
419  return ptr;
420  }
421 
422  private:
423  // Out-of-line routine to save space in ParseContext::ParseMessage<T>
424  // int old;
425  // ptr = ReadSizeAndPushLimitAndDepth(ptr, &old)
426  // is equivalent to:
427  // int size = ReadSize(&ptr);
428  // if (!ptr) return nullptr;
429  // int old = PushLimit(ptr, size);
430  // if (--depth_ < 0) return nullptr;
431  PROTOBUF_NODISCARD const char* ReadSizeAndPushLimitAndDepth(const char* ptr,
432  int* old_limit);
433 
434  // The context keeps an internal stack to keep track of the recursive
435  // part of the parse state.
436  // Current depth of the active parser, depth counts down.
437  // This is used to limit recursion depth (to prevent overflow on malicious
438  // data), but is also used to index in stack_ to store the current state.
439  int depth_;
440  // Unfortunately necessary for the fringe case of ending on 0 or end-group tag
441  // in the last kSlopBytes of a ZeroCopyInputStream chunk.
442  int group_depth_ = INT_MIN;
443  Data data_;
444 };
445 
446 template <uint32_t tag>
447 bool ExpectTag(const char* ptr) {
448  if (tag < 128) {
449  return *ptr == static_cast<char>(tag);
450  } else {
451  static_assert(tag < 128 * 128, "We only expect tags for 1 or 2 bytes");
452  char buf[2] = {static_cast<char>(tag | 0x80), static_cast<char>(tag >> 7)};
453  return std::memcmp(ptr, buf, 2) == 0;
454  }
455 }
456 
457 template <int>
458 struct EndianHelper;
459 
460 template <>
461 struct EndianHelper<1> {
462  static uint8_t Load(const void* p) { return *static_cast<const uint8_t*>(p); }
463 };
464 
465 template <>
466 struct EndianHelper<2> {
467  static uint16_t Load(const void* p) {
468  uint16_t tmp;
469  std::memcpy(&tmp, p, 2);
470 #ifndef PROTOBUF_LITTLE_ENDIAN
471  tmp = bswap_16(tmp);
472 #endif
473  return tmp;
474  }
475 };
476 
477 template <>
478 struct EndianHelper<4> {
479  static uint32_t Load(const void* p) {
480  uint32_t tmp;
481  std::memcpy(&tmp, p, 4);
482 #ifndef PROTOBUF_LITTLE_ENDIAN
483  tmp = bswap_32(tmp);
484 #endif
485  return tmp;
486  }
487 };
488 
489 template <>
490 struct EndianHelper<8> {
491  static uint64_t Load(const void* p) {
492  uint64_t tmp;
493  std::memcpy(&tmp, p, 8);
494 #ifndef PROTOBUF_LITTLE_ENDIAN
495  tmp = bswap_64(tmp);
496 #endif
497  return tmp;
498  }
499 };
500 
501 template <typename T>
502 T UnalignedLoad(const char* p) {
503  auto tmp = EndianHelper<sizeof(T)>::Load(p);
504  T res;
505  memcpy(&res, &tmp, sizeof(T));
506  return res;
507 }
508 
509 PROTOBUF_EXPORT
510 std::pair<const char*, uint32_t> VarintParseSlow32(const char* p, uint32_t res);
511 PROTOBUF_EXPORT
512 std::pair<const char*, uint64_t> VarintParseSlow64(const char* p, uint32_t res);
513 
514 inline const char* VarintParseSlow(const char* p, uint32_t res, uint32_t* out) {
515  auto tmp = VarintParseSlow32(p, res);
516  *out = tmp.second;
517  return tmp.first;
518 }
519 
520 inline const char* VarintParseSlow(const char* p, uint32_t res, uint64_t* out) {
521  auto tmp = VarintParseSlow64(p, res);
522  *out = tmp.second;
523  return tmp.first;
524 }
525 
526 template <typename T>
527 PROTOBUF_NODISCARD const char* VarintParse(const char* p, T* out) {
528  auto ptr = reinterpret_cast<const uint8_t*>(p);
529  uint32_t res = ptr[0];
530  if (!(res & 0x80)) {
531  *out = res;
532  return p + 1;
533  }
534  uint32_t byte = ptr[1];
535  res += (byte - 1) << 7;
536  if (!(byte & 0x80)) {
537  *out = res;
538  return p + 2;
539  }
540  return VarintParseSlow(p, res, out);
541 }
542 
543 // Used for tags, could read up to 5 bytes which must be available.
544 // Caller must ensure its safe to call.
545 
546 PROTOBUF_EXPORT
547 std::pair<const char*, uint32_t> ReadTagFallback(const char* p, uint32_t res);
548 
549 // Same as ParseVarint but only accept 5 bytes at most.
550 inline const char* ReadTag(const char* p, uint32_t* out,
551  uint32_t /*max_tag*/ = 0) {
552  uint32_t res = static_cast<uint8_t>(p[0]);
553  if (res < 128) {
554  *out = res;
555  return p + 1;
556  }
557  uint32_t second = static_cast<uint8_t>(p[1]);
558  res += (second - 1) << 7;
559  if (second < 128) {
560  *out = res;
561  return p + 2;
562  }
563  auto tmp = ReadTagFallback(p, res);
564  *out = tmp.second;
565  return tmp.first;
566 }
567 
568 // Decode 2 consecutive bytes of a varint and returns the value, shifted left
569 // by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the
570 // first byte's continuation bit is set.
571 // If bit 15 of return value is set (equivalent to the continuation bits of both
572 // bytes being set) the varint continues, otherwise the parse is done. On x86
573 // movsx eax, dil
574 // add edi, eax
575 // adc [rsi], 1
576 // add eax, eax
577 // and eax, edi
578 inline uint32_t DecodeTwoBytes(const char** ptr) {
579  uint32_t value = UnalignedLoad<uint16_t>(*ptr);
580  // Sign extend the low byte continuation bit
581  uint32_t x = static_cast<int8_t>(value);
582  // This add is an amazing operation, it cancels the low byte continuation bit
583  // from y transferring it to the carry. Simultaneously it also shifts the 7
584  // LSB left by one tightly against high byte varint bits. Hence value now
585  // contains the unpacked value shifted left by 1.
586  value += x;
587  // Use the carry to update the ptr appropriately.
588  *ptr += value < x ? 2 : 1;
589  return value & (x + x); // Mask out the high byte iff no continuation
590 }
591 
592 // More efficient varint parsing for big varints
593 inline const char* ParseBigVarint(const char* p, uint64_t* out) {
594  auto pnew = p;
595  auto tmp = DecodeTwoBytes(&pnew);
596  uint64_t res = tmp >> 1;
597  if (PROTOBUF_PREDICT_TRUE(static_cast<std::int16_t>(tmp) >= 0)) {
598  *out = res;
599  return pnew;
600  }
601  for (std::uint32_t i = 1; i < 5; i++) {
602  pnew = p + 2 * i;
603  tmp = DecodeTwoBytes(&pnew);
604  res += (static_cast<std::uint64_t>(tmp) - 2) << (14 * i - 1);
605  if (PROTOBUF_PREDICT_TRUE(static_cast<std::int16_t>(tmp) >= 0)) {
606  *out = res;
607  return pnew;
608  }
609  }
610  return nullptr;
611 }
612 
613 PROTOBUF_EXPORT
614 std::pair<const char*, int32_t> ReadSizeFallback(const char* p, uint32_t first);
615 // Used for tags, could read up to 5 bytes which must be available. Additionally
616 // it makes sure the unsigned value fits a int32_t, otherwise returns nullptr.
617 // Caller must ensure its safe to call.
618 inline uint32_t ReadSize(const char** pp) {
619  auto p = *pp;
620  uint32_t res = static_cast<uint8_t>(p[0]);
621  if (res < 128) {
622  *pp = p + 1;
623  return res;
624  }
625  auto x = ReadSizeFallback(p, res);
626  *pp = x.first;
627  return x.second;
628 }
629 
630 // Some convenience functions to simplify the generated parse loop code.
631 // Returning the value and updating the buffer pointer allows for nicer
632 // function composition. We rely on the compiler to inline this.
633 // Also in debug compiles having local scoped variables tend to generated
634 // stack frames that scale as O(num fields).
635 inline uint64_t ReadVarint64(const char** p) {
636  uint64_t tmp;
637  *p = VarintParse(*p, &tmp);
638  return tmp;
639 }
640 
641 inline uint32_t ReadVarint32(const char** p) {
642  uint32_t tmp;
643  *p = VarintParse(*p, &tmp);
644  return tmp;
645 }
646 
647 inline int64_t ReadVarintZigZag64(const char** p) {
648  uint64_t tmp;
649  *p = VarintParse(*p, &tmp);
651 }
652 
653 inline int32_t ReadVarintZigZag32(const char** p) {
654  uint64_t tmp;
655  *p = VarintParse(*p, &tmp);
656  return WireFormatLite::ZigZagDecode32(static_cast<uint32_t>(tmp));
657 }
658 
659 template <typename T, typename std::enable_if<
661 PROTOBUF_NODISCARD const char* ParseContext::ParseMessage(T* msg,
662  const char* ptr) {
663  int old;
665  ptr = ptr ? msg->_InternalParse(ptr, this) : nullptr;
666  depth_++;
667  if (!PopLimit(old)) return nullptr;
668  return ptr;
669 }
670 
671 template <typename Tag, typename T>
672 const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr,
673  Tag expected_tag,
675  do {
676  out->Add(UnalignedLoad<T>(ptr));
677  ptr += sizeof(T);
678  if (PROTOBUF_PREDICT_FALSE(ptr >= limit_end_)) return ptr;
679  } while (UnalignedLoad<Tag>(ptr) == expected_tag && (ptr += sizeof(Tag)));
680  return ptr;
681 }
682 
683 // Add any of the following lines to debug which parse function is failing.
684 
685 #define GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, ret) \
686  if (!(predicate)) { \
687  /* ::raise(SIGINT); */ \
688  /* GOOGLE_LOG(ERROR) << "Parse failure"; */ \
689  return ret; \
690  }
691 
692 #define GOOGLE_PROTOBUF_PARSER_ASSERT(predicate) \
693  GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, nullptr)
694 
695 template <typename T>
696 const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size,
699  int nbytes = buffer_end_ + kSlopBytes - ptr;
700  while (size > nbytes) {
701  int num = nbytes / sizeof(T);
702  int old_entries = out->size();
703  out->Reserve(old_entries + num);
704  int block_size = num * sizeof(T);
705  auto dst = out->AddNAlreadyReserved(num);
706 #ifdef PROTOBUF_LITTLE_ENDIAN
707  std::memcpy(dst, ptr, block_size);
708 #else
709  for (int i = 0; i < num; i++)
710  dst[i] = UnalignedLoad<T>(ptr + i * sizeof(T));
711 #endif
712  size -= block_size;
713  if (limit_ <= kSlopBytes) return nullptr;
714  ptr = Next();
715  if (ptr == nullptr) return nullptr;
716  ptr += kSlopBytes - (nbytes - block_size);
717  nbytes = buffer_end_ + kSlopBytes - ptr;
718  }
719  int num = size / sizeof(T);
720  int old_entries = out->size();
721  out->Reserve(old_entries + num);
722  int block_size = num * sizeof(T);
723  auto dst = out->AddNAlreadyReserved(num);
724 #ifdef PROTOBUF_LITTLE_ENDIAN
725  std::memcpy(dst, ptr, block_size);
726 #else
727  for (int i = 0; i < num; i++) dst[i] = UnalignedLoad<T>(ptr + i * sizeof(T));
728 #endif
729  ptr += block_size;
730  if (size != block_size) return nullptr;
731  return ptr;
732 }
733 
734 template <typename Add>
735 const char* ReadPackedVarintArray(const char* ptr, const char* end, Add add) {
736  while (ptr < end) {
737  uint64_t varint;
738  ptr = VarintParse(ptr, &varint);
739  if (ptr == nullptr) return nullptr;
740  add(varint);
741  }
742  return ptr;
743 }
744 
745 template <typename Add>
746 const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) {
747  int size = ReadSize(&ptr);
749  int chunk_size = buffer_end_ - ptr;
750  while (size > chunk_size) {
752  if (ptr == nullptr) return nullptr;
753  int overrun = ptr - buffer_end_;
754  GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes);
755  if (size - chunk_size <= kSlopBytes) {
756  // The current buffer contains all the information needed, we don't need
757  // to flip buffers. However we must parse from a buffer with enough space
758  // so we are not prone to a buffer overflow.
759  char buf[kSlopBytes + 10] = {};
761  GOOGLE_CHECK_LE(size - chunk_size, kSlopBytes);
762  auto end = buf + (size - chunk_size);
763  auto res = ReadPackedVarintArray(buf + overrun, end, add);
764  if (res == nullptr || res != end) return nullptr;
765  return buffer_end_ + (res - buf);
766  }
767  size -= overrun + chunk_size;
769  // We must flip buffers
770  if (limit_ <= kSlopBytes) return nullptr;
771  ptr = Next();
772  if (ptr == nullptr) return nullptr;
773  ptr += overrun;
774  chunk_size = buffer_end_ - ptr;
775  }
776  auto end = ptr + size;
778  return end == ptr ? ptr : nullptr;
779 }
780 
781 // Helper for verification of utf8
782 PROTOBUF_EXPORT
783 bool VerifyUTF8(StringPiece s, const char* field_name);
784 
785 inline bool VerifyUTF8(const std::string* s, const char* field_name) {
786  return VerifyUTF8(*s, field_name);
787 }
788 
789 // All the string parsers with or without UTF checking and for all CTypes.
790 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* InlineGreedyStringParser(
791  std::string* s, const char* ptr, ParseContext* ctx);
792 
793 
794 template <typename T>
795 PROTOBUF_NODISCARD const char* FieldParser(uint64_t tag, T& field_parser,
796  const char* ptr, ParseContext* ctx) {
797  uint32_t number = tag >> 3;
799  using WireType = internal::WireFormatLite::WireType;
800  switch (tag & 7) {
802  uint64_t value;
803  ptr = VarintParse(ptr, &value);
805  field_parser.AddVarint(number, value);
806  break;
807  }
809  uint64_t value = UnalignedLoad<uint64_t>(ptr);
810  ptr += 8;
811  field_parser.AddFixed64(number, value);
812  break;
813  }
815  ptr = field_parser.ParseLengthDelimited(number, ptr, ctx);
817  break;
818  }
820  ptr = field_parser.ParseGroup(number, ptr, ctx);
822  break;
823  }
825  GOOGLE_LOG(FATAL) << "Can't happen";
826  break;
827  }
829  uint32_t value = UnalignedLoad<uint32_t>(ptr);
830  ptr += 4;
831  field_parser.AddFixed32(number, value);
832  break;
833  }
834  default:
835  return nullptr;
836  }
837  return ptr;
838 }
839 
840 template <typename T>
841 PROTOBUF_NODISCARD const char* WireFormatParser(T& field_parser,
842  const char* ptr,
843  ParseContext* ctx) {
844  while (!ctx->Done(&ptr)) {
845  uint32_t tag;
846  ptr = ReadTag(ptr, &tag);
848  if (tag == 0 || (tag & 7) == 4) {
849  ctx->SetLastTag(tag);
850  return ptr;
851  }
852  ptr = FieldParser(tag, field_parser, ptr, ctx);
854  }
855  return ptr;
856 }
857 
858 // The packed parsers parse repeated numeric primitives directly into the
859 // corresponding field
860 
861 // These are packed varints
862 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt32Parser(
863  void* object, const char* ptr, ParseContext* ctx);
864 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt32Parser(
865  void* object, const char* ptr, ParseContext* ctx);
866 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt64Parser(
867  void* object, const char* ptr, ParseContext* ctx);
868 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt64Parser(
869  void* object, const char* ptr, ParseContext* ctx);
870 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt32Parser(
871  void* object, const char* ptr, ParseContext* ctx);
872 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt64Parser(
873  void* object, const char* ptr, ParseContext* ctx);
874 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedEnumParser(
875  void* object, const char* ptr, ParseContext* ctx);
876 
877 template <typename T>
878 PROTOBUF_NODISCARD const char* PackedEnumParser(void* object, const char* ptr,
879  ParseContext* ctx,
880  bool (*is_valid)(int),
882  int field_num) {
883  return ctx->ReadPackedVarint(
884  ptr, [object, is_valid, metadata, field_num](uint64_t val) {
885  if (is_valid(val)) {
886  static_cast<RepeatedField<int>*>(object)->Add(val);
887  } else {
888  WriteVarint(field_num, val, metadata->mutable_unknown_fields<T>());
889  }
890  });
891 }
892 
893 template <typename T>
894 PROTOBUF_NODISCARD const char* PackedEnumParserArg(
895  void* object, const char* ptr, ParseContext* ctx,
896  bool (*is_valid)(const void*, int), const void* data,
897  InternalMetadata* metadata, int field_num) {
898  return ctx->ReadPackedVarint(
899  ptr, [object, is_valid, data, metadata, field_num](uint64_t val) {
900  if (is_valid(data, val)) {
901  static_cast<RepeatedField<int>*>(object)->Add(val);
902  } else {
903  WriteVarint(field_num, val, metadata->mutable_unknown_fields<T>());
904  }
905  });
906 }
907 
908 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedBoolParser(
909  void* object, const char* ptr, ParseContext* ctx);
910 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed32Parser(
911  void* object, const char* ptr, ParseContext* ctx);
912 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed32Parser(
913  void* object, const char* ptr, ParseContext* ctx);
914 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed64Parser(
915  void* object, const char* ptr, ParseContext* ctx);
916 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed64Parser(
917  void* object, const char* ptr, ParseContext* ctx);
918 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFloatParser(
919  void* object, const char* ptr, ParseContext* ctx);
920 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedDoubleParser(
921  void* object, const char* ptr, ParseContext* ctx);
922 
923 // This is the only recursive parser.
924 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownGroupLiteParse(
925  std::string* unknown, const char* ptr, ParseContext* ctx);
926 // This is a helper to for the UnknownGroupLiteParse but is actually also
927 // useful in the generated code. It uses overload on std::string* vs
928 // UnknownFieldSet* to make the generated code isomorphic between full and lite.
929 PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownFieldParse(
930  uint32_t tag, std::string* unknown, const char* ptr, ParseContext* ctx);
931 
932 } // namespace internal
933 } // namespace protobuf
934 } // namespace google
935 
936 #include <google/protobuf/port_undef.inc>
937 
938 #endif // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
xds_interop_client.str
str
Definition: xds_interop_client.py:487
google::protobuf.internal::EpsCopyInputStream::ReadRepeatedFixed
const PROTOBUF_MUST_USE_RESULT char * ReadRepeatedFixed(const char *ptr, Tag expected_tag, RepeatedField< T > *out)
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf.internal::ReadVarintZigZag64
int64 ReadVarintZigZag64(const char **p)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:584
google::protobuf.internal::ReadTag
const char * ReadTag(const char *p, uint32 *out, uint32 max_tag=0)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:494
google::protobuf.internal::ParseContext::ReadSizeAndPushLimitAndDepth
const PROTOBUF_NODISCARD char * ReadSizeAndPushLimitAndDepth(const char *ptr, int *old_limit)
Definition: protobuf/src/google/protobuf/parse_context.cc:279
google::protobuf.internal::EpsCopyInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:107
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
google::protobuf.internal::VarintParseSlow32
std::pair< const char *, uint32 > VarintParseSlow32(const char *p, uint32 res)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:340
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
google::protobuf.internal::VarintParseSlow
const char * VarintParseSlow(const char *p, uint32 res, uint32 *out)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:458
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf.internal::ReadSize
uint32 ReadSize(const char **pp)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:561
google::protobuf.internal::EpsCopyInputStream::InitFrom
const char * InitFrom(StringPiece flat)
Definition: protobuf/src/google/protobuf/parse_context.h:228
ctx
Definition: benchmark-async.c:30
google::protobuf.internal::VarintParseSlow64
std::pair< const char *, uint64 > VarintParseSlow64(const char *p, uint32 res32)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:358
metadata
Definition: cq_verifier.cc:48
google::protobuf.internal::ParseContext::ParseMessage
const PROTOBUF_MUST_USE_RESULT char * ParseMessage(T *msg, const char *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:597
google::protobuf.internal::EpsCopyInputStream::ReadPackedVarint
const PROTOBUF_MUST_USE_RESULT char * ReadPackedVarint(const char *ptr, Add add)
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
google::protobuf::StringPiece::data
const char * data() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:247
google::protobuf.internal::EpsCopyInputStream::SetEndOfStream
void SetEndOfStream()
Definition: protobuf/src/google/protobuf/parse_context.h:195
google::protobuf::bswap_16
static uint16 bswap_16(uint16 x)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:276
google::protobuf.internal::ParseContext::ParseGroup
PROTOBUF_NODISCARD const PROTOBUF_NDEBUG_INLINE char * ParseGroup(T *msg, const char *ptr, uint32_t tag)
Definition: protobuf/src/google/protobuf/parse_context.h:411
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf.internal::UnknownGroupLiteParse
const char * UnknownGroupLiteParse(std::string *unknown, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:600
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf.internal::EpsCopyInputStream::LastTag
uint32_t LastTag() const
Definition: protobuf/src/google/protobuf/parse_context.h:186
google::protobuf.internal::UnknownFieldParse
const char * UnknownFieldParse(uint32 tag, std::string *unknown, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:606
Arena
Definition: arena.c:39
google::protobuf.internal.wire_format.WIRETYPE_START_GROUP
int WIRETYPE_START_GROUP
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:50
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf.internal::PackedBoolParser
const char * PackedBoolParser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:512
google::protobuf.internal::ParseContext
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:336
google::protobuf.internal::EpsCopyInputStream::EndedAtLimit
bool EndedAtLimit() const
Definition: protobuf/src/google/protobuf/parse_context.h:192
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf.internal::ParseContext::data
Data & data()
Definition: protobuf/src/google/protobuf/parse_context.h:397
google::protobuf::RepeatedField< T >
xds_manager.p
p
Definition: xds_manager.py:60
google::protobuf::python::cdescriptor_pool::Add
static PyObject * Add(PyObject *self, PyObject *file_descriptor_proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/descriptor_pool.cc:621
google::protobuf.internal::EpsCopyInputStream::ReadString
const PROTOBUF_NODISCARD char * ReadString(const char *ptr, int size, std::string *s)
Definition: protobuf/src/google/protobuf/parse_context.h:154
google::protobuf::MessageLite
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:184
second
StrT second
Definition: cxa_demangle.cpp:4885
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:2512
absl::base_internal::Next
static AllocList * Next(int i, AllocList *prev, LowLevelAlloc::Arena *arena)
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:453
google::protobuf::MessageFactory
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:1066
T
#define T(upbtypeconst, upbtype, ctype, default_value)
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
google::protobuf.internal::ReadPackedVarintArray
const char * ReadPackedVarintArray(const char *ptr, const char *end, Add add)
Definition: protobuf/src/google/protobuf/parse_context.h:735
google::protobuf.internal::PackedFixed64Parser
const char * PackedFixed64Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:532
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf.internal::EpsCopyInputStream::ConsumeEndGroup
bool ConsumeEndGroup(uint32_t start_tag)
Definition: protobuf/src/google/protobuf/parse_context.h:187
buffer_
static uint8 buffer_[kBufferSize]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:136
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
google::protobuf.internal::EpsCopyInputStream::buffer_end_
const char * buffer_end_
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:250
google::protobuf.internal::EpsCopyInputStream::ReadPackedFixed
const PROTOBUF_MUST_USE_RESULT char * ReadPackedFixed(const char *ptr, int size, RepeatedField< T > *out)
start
static uint64_t start
Definition: benchmark-pound.c:74
google::protobuf.internal::EpsCopyInputStream::StreamBackUp
void StreamBackUp(int count)
Definition: protobuf/src/google/protobuf/parse_context.h:317
google::protobuf.internal::EpsCopyInputStream::AppendUntilEnd
const char * AppendUntilEnd(const char *ptr, const A &append)
Definition: protobuf/src/google/protobuf/parse_context.h:350
int16_t
signed short int16_t
Definition: stdint-msvc2008.h:76
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
google::protobuf.internal::ParseBigVarint
const char * ParseBigVarint(const char *p, uint64 *out)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:536
GOOGLE_PROTOBUF_PARSER_ASSERT
#define GOOGLE_PROTOBUF_PARSER_ASSERT(predicate)
Definition: protobuf/src/google/protobuf/parse_context.h:692
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
google::protobuf.internal::PackedEnumParser
const char * PackedEnumParser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:478
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
GOOGLE_DCHECK_GT
#define GOOGLE_DCHECK_GT
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:200
google::protobuf.internal::EpsCopyInputStream::SetLastTag
void SetLastTag(uint32_t tag)
Definition: protobuf/src/google/protobuf/parse_context.h:194
google::protobuf.internal::ParseContext::Done
bool Done(const char **ptr)
Definition: protobuf/src/google/protobuf/parse_context.h:393
google::protobuf.internal::ParseContext::Data
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:338
google::protobuf.internal::ParseContext::ParseContext
ParseContext(int depth, bool aliasing, const char **start, T &&... args)
Definition: protobuf/src/google/protobuf/parse_context.h:386
google::protobuf.internal::PackedEnumParserArg
const char * PackedEnumParserArg(void *object, const char *ptr, ParseContext *ctx, bool(*is_valid)(const void *, int), const void *data, InternalMetadataWithArenaLite *metadata, int field_num)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:496
google::protobuf.internal::VarintParse
const PROTOBUF_MUST_USE_RESULT char * VarintParse(const char *p, T *out)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:471
google::protobuf::StringPiece
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:180
google::protobuf.internal::WriteLengthDelimited
void WriteLengthDelimited(uint32 num, StringPiece val, std::string *s)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:334
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf.internal::PackedUInt64Parser
const char * PackedUInt64Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:465
google::protobuf.internal::ImplicitWeakMessage
Definition: bloaty/third_party/protobuf/src/google/protobuf/implicit_weak_message.h:57
opencensus.proto.stats.v1.stats_pb2.Tag
Tag
Definition: stats_pb2.py:431
google::protobuf.internal::EndianHelper< 8 >::Load
static uint64_t Load(const void *p)
Definition: protobuf/src/google/protobuf/parse_context.h:491
google::protobuf::DescriptorPool
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1539
google::protobuf.reflection.ParseMessage
def ParseMessage(descriptor, byte_str)
Definition: third_party/bloaty/third_party/protobuf/python/google/protobuf/reflection.py:62
google::protobuf.internal::InternalMetadata
Definition: protobuf/src/google/protobuf/metadata_lite.h:62
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
google::protobuf.internal::ExpectTag
bool ExpectTag(const char *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:391
depth_
int depth_
Definition: json_writer.cc:73
google::protobuf.internal.wire_format.WIRETYPE_END_GROUP
int WIRETYPE_END_GROUP
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:51
google::protobuf.internal::DecodeTwoBytes
uint32 DecodeTwoBytes(const char **ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:521
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
google::protobuf.internal::EndianHelper< 4 >::Load
static uint32_t Load(const void *p)
Definition: protobuf/src/google/protobuf/parse_context.h:479
google::protobuf.internal::EpsCopyInputStream::EpsCopyInputStream
EpsCopyInputStream(bool enable_aliasing)
Definition: protobuf/src/google/protobuf/parse_context.h:113
google::protobuf.internal::PackedSFixed32Parser
const char * PackedSFixed32Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:528
google::protobuf.internal.wire_format.WIRETYPE_LENGTH_DELIMITED
int WIRETYPE_LENGTH_DELIMITED
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:49
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
min
#define min(a, b)
Definition: qsort.h:83
google::protobuf.internal::InlineGreedyStringParser
const char * InlineGreedyStringParser(std::string *s, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:420
google::protobuf.internal::VerifyUTF8
bool VerifyUTF8(StringPiece str, const char *field_name)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:412
google::protobuf.internal::UnalignedLoad
T UnalignedLoad(const char *p)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:446
google::protobuf.internal::EpsCopyInputStream::InitFrom
const char * InitFrom(io::ZeroCopyInputStream *zcis, int limit)
Definition: protobuf/src/google/protobuf/parse_context.h:251
google::protobuf.internal::FieldParser
const PROTOBUF_MUST_USE_RESULT char * FieldParser(uint64 tag, T &field_parser, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:664
google::protobuf.internal::EpsCopyInputStream::PopLimit
PROTOBUF_MUST_USE_RESULT bool PopLimit(int delta)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:137
google::protobuf.internal::ParseContext::depth
int depth() const
Definition: protobuf/src/google/protobuf/parse_context.h:395
google::protobuf.internal::PackedInt64Parser
const char * PackedInt64Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:461
google::protobuf.internal.wire_format.WIRETYPE_VARINT
int WIRETYPE_VARINT
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:47
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
google::protobuf.internal::EndianHelper< 2 >::Load
static uint16_t Load(const void *p)
Definition: protobuf/src/google/protobuf/parse_context.h:467
google::protobuf.internal.wire_format.WIRETYPE_FIXED32
int WIRETYPE_FIXED32
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:52
add
static void add(const char *beg, const char *end, char ***ss, size_t *ns)
Definition: debug/trace.cc:96
google::protobuf.internal::PackedSFixed64Parser
const char * PackedSFixed64Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:536
google::protobuf.internal::PackedFloatParser
const char * PackedFloatParser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:540
value
const char * value
Definition: hpack_parser_table.cc:165
google::protobuf::io::ZeroCopyInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h:126
google::protobuf.internal::EpsCopyInputStream::DoneWithCheck
bool DoneWithCheck(const char **ptr, int d)
Definition: protobuf/src/google/protobuf/parse_context.h:211
pp
const uint8_t ** pp
Definition: ssl_x509.cc:1020
FATAL
#define FATAL(msg)
Definition: task.h:88
google::protobuf.internal::EpsCopyInputStream::IsExceedingLimit
bool IsExceedingLimit(const char *ptr)
Definition: protobuf/src/google/protobuf/parse_context.h:196
google::protobuf.internal::PackedInt32Parser
const char * PackedInt32Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:453
google::protobuf.internal::EpsCopyInputStream::limit_end_
const char * limit_end_
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:249
google::protobuf.internal::EpsCopyInputStream::EndedAtEndOfStream
bool EndedAtEndOfStream() const
Definition: protobuf/src/google/protobuf/parse_context.h:193
google::protobuf.internal::ReadVarint32
uint32_t ReadVarint32(const char **p)
Definition: protobuf/src/google/protobuf/parse_context.h:641
size_
size_t size_
Definition: memory_allocator.cc:56
google::protobuf.internal::EpsCopyInputStream::BackUp
void BackUp(const char *ptr)
Definition: protobuf/src/google/protobuf/parse_context.h:116
google::protobuf.internal::ReadTagFallback
std::pair< const char *, uint32 > ReadTagFallback(const char *p, uint32 res)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:370
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
google::protobuf.internal::ParseContext::TrackCorrectEnding
void TrackCorrectEnding()
Definition: protobuf/src/google/protobuf/parse_context.h:391
google::protobuf.internal::EpsCopyInputStream::Next
const char * Next()
Definition: protobuf/src/google/protobuf/parse_context.cc:157
google::protobuf::bswap_32
static uint32 bswap_32(uint32 x)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:283
google::protobuf.internal::EpsCopyInputStream::kSlopBytes
@ kSlopBytes
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:109
google::protobuf.internal::EpsCopyInputStream::DataAvailable
bool DataAvailable(const char *ptr)
Definition: protobuf/src/google/protobuf/parse_context.h:205
google::protobuf.internal::EpsCopyInputStream::AppendSize
const char * AppendSize(const char *ptr, int size, const A &append)
Definition: protobuf/src/google/protobuf/parse_context.h:323
first
StrT first
Definition: cxa_demangle.cpp:4884
A
Definition: miscompile_with_no_unique_address_test.cc:23
xds_manager.num
num
Definition: xds_manager.py:56
google::protobuf.internal::ReadSizeFallback
std::pair< const char *, int32 > ReadSizeFallback(const char *p, uint32 res)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:381
data_
std::string data_
Definition: cord_rep_btree_navigator_test.cc:84
google::protobuf.internal::PackedUInt32Parser
const char * PackedUInt32Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:457
google::protobuf.internal::PackedSInt64Parser
const char * PackedSInt64Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:473
google::protobuf.internal::EpsCopyInputStream::AppendString
const PROTOBUF_NODISCARD char * AppendString(const char *ptr, std::string *str)
Definition: protobuf/src/google/protobuf/parse_context.h:365
google::protobuf.internal::EndianHelper< 1 >::Load
static uint8_t Load(const void *p)
Definition: protobuf/src/google/protobuf/parse_context.h:462
google::protobuf.internal::WireFormatLite::WireType
WireType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:101
google::protobuf.internal::PackedSInt32Parser
const char * PackedSInt32Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:469
google::protobuf.internal::EpsCopyInputStream::PopLimit
PROTOBUF_NODISCARD bool PopLimit(int delta)
Definition: protobuf/src/google/protobuf/parse_context.h:139
google::protobuf.internal::ReadVarintZigZag32
int32 ReadVarintZigZag32(const char **p)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:590
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
google::protobuf.internal::EpsCopyInputStream::StreamNext
bool StreamNext(const void **data)
Definition: protobuf/src/google/protobuf/parse_context.h:312
google::protobuf.internal::EpsCopyInputStream::PushLimit
PROTOBUF_NODISCARD int PushLimit(const char *ptr, int limit)
Definition: protobuf/src/google/protobuf/parse_context.h:128
google::protobuf.internal::ParseContext::depth_
int depth_
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:383
google::protobuf.internal::EpsCopyInputStream::AppendString
const PROTOBUF_NODISCARD char * AppendString(const char *ptr, int size, std::string *s)
Definition: protobuf/src/google/protobuf/parse_context.h:162
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::ParseContext::data
const Data & data() const
Definition: protobuf/src/google/protobuf/parse_context.h:398
google::protobuf.internal::PackedFixed32Parser
const char * PackedFixed32Parser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:524
google::protobuf::io::ZeroCopyInputStream::BackUp
virtual void BackUp(int count)=0
int8_t
signed char int8_t
Definition: stdint-msvc2008.h:75
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
google::protobuf.internal::WriteVarint
void WriteVarint(uint64 val, std::string *s)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:320
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
google::protobuf.internal::WireFormatLite::ZigZagDecode64
static int64 ZigZagDecode64(uint64 n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:885
google::protobuf.internal::EpsCopyInputStream::Skip
const PROTOBUF_NODISCARD char * Skip(const char *ptr, int size)
Definition: protobuf/src/google/protobuf/parse_context.h:148
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf::io::ZeroCopyInputStream::Next
virtual bool Next(const void **data, int *size)=0
mkowners.depth
depth
Definition: mkowners.py:114
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
DescriptorPool
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:110
google::protobuf::StringPiece::size
stringpiece_ssize_type size() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:248
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf.internal.wire_format.WIRETYPE_FIXED64
int WIRETYPE_FIXED64
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:48
google::protobuf::bswap_64
static uint64 bswap_64(uint64 x)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:293
GOOGLE_DCHECK_LE
#define GOOGLE_DCHECK_LE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:199
google::protobuf.internal::EpsCopyInputStream::limit_
int limit_
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:253
google::protobuf.internal::WireFormatParser
const PROTOBUF_MUST_USE_RESULT char * WireFormatParser(T &field_parser, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:711
google::protobuf.internal::WireFormatLite::ZigZagDecode32
static int32 ZigZagDecode32(uint32 n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:874
binary_size.old
string old
Definition: binary_size.py:128
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf.internal::ArenaStringPtr
Definition: bloaty/third_party/protobuf/src/google/protobuf/arenastring.h:74
google::protobuf.internal::PackedDoubleParser
const char * PackedDoubleParser(void *object, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:544
GOOGLE_CHECK_LE
#define GOOGLE_CHECK_LE(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:159
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf.internal::EpsCopyInputStream::BytesUntilLimit
int BytesUntilLimit(const char *ptr) const
Definition: protobuf/src/google/protobuf/parse_context.h:200
google::protobuf.internal::ReadVarint64
uint64_t ReadVarint64(const char **p)
Definition: protobuf/src/google/protobuf/parse_context.h:635
RepeatedField
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:403


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:39