Skip to content

Commit

Permalink
Minor cleanup: IWYU, shoud_split() instead of ShouldSplit(...).
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 604471605
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Feb 6, 2024
1 parent 41732e8 commit f5a2255
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 77 deletions.
13 changes: 7 additions & 6 deletions cmake/abseil-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFI

if (BUILD_SHARED_LIBS AND MSVC)
# On MSVC Abseil is bundled into a single DLL.
# This condition is necessary as of abseil 20230125.3 when abseil is consumed via add_subdirectory,
# the abseil_dll target is named abseil_dll, while if abseil is consumed via find_package, the target
# is called absl::abseil_dll
# Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released in the minimum version of
# abseil required by protobuf, it is possible to always link absl::abseil_dll and absl::abseil_test_dll
# and remove the if
# This condition is necessary as of abseil 20230125.3 when abseil is consumed
# via add_subdirectory, the abseil_dll target is named abseil_dll, while if
# abseil is consumed via find_package, the target is called absl::abseil_dll
# Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released
# in the minimum version of abseil required by protobuf, it is possible to
# always link absl::abseil_dll and absl::abseil_test_dll and remove the if
if(protobuf_ABSL_PROVIDER STREQUAL "package")
set(protobuf_ABSL_USED_TARGETS absl::abseil_dll)
set(protobuf_ABSL_USED_TEST_TARGETS absl::abseil_test_dll)
Expand Down Expand Up @@ -75,6 +75,7 @@ else()
absl::if_constexpr
absl::layout
absl::log_initialize
absl::log_globals
absl::log_severity
absl::memory
absl::node_hash_map
Expand Down
4 changes: 4 additions & 0 deletions src/google/protobuf/compiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ cc_library(
"//src/google/protobuf/stubs",
"@com_google_absl//absl/algorithm",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
Expand Down Expand Up @@ -421,6 +424,7 @@ cc_test(
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
Expand Down
10 changes: 7 additions & 3 deletions src/google/protobuf/compiler/code_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

#include "google/protobuf/compiler/code_generator.h"

#include <cstddef>
#include <string>
#include <utility>
#include <vector>

#include "absl/log/absl_log.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
Expand All @@ -31,7 +35,7 @@ namespace google {
namespace protobuf {
namespace compiler {

CodeGenerator::~CodeGenerator() {}
CodeGenerator::~CodeGenerator() = default;

bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
const std::string& parameter,
Expand All @@ -40,7 +44,7 @@ bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
// Default implementation is just to call the per file method, and prefix any
// error string with the file to provide context.
bool succeeded = true;
for (int i = 0; i < files.size(); i++) {
for (size_t i = 0; i < files.size(); i++) {
const FileDescriptor* file = files[i];
succeeded = Generate(file, parameter, generator_context, error);
if (!succeeded && error && error->empty()) {
Expand Down Expand Up @@ -74,7 +78,7 @@ absl::StatusOr<FeatureSetDefaults> CodeGenerator::BuildFeatureSetDefaults()
GetMaximumEdition());
}

GeneratorContext::~GeneratorContext() {}
GeneratorContext::~GeneratorContext() = default;

io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend(
const std::string& filename) {
Expand Down
4 changes: 1 addition & 3 deletions src/google/protobuf/compiler/code_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/retention.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/port.h"

// Must be included last.
#include "google/protobuf/port_def.inc"
Expand Down Expand Up @@ -53,7 +51,7 @@ class GeneratorContext;
// be registered with CommandLineInterface to support various languages.
class PROTOC_EXPORT CodeGenerator {
public:
CodeGenerator() {}
CodeGenerator() = default;
CodeGenerator(const CodeGenerator&) = delete;
CodeGenerator& operator=(const CodeGenerator&) = delete;
virtual ~CodeGenerator();
Expand Down
Loading

0 comments on commit f5a2255

Please sign in to comment.