Skip to content

Commit

Permalink
IWYU and format fix.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595732256
  • Loading branch information
protobuf-github-bot authored and Copybara-Service committed Jan 4, 2024
1 parent b7a8a02 commit 4407d1e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
6 changes: 6 additions & 0 deletions src/google/protobuf/BUILD.bazel
Expand Up @@ -1256,7 +1256,9 @@ cc_test(
":test_util",
"//src/google/protobuf/stubs",
"//src/google/protobuf/testing",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
Expand All @@ -1276,6 +1278,10 @@ cc_test(
":cc_test_protos",
":port",
":protobuf_lite",
"//src/google/protobuf/io",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/compiler/cpp/BUILD.bazel
Expand Up @@ -251,6 +251,7 @@ cc_test(
"//src/google/protobuf",
"//src/google/protobuf:cc_test_protos",
"//src/google/protobuf:port",
"//src/google/protobuf:protobuf_lite",
"@com_google_absl//absl/log:absl_check",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
Expand Down
46 changes: 25 additions & 21 deletions src/google/protobuf/compiler/cpp/message_size_unittest.cc
Expand Up @@ -5,10 +5,14 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include <gmock/gmock.h>
#include <cstdint>
#include <string>

#include <gtest/gtest.h>
#include "absl/log/absl_check.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_bases.h"
#include "google/protobuf/repeated_ptr_field.h"
#include "google/protobuf/unittest.pb.h"

// Must be included last.
Expand Down Expand Up @@ -89,7 +93,7 @@ TEST(GeneratedMessageTest, EmptyMessageWithExtensionsSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
MockExtensionSet extensions; // 24 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes of padding
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48);
Expand All @@ -103,7 +107,7 @@ TEST(GeneratedMessageTest, RecursiveMessageSize) {
int cached_size; // 4 bytes
void* a; // 8 bytes
int32_t i; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 40);
Expand All @@ -115,9 +119,9 @@ TEST(GeneratedMessageTest, OneStringSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
void* data; // 8 bytes
void* data; // 8 bytes
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32);
EXPECT_EQ(sizeof(protobuf_unittest::OneString), sizeof(MockGenerated));
Expand All @@ -126,9 +130,9 @@ TEST(GeneratedMessageTest, OneStringSize) {
TEST(GeneratedMessageTest, MoreStringSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
MockRepeatedPtrField data; // 24 bytes
MockRepeatedPtrField data; // 24 bytes
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48);
EXPECT_EQ(sizeof(protobuf_unittest::MoreString), sizeof(MockGenerated));
Expand All @@ -138,9 +142,9 @@ TEST(GeneratedMessageTest, Int32MessageSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
int32_t data; // 4 bytes
int32_t data; // 4 bytes
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32);
EXPECT_EQ(sizeof(protobuf_unittest::Int32Message), sizeof(MockGenerated));
Expand All @@ -150,9 +154,9 @@ TEST(GeneratedMessageTest, Int64MessageSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
int64_t data; // 8 bytes
int64_t data; // 8 bytes
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32);
EXPECT_EQ(sizeof(protobuf_unittest::Int64Message), sizeof(MockGenerated));
Expand All @@ -162,9 +166,9 @@ TEST(GeneratedMessageTest, BoolMessageSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
bool data; // 1 byte
bool data; // 1 byte
// + 3 bytes padding
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32);
Expand All @@ -175,9 +179,9 @@ TEST(GeneratedMessageTest, OneofSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
void* foo; // 8 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
uint32_t oneof_case[1]; // 4 bytes
uint32_t oneof_case[1]; // 4 bytes
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32);
EXPECT_EQ(sizeof(protobuf_unittest::TestOneof), sizeof(MockGenerated));
Expand All @@ -187,9 +191,9 @@ TEST(GeneratedMessageTest, Oneof2Size) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
void* baz_string; // 8 bytes
void* baz_string; // 8 bytes
int32_t baz_int; // 4 bytes
// + 4 bytes padding
void* foo; // 8 bytes
Expand All @@ -209,7 +213,7 @@ TEST(GeneratedMessageTest, FieldOrderingsSize) {
void* optional_nested_message; // 8 bytes
int64_t my_int; // 8 bytes
float my_float; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 80);
Expand All @@ -221,9 +225,9 @@ TEST(GeneratedMessageTest, TestMessageSize) {
struct MockGenerated : public MockMessageBase { // 16 bytes
int has_bits[1]; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
void* m4; // 8 bytes
void* m4; // 8 bytes
int64_t m2; // 8 bytes
bool m1; // 1 bytes
bool m3; // 1 bytes
Expand Down Expand Up @@ -259,7 +263,7 @@ TEST(GeneratedMessageTest, PackedTypesSize) {
MockRepeatedField packed_enum; // 16 bytes
int packed_enum_cached_byte_size; // 4 bytes
int cached_size; // 4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
// + 0-4 bytes padding
};
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8);
Expand Down
6 changes: 5 additions & 1 deletion src/google/protobuf/generated_message_reflection_unittest.cc
Expand Up @@ -22,16 +22,20 @@
#include "google/protobuf/generated_message_reflection.h"

#include <memory>
#include <string>
#include <vector>

#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "absl/flags/flag.h"
#include "absl/log/absl_check.h"
#include "absl/strings/cord.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/map_test_util.h"
#include "google/protobuf/map_unittest.pb.h"
#include "google/protobuf/message.h"
#include "google/protobuf/test_util.h"
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest.pb.h"
Expand Down
9 changes: 9 additions & 0 deletions src/google/protobuf/generated_message_tctable_lite_test.cc
Expand Up @@ -6,11 +6,20 @@
// https://developers.google.com/open-source/licenses/bsd

#include <cstddef>
#include <cstdint>
#include <cstring>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "google/protobuf/generated_message_tctable_decl.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/parse_context.h"
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/wire_format_lite.h"

Expand Down

0 comments on commit 4407d1e

Please sign in to comment.