Misc. cleanup: IWYU, clang-tidy, etc.

PiperOrigin-RevId: 674337945
pull/18278/head
Protobuf Team Bot 7 months ago committed by Copybara-Service
parent d77bdacc31
commit 0d027c6c46
  1. 1
      src/google/protobuf/BUILD.bazel
  2. 10
      src/google/protobuf/wire_format.cc
  3. 14
      src/google/protobuf/wire_format.h
  4. 10
      src/google/protobuf/wire_format_lite.cc
  5. 67
      src/google/protobuf/wire_format_lite.h

@ -565,6 +565,7 @@ cc_library(
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/hash",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/meta:type_traits",

@ -11,10 +11,14 @@
#include "google/protobuf/wire_format.h"
#include <stack>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/attributes.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/strings/cord.h"
@ -22,14 +26,12 @@
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/dynamic_message.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/map_field.h"
#include "google/protobuf/map_field_inl.h"
#include "google/protobuf/message.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/parse_context.h"
#include "google/protobuf/unknown_field_set.h"
#include "google/protobuf/wire_format_lite.h"
// Must be included last.

@ -16,15 +16,19 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__
#include "google/protobuf/stubs/common.h"
#include <cstddef>
#include <cstdint>
#include "absl/base/casts.h"
#include "absl/log/absl_check.h"
#include "absl/strings/cord.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/message.h"
#include "google/protobuf/metadata_lite.h"
#include "google/protobuf/parse_context.h"
#include "google/protobuf/port.h"
#include "google/protobuf/wire_format_lite.h"
#ifdef SWIG
@ -45,6 +49,8 @@ namespace google {
namespace protobuf {
namespace internal {
class TcParser;
// This class is for internal use by the protocol buffer library and by
// protocol-compiler-generated message classes. It must not be called
// directly by clients.
@ -287,9 +293,9 @@ class PROTOBUF_EXPORT WireFormat {
// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet.
class PROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
public:
UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)
explicit UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)
: unknown_fields_(unknown_fields) {}
~UnknownFieldSetFieldSkipper() override {}
~UnknownFieldSetFieldSkipper() override = default;
// implements FieldSkipper -----------------------------------------
bool SkipField(io::CodedInputStream* input, uint32_t tag) override;

@ -11,17 +11,23 @@
#include "google/protobuf/wire_format_lite.h"
#include <cstddef>
#include <cstdint>
#include <limits>
#include <stack>
#include <new>
#include <string>
#include <vector>
#include <type_traits>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/log/log.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/repeated_field.h"
#include "utf8_validity.h"

@ -17,10 +17,13 @@
#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>
#include <utility>
#include "google/protobuf/stubs/common.h"
#include "absl/base/casts.h"
#include "absl/log/absl_check.h"
#include "absl/strings/string_view.h"
@ -493,33 +496,33 @@ class PROTOBUF_EXPORT WireFormatLite {
uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32NoTagToArray(
const RepeatedField<int32_t>& value, uint8_t* output);
const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64NoTagToArray(
const RepeatedField<int64_t>& value, uint8_t* output);
const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32NoTagToArray(
const RepeatedField<uint32_t>& value, uint8_t* output);
const RepeatedField<uint32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64NoTagToArray(
const RepeatedField<uint64_t>& value, uint8_t* output);
const RepeatedField<uint64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32NoTagToArray(
const RepeatedField<int32_t>& value, uint8_t* output);
const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64NoTagToArray(
const RepeatedField<int64_t>& value, uint8_t* output);
const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32NoTagToArray(
const RepeatedField<uint32_t>& value, uint8_t* output);
const RepeatedField<uint32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64NoTagToArray(
const RepeatedField<uint64_t>& value, uint8_t* output);
const RepeatedField<uint64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32NoTagToArray(
const RepeatedField<int32_t>& value, uint8_t* output);
const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64NoTagToArray(
const RepeatedField<int64_t>& value, uint8_t* output);
const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatNoTagToArray(
const RepeatedField<float>& value, uint8_t* output);
const RepeatedField<float>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleNoTagToArray(
const RepeatedField<double>& value, uint8_t* output);
const RepeatedField<double>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolNoTagToArray(
const RepeatedField<bool>& value, uint8_t* output);
const RepeatedField<bool>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumNoTagToArray(
const RepeatedField<int>& value, uint8_t* output);
const RepeatedField<int>& value, uint8_t* target);
// Write fields, including tags.
template <int field_number>
@ -594,33 +597,33 @@ class PROTOBUF_EXPORT WireFormatLite {
uint8_t* (*Writer)(int, T, uint8_t*), uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32ToArray(
int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
int field_number, const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64ToArray(
int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
int field_number, const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32ToArray(
int field_number, const RepeatedField<uint32_t>& value, uint8_t* output);
int field_number, const RepeatedField<uint32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64ToArray(
int field_number, const RepeatedField<uint64_t>& value, uint8_t* output);
int field_number, const RepeatedField<uint64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32ToArray(
int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
int field_number, const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64ToArray(
int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
int field_number, const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32ToArray(
int field_number, const RepeatedField<uint32_t>& value, uint8_t* output);
int field_number, const RepeatedField<uint32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64ToArray(
int field_number, const RepeatedField<uint64_t>& value, uint8_t* output);
int field_number, const RepeatedField<uint64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32ToArray(
int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
int field_number, const RepeatedField<int32_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64ToArray(
int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
int field_number, const RepeatedField<int64_t>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatToArray(
int field_number, const RepeatedField<float>& value, uint8_t* output);
int field_number, const RepeatedField<float>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleToArray(
int field_number, const RepeatedField<double>& value, uint8_t* output);
int field_number, const RepeatedField<double>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolToArray(
int field_number, const RepeatedField<bool>& value, uint8_t* output);
int field_number, const RepeatedField<bool>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumToArray(
int field_number, const RepeatedField<int>& value, uint8_t* output);
int field_number, const RepeatedField<int>& value, uint8_t* target);
PROTOBUF_NDEBUG_INLINE static uint8_t* WriteStringToArray(
int field_number, const std::string& value, uint8_t* target);
@ -781,8 +784,8 @@ class PROTOBUF_EXPORT WireFormatLite {
// ExtensionSet is part of the lite library but UnknownFieldSet is not.
class PROTOBUF_EXPORT FieldSkipper {
public:
FieldSkipper() {}
virtual ~FieldSkipper() {}
FieldSkipper() = default;
virtual ~FieldSkipper() = default;
// Skip a field whose tag has already been consumed.
virtual bool SkipField(io::CodedInputStream* input, uint32_t tag);
@ -803,7 +806,7 @@ class PROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {
public:
explicit CodedOutputStreamFieldSkipper(io::CodedOutputStream* unknown_fields)
: unknown_fields_(unknown_fields) {}
~CodedOutputStreamFieldSkipper() override {}
~CodedOutputStreamFieldSkipper() override = default;
// implements FieldSkipper -----------------------------------------
bool SkipField(io::CodedInputStream* input, uint32_t tag) override;

Loading…
Cancel
Save