Skip to content

Commit

Permalink
Misc. cleanup: IWYU, clang-tidy, etc.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 674337945
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 13, 2024
1 parent d77bdac commit 0d027c6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/google/protobuf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions src/google/protobuf/wire_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@

#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"
#include "google/protobuf/descriptor.h"
#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.
Expand Down
14 changes: 10 additions & 4 deletions src/google/protobuf/wire_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions src/google/protobuf/wire_format_lite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
67 changes: 35 additions & 32 deletions src/google/protobuf/wire_format_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 0d027c6

Please sign in to comment.