IWYU and format fix.

PiperOrigin-RevId: 595732256
pull/15267/head
Protobuf Team Bot 11 months ago committed by Copybara-Service
parent b7a8a02ad9
commit 4407d1ed7e
  1. 6
      src/google/protobuf/BUILD.bazel
  2. 1
      src/google/protobuf/compiler/cpp/BUILD.bazel
  3. 46
      src/google/protobuf/compiler/cpp/message_size_unittest.cc
  4. 6
      src/google/protobuf/generated_message_reflection_unittest.cc
  5. 9
      src/google/protobuf/generated_message_tctable_lite_test.cc

@ -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",
@ -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",

@ -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",

@ -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.
@ -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);
@ -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);
@ -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));
@ -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));
@ -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));
@ -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));
@ -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);
@ -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));
@ -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
@ -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);
@ -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
@ -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);

@ -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"

@ -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"

Loading…
Cancel
Save