From a9f1ea6371c108876649f27a5940a59cc8594768 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Tue, 24 Jan 2023 21:49:33 -0800 Subject: [PATCH] Breaking change: Migrate to Abseil's logging library. This deletes our old branches of internal Abseil code in favor of their newly open-sourced library. Notably, this removes the ability to turn CHECK crashes into exceptions. PiperOrigin-RevId: 504460562 --- .github/workflows/codespell.yml | 2 +- .gitmodules | 2 +- CMakeLists.txt | 8 + build_defs/cpp_opts.bzl | 1 + cmake/abseil-cpp.cmake | 22 +- cmake/gtest.cmake | 48 ++++ cmake/tests.cmake | 38 +-- conformance/binary_json_conformance_suite.cc | 18 +- conformance/conformance_cpp.cc | 18 +- conformance/conformance_test.cc | 20 +- conformance/conformance_test_runner.cc | 22 +- conformance/text_format_conformance_suite.cc | 6 +- kokoro/common/setup_kokoro_environment.sh | 5 + kokoro/macos-next/cpp/build.sh | 4 + kokoro/windows/prepare_build_win64.bat | 7 + protobuf_deps.bzl | 4 +- python/google/protobuf/pyext/descriptor.cc | 4 +- .../protobuf/pyext/descriptor_database.cc | 12 +- python/google/protobuf/pyext/message.cc | 24 +- python/google/protobuf/pyext/safe_numerics.h | 4 +- regenerate_stale_files.sh | 2 + src/google/protobuf/BUILD.bazel | 17 ++ src/google/protobuf/any_test.cc | 4 +- src/google/protobuf/arena.cc | 40 +-- src/google/protobuf/arena.h | 2 +- src/google/protobuf/arena_align.h | 6 +- src/google/protobuf/arena_align_test.cc | 24 +- src/google/protobuf/arena_cleanup.h | 10 +- src/google/protobuf/arena_test_util.cc | 4 +- src/google/protobuf/arena_test_util.h | 8 +- src/google/protobuf/arena_unittest.cc | 66 ++--- src/google/protobuf/arenastring.cc | 8 +- src/google/protobuf/arenastring.h | 10 +- src/google/protobuf/arenastring_unittest.cc | 2 +- src/google/protobuf/arenaz_sampler_test.cc | 4 +- src/google/protobuf/compiler/BUILD.bazel | 7 + .../protobuf/compiler/annotation_test_util.cc | 6 +- .../protobuf/compiler/code_generator.cc | 6 +- .../compiler/command_line_interface.cc | 22 +- .../command_line_interface_unittest.cc | 36 +-- .../compiler/cpp/bootstrap_unittest.cc | 8 +- src/google/protobuf/compiler/cpp/field.cc | 10 +- src/google/protobuf/compiler/cpp/field.h | 6 +- .../cpp/field_generators/enum_field.cc | 4 +- .../cpp/field_generators/map_field.cc | 2 +- .../cpp/field_generators/message_field.cc | 2 +- .../cpp/field_generators/primitive_field.cc | 6 +- .../cpp/field_generators/string_field.cc | 12 +- src/google/protobuf/compiler/cpp/file.cc | 6 +- src/google/protobuf/compiler/cpp/file.h | 4 +- src/google/protobuf/compiler/cpp/generator.cc | 16 +- src/google/protobuf/compiler/cpp/helpers.cc | 30 +- src/google/protobuf/compiler/cpp/helpers.h | 6 +- src/google/protobuf/compiler/cpp/message.cc | 68 ++--- .../compiler/cpp/message_size_unittest.cc | 52 ++-- .../protobuf/compiler/cpp/metadata_test.cc | 8 +- .../compiler/cpp/padding_optimizer.cc | 4 +- .../compiler/cpp/parse_function_generator.cc | 32 +-- .../protobuf/compiler/cpp/plugin_unittest.cc | 4 +- src/google/protobuf/compiler/cpp/service.cc | 8 +- src/google/protobuf/compiler/cpp/tracker.cc | 2 +- src/google/protobuf/compiler/cpp/unittest.inc | 4 +- .../csharp/csharp_bootstrap_unittest.cc | 2 +- .../protobuf/compiler/csharp/csharp_enum.cc | 4 +- .../compiler/csharp/csharp_field_base.cc | 10 +- .../compiler/csharp/csharp_helpers.cc | 8 +- .../compiler/csharp/csharp_message.cc | 4 +- src/google/protobuf/compiler/importer.h | 2 +- .../protobuf/compiler/importer_unittest.cc | 10 +- src/google/protobuf/compiler/java/context.cc | 8 +- .../protobuf/compiler/java/enum_field.cc | 10 +- .../protobuf/compiler/java/enum_field_lite.cc | 6 +- src/google/protobuf/compiler/java/field.cc | 4 +- src/google/protobuf/compiler/java/field.h | 4 +- src/google/protobuf/compiler/java/file.cc | 14 +- src/google/protobuf/compiler/java/helpers.cc | 28 +- .../protobuf/compiler/java/map_field.cc | 8 +- .../protobuf/compiler/java/map_field_lite.cc | 8 +- src/google/protobuf/compiler/java/message.cc | 6 +- .../protobuf/compiler/java/message_builder.cc | 6 +- .../compiler/java/message_builder_lite.cc | 4 +- .../protobuf/compiler/java/message_field.cc | 2 +- .../protobuf/compiler/java/message_lite.cc | 4 +- .../java/message_serialization_unittest.cc | 6 +- .../protobuf/compiler/java/name_resolver.cc | 4 +- .../protobuf/compiler/java/plugin_unittest.cc | 6 +- .../protobuf/compiler/java/primitive_field.cc | 12 +- .../compiler/java/primitive_field_lite.cc | 6 +- src/google/protobuf/compiler/java/service.cc | 2 +- .../protobuf/compiler/java/string_field.cc | 6 +- .../compiler/java/string_field_lite.cc | 6 +- src/google/protobuf/compiler/main.cc | 2 + .../protobuf/compiler/mock_code_generator.cc | 48 ++-- .../protobuf/compiler/objectivec/extension.cc | 11 +- .../protobuf/compiler/objectivec/field.cc | 16 +- .../protobuf/compiler/objectivec/helpers.cc | 14 +- .../compiler/objectivec/import_writer.cc | 4 +- .../protobuf/compiler/objectivec/map_field.cc | 4 +- .../protobuf/compiler/objectivec/message.cc | 4 +- .../compiler/objectivec/primitive_field.cc | 6 +- .../objectivec/text_format_decode_data.cc | 35 +-- .../text_format_decode_data_unittest.cc | 52 ++-- src/google/protobuf/compiler/parser.cc | 18 +- .../protobuf/compiler/parser_unittest.cc | 6 +- .../protobuf/compiler/php/php_generator.cc | 6 +- src/google/protobuf/compiler/plugin.pb.cc | 20 +- src/google/protobuf/compiler/plugin.pb.h | 12 +- .../protobuf/compiler/python/generator.cc | 16 +- .../protobuf/compiler/python/helpers.cc | 2 +- .../compiler/python/plugin_unittest.cc | 8 +- .../protobuf/compiler/python/pyi_generator.cc | 8 +- .../protobuf/compiler/ruby/ruby_generator.cc | 10 +- .../compiler/ruby/ruby_generator_unittest.cc | 12 +- src/google/protobuf/compiler/scc.h | 8 +- src/google/protobuf/compiler/subprocess.cc | 44 +-- src/google/protobuf/descriptor.cc | 126 ++++----- src/google/protobuf/descriptor.h | 16 +- src/google/protobuf/descriptor.pb.cc | 128 ++++----- src/google/protobuf/descriptor.pb.h | 70 ++--- src/google/protobuf/descriptor_database.cc | 28 +- src/google/protobuf/descriptor_database.h | 2 +- src/google/protobuf/descriptor_unittest.cc | 66 ++--- src/google/protobuf/dynamic_message.cc | 4 +- src/google/protobuf/dynamic_message.h | 4 +- src/google/protobuf/extension_set.cc | 180 ++++++------ src/google/protobuf/extension_set.h | 12 +- src/google/protobuf/extension_set_heavy.cc | 28 +- src/google/protobuf/extension_set_inl.h | 2 +- src/google/protobuf/extension_set_unittest.cc | 4 +- .../protobuf/generated_message_bases.cc | 2 +- .../protobuf/generated_message_reflection.cc | 108 +++---- .../protobuf/generated_message_reflection.h | 18 +- .../generated_message_reflection_unittest.cc | 8 +- .../protobuf/generated_message_tctable_gen.cc | 20 +- .../protobuf/generated_message_tctable_impl.h | 4 +- .../generated_message_tctable_lite.cc | 28 +- .../generated_message_tctable_lite_test.cc | 4 +- src/google/protobuf/generated_message_util.cc | 8 +- src/google/protobuf/inlined_string_field.h | 2 +- .../protobuf/inlined_string_field_unittest.cc | 2 +- src/google/protobuf/io/BUILD.bazel | 9 + src/google/protobuf/io/coded_stream.cc | 46 +-- src/google/protobuf/io/coded_stream.h | 8 +- .../protobuf/io/coded_stream_unittest.cc | 40 ++- src/google/protobuf/io/gzip_stream.cc | 14 +- src/google/protobuf/io/printer.cc | 20 +- src/google/protobuf/io/printer.h | 8 +- src/google/protobuf/io/printer_death_test.cc | 30 +- src/google/protobuf/io/printer_unittest.cc | 6 +- src/google/protobuf/io/strtod.cc | 10 +- .../protobuf/io/test_zero_copy_stream.h | 14 +- .../protobuf/io/test_zero_copy_stream_test.cc | 24 +- src/google/protobuf/io/tokenizer.cc | 12 +- src/google/protobuf/io/tokenizer.h | 4 +- src/google/protobuf/io/tokenizer_unittest.cc | 8 +- src/google/protobuf/io/zero_copy_sink_test.cc | 4 +- src/google/protobuf/io/zero_copy_stream.cc | 4 +- src/google/protobuf/io/zero_copy_stream.h | 2 +- .../protobuf/io/zero_copy_stream_impl.cc | 22 +- .../protobuf/io/zero_copy_stream_impl_lite.cc | 44 +-- .../protobuf/io/zero_copy_stream_unittest.cc | 6 +- src/google/protobuf/json/BUILD.bazel | 7 +- .../json/internal/descriptor_traits.h | 6 +- src/google/protobuf/json/internal/lexer.cc | 4 +- src/google/protobuf/json/internal/parser.cc | 10 +- .../json/internal/test_input_stream.h | 8 +- src/google/protobuf/json/internal/unparser.cc | 10 +- .../protobuf/json/internal/untyped_message.cc | 8 +- .../protobuf/json/internal/untyped_message.h | 4 +- src/google/protobuf/json/internal/writer.cc | 4 +- .../internal/zero_copy_buffered_stream.cc | 10 +- .../json/internal/zero_copy_buffered_stream.h | 14 +- src/google/protobuf/lite_unittest.cc | 2 +- src/google/protobuf/map.h | 40 +-- src/google/protobuf/map_field.cc | 12 +- src/google/protobuf/map_field.h | 26 +- src/google/protobuf/map_field_inl.h | 4 +- src/google/protobuf/map_field_lite.h | 2 +- src/google/protobuf/map_field_test.cc | 2 +- src/google/protobuf/map_test.inc | 47 ++-- src/google/protobuf/message.cc | 28 +- src/google/protobuf/message.h | 12 +- src/google/protobuf/message_lite.cc | 44 +-- src/google/protobuf/message_lite.h | 10 +- src/google/protobuf/message_unittest.inc | 59 ++-- src/google/protobuf/no_field_presence_test.cc | 8 +- src/google/protobuf/parse_context.cc | 34 +-- src/google/protobuf/parse_context.h | 40 +-- src/google/protobuf/port_def.inc | 10 +- src/google/protobuf/proto3_arena_unittest.cc | 8 +- src/google/protobuf/reflection_internal.h | 6 +- src/google/protobuf/reflection_ops.cc | 16 +- .../protobuf/reflection_ops_unittest.cc | 4 +- src/google/protobuf/reflection_tester.cc | 4 +- src/google/protobuf/repeated_field.cc | 4 +- src/google/protobuf/repeated_field.h | 54 ++-- .../repeated_field_reflection_unittest.cc | 12 +- .../protobuf/repeated_field_unittest.cc | 16 +- src/google/protobuf/repeated_ptr_field.cc | 8 +- src/google/protobuf/repeated_ptr_field.h | 84 +++--- src/google/protobuf/serial_arena.h | 20 +- src/google/protobuf/string_member_robber.h | 2 +- src/google/protobuf/stubs/BUILD.bazel | 5 +- src/google/protobuf/stubs/common.cc | 215 ++------------ src/google/protobuf/stubs/common.h | 34 --- src/google/protobuf/stubs/common_unittest.cc | 84 +----- src/google/protobuf/stubs/logging.h | 266 ------------------ src/google/protobuf/test_util.h | 2 +- src/google/protobuf/test_util.inc | 4 +- src/google/protobuf/test_util2.h | 4 +- src/google/protobuf/testing/BUILD.bazel | 5 + src/google/protobuf/testing/file.cc | 70 +++-- src/google/protobuf/testing/file.h | 28 +- src/google/protobuf/testing/googletest.cc | 49 +--- src/google/protobuf/testing/googletest.h | 46 +-- src/google/protobuf/text_format.cc | 42 +-- src/google/protobuf/text_format_unittest.cc | 45 ++- src/google/protobuf/unknown_field_set.cc | 6 +- src/google/protobuf/unknown_field_set.h | 4 +- src/google/protobuf/util/BUILD.bazel | 5 + src/google/protobuf/util/field_comparator.cc | 10 +- src/google/protobuf/util/field_mask_util.cc | 21 +- src/google/protobuf/util/field_mask_util.h | 6 +- .../protobuf/util/message_differencer.cc | 68 ++--- .../protobuf/util/message_differencer.h | 4 +- .../util/message_differencer_unittest.cc | 2 +- src/google/protobuf/util/time_util.cc | 26 +- src/google/protobuf/util/time_util_test.cc | 4 +- .../protobuf/util/type_resolver_util.cc | 4 +- src/google/protobuf/wire_format.cc | 30 +- src/google/protobuf/wire_format.h | 2 +- src/google/protobuf/wire_format_lite.cc | 14 +- src/google/protobuf/wire_format_lite.h | 8 +- src/google/protobuf/wire_format_unittest.inc | 94 +++---- 234 files changed, 1993 insertions(+), 2539 deletions(-) create mode 100644 cmake/gtest.cmake delete mode 100644 src/google/protobuf/stubs/logging.h diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index cc4210c6707c..3d258fc0eb74 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -15,4 +15,4 @@ jobs: with: check_filenames: true skip: ./.git,./third_party,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml - ignore_words_list: "alow,alse,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,falsy,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',ro,te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy" + ignore_words_list: "alow,alse,atleast,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,falsy,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',ro,te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy" diff --git a/.gitmodules b/.gitmodules index c4e7dcca7c3a..32628905b7c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,7 @@ [submodule "third_party/abseil-cpp"] path = third_party/abseil-cpp url = https://github.com/abseil/abseil-cpp.git - branch = lts_2023_01_17 + branch = lts_2023_01_24 [submodule "third_party/jsoncpp"] path = third_party/jsoncpp url = https://github.com/open-source-parsers/jsoncpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ab6a763b241a..ca4144bee9de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,9 @@ else (protobuf_BUILD_SHARED_LIBS) endif() endif (protobuf_BUILD_SHARED_LIBS) +# Export all symbols on Windows when building shared libraries +SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + if (MSVC) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Build with multiple processes @@ -268,6 +271,7 @@ if (MSVC) # MSVC warning suppressions add_compile_options( /wd4065 # switch statement contains 'default' but no 'case' labels + /wd4146 # unary minus operator applied to unsigned type /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data /wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' /wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data @@ -319,6 +323,10 @@ endif (protobuf_UNICODE) set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library") set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package") +if (protobuf_BUILD_TESTS) + include(${protobuf_SOURCE_DIR}/cmake/gtest.cmake) +endif (protobuf_BUILD_TESTS) + include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake) if (protobuf_BUILD_PROTOBUF_BINARIES) diff --git a/build_defs/cpp_opts.bzl b/build_defs/cpp_opts.bzl index 14cdd4de649f..33e157875bd1 100644 --- a/build_defs/cpp_opts.bzl +++ b/build_defs/cpp_opts.bzl @@ -3,6 +3,7 @@ COPTS = select({ "//build_defs:config_msvc": [ "/wd4065", # switch statement contains 'default' but no 'case' labels + "/wd4146", # unary minus operator applied to unsigned type "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake index cb7d13b0ce47..e7bfb2b15f8f 100644 --- a/cmake/abseil-cpp.cmake +++ b/cmake/abseil-cpp.cmake @@ -1,5 +1,15 @@ # Setup our dependency on Abseil. +if(protobuf_BUILD_TESTS) + # Tell Abseil to build test-only helpers. + set(ABSL_BUILD_TEST_HELPERS ON) + + # We depend on googletest too, so just tell Abseil to use the same one we've + # already setup. + set(ABSL_USE_EXTERNAL_GOOGLETEST ON) + set(ABSL_FIND_GOOGLETEST OFF) +endif() + if(TARGET absl::strings) # If Abseil is included already, skip including it. # (https://github.com/protocolbuffers/protobuf/issues/10435) @@ -31,11 +41,11 @@ if (BUILD_SHARED_LIBS AND MSVC) # On MSVC Abseil is bundled into a single DLL. set(protobuf_ABSL_USED_TARGETS abseil_dll) - # As a workaround for https://github.com/abseil/abseil-cpp/issues/1118, - # make sure ABSL_CONSUME_DLL gets set for all subsequent builds. - add_definitions(-DABSL_CONSUME_DLL) + set(protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll) else() set(protobuf_ABSL_USED_TARGETS + absl::absl_check + absl::absl_log absl::algorithm absl::base absl::bind_front @@ -45,6 +55,7 @@ else() absl::cord absl::core_headers absl::debugging + absl::die_if_null absl::dynamic_annotations absl::flags absl::flat_hash_map @@ -52,6 +63,8 @@ else() absl::function_ref absl::hash absl::layout + absl::log_initialize + absl::log_severity absl::memory absl::node_hash_map absl::node_hash_set @@ -66,4 +79,7 @@ else() absl::utility absl::variant ) + set(protobuf_ABSL_USED_TEST_TARGETS + absl::scoped_mock_log + ) endif () diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake new file mode 100644 index 000000000000..7e246fb7b967 --- /dev/null +++ b/cmake/gtest.cmake @@ -0,0 +1,48 @@ +option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF) + +if (protobuf_USE_EXTERNAL_GTEST) + find_package(GTest REQUIRED) +else() + if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt") + message(FATAL_ERROR + "Cannot find third_party/googletest directory that's needed to " + "build tests. If you use git, make sure you have cloned submodules:\n" + " git submodule update --init --recursive\n" + "If instead you want to skip tests, run cmake with:\n" + " cmake -Dprotobuf_BUILD_TESTS=OFF\n") + endif() + + set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock") + set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest") + include_directories( + ${googlemock_source_dir} + ${googletest_source_dir} + ${googletest_source_dir}/include + ${googlemock_source_dir}/include + ) + + add_library(gmock ${protobuf_SHARED_OR_STATIC} + "${googlemock_source_dir}/src/gmock-all.cc" + "${googletest_source_dir}/src/gtest-all.cc" + ) + if (protobuf_BUILD_SHARED_LIBS) + set_target_properties(gmock + PROPERTIES + COMPILE_DEFINITIONS + "GTEST_CREATE_SHARED_LIBRARY=1" + ) + install(TARGETS gmock EXPORT protobuf-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + + target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT}) + add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc") + target_link_libraries(gmock_main gmock) + + add_library(GTest::gmock ALIAS gmock) + add_library(GTest::gmock_main ALIAS gmock_main) + add_library(GTest::gtest ALIAS gmock) + add_library(GTest::gtest_main ALIAS gmock_main) +endif() diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 9038c6db997b..27f2eaca7297 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -1,5 +1,3 @@ -option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF) - option(protobuf_REMOVE_INSTALLED_HEADERS "Remove local headers so that installed ones are used instead" OFF) @@ -7,39 +5,6 @@ option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH "Using absolute test_plugin path in tests" ON) mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) -if (protobuf_USE_EXTERNAL_GTEST) - find_package(GTest REQUIRED) -else() - if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt") - message(FATAL_ERROR - "Cannot find third_party/googletest directory that's needed to " - "build tests. If you use git, make sure you have cloned submodules:\n" - " git submodule update --init --recursive\n" - "If instead you want to skip tests, run cmake with:\n" - " cmake -Dprotobuf_BUILD_TESTS=OFF\n") - endif() - - set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock") - set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest") - include_directories( - ${googlemock_source_dir} - ${googletest_source_dir} - ${googletest_source_dir}/include - ${googlemock_source_dir}/include - ) - - add_library(gmock STATIC - "${googlemock_source_dir}/src/gmock-all.cc" - "${googletest_source_dir}/src/gtest-all.cc" - ) - target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT}) - add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc") - target_link_libraries(gmock_main gmock) - - add_library(GTest::gmock ALIAS gmock) - add_library(GTest::gmock_main ALIAS gmock_main) -endif() - include(${protobuf_SOURCE_DIR}/src/file_lists.cmake) set(lite_test_protos @@ -133,6 +98,7 @@ target_link_libraries(tests ${protobuf_LIB_PROTOC} ${protobuf_LIB_PROTOBUF} ${protobuf_ABSL_USED_TARGETS} + ${protobuf_ABSL_USED_TEST_TARGETS} GTest::gmock_main ) @@ -148,6 +114,7 @@ target_link_libraries(test_plugin ${protobuf_LIB_PROTOC} ${protobuf_LIB_PROTOBUF} ${protobuf_ABSL_USED_TARGETS} + ${protobuf_ABSL_USED_TEST_TARGETS} GTest::gmock ) @@ -159,6 +126,7 @@ add_executable(lite-test target_link_libraries(lite-test ${protobuf_LIB_PROTOBUF_LITE} ${protobuf_ABSL_USED_TARGETS} + ${protobuf_ABSL_USED_TEST_TARGETS} GTest::gmock_main ) diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index c4fb3d057b72..90991f1904c7 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -38,8 +38,8 @@ #include "google/protobuf/text_format.h" #include "google/protobuf/util/json_util.h" #include "google/protobuf/util/type_resolver_util.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "json/json.h" @@ -241,7 +241,7 @@ const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type, if (packed == Packed::kFalse) { packed_string = "Unpacked "; } - GOOGLE_ABSL_LOG(FATAL) << "Couldn't find field with type: " << repeated_string + ABSL_LOG(FATAL) << "Couldn't find field with type: " << repeated_string << packed_string << FieldDescriptor::TypeName(type) << " for " << proto_string; return nullptr; @@ -265,7 +265,7 @@ const FieldDescriptor* GetFieldForMapType(FieldDescriptor::Type key_type, } const absl::string_view proto_string = is_proto3 ? "Proto3" : "Proto2"; - GOOGLE_ABSL_LOG(FATAL) << "Couldn't find map field with type: " + ABSL_LOG(FATAL) << "Couldn't find map field with type: " << FieldDescriptor::TypeName(key_type) << " and " << FieldDescriptor::TypeName(key_type) << " for " << proto_string; @@ -285,7 +285,7 @@ const FieldDescriptor* GetFieldForOneofType(FieldDescriptor::Type type, } const absl::string_view proto_string = is_proto3 ? "Proto3" : "Proto2"; - GOOGLE_ABSL_LOG(FATAL) << "Couldn't find oneof field with type: " + ABSL_LOG(FATAL) << "Couldn't find oneof field with type: " << FieldDescriptor::TypeName(type) << " for " << proto_string; return nullptr; } @@ -353,7 +353,7 @@ bool BinaryAndJsonConformanceSuite::ParseJsonResponse( } if (!test_message->ParseFromString(binary_protobuf)) { - GOOGLE_ABSL_LOG(FATAL) << "INTERNAL ERROR: internal JSON->protobuf transcode " + ABSL_LOG(FATAL) << "INTERNAL ERROR: internal JSON->protobuf transcode " << "yielded unparseable proto."; return false; } @@ -407,7 +407,7 @@ bool BinaryAndJsonConformanceSuite::ParseResponse( } default: - GOOGLE_ABSL_LOG(FATAL) << test_name + ABSL_LOG(FATAL) << test_name << ": unknown payload type: " << response.result_case(); } @@ -652,7 +652,7 @@ void BinaryAndJsonConformanceSuite::ExpectSerializeFailureForJson( const string& test_name, ConformanceLevel level, const string& text_format) { TestAllTypesProto3 payload_message; - GOOGLE_ABSL_CHECK(TextFormat::ParseFromString(text_format, &payload_message)) + ABSL_CHECK(TextFormat::ParseFromString(text_format, &payload_message)) << "Failed to parse: " << text_format; TestAllTypesProto3 prototype; @@ -1414,7 +1414,7 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() { req.set_protobuf_payload(""); req.set_requested_output_format(conformance::WireFormat::PROTOBUF); RunTest("FindFailures", req, &res); - GOOGLE_ABSL_CHECK(failure_set.MergeFromString(res.protobuf_payload())); + ABSL_CHECK(failure_set.MergeFromString(res.protobuf_payload())); for (const string& failure : failure_set.failure()) { AddExpectedFailedTest(failure); } diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc index 519a09ba26a1..2fc9424ec8fe 100644 --- a/conformance/conformance_cpp.cc +++ b/conformance/conformance_cpp.cc @@ -40,8 +40,8 @@ #include "google/protobuf/text_format.h" #include "google/protobuf/util/json_util.h" #include "google/protobuf/util/type_resolver_util.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "conformance/conformance.pb.h" @@ -187,14 +187,14 @@ absl::StatusOr Harness::RunTest( return absl::InvalidArgumentError("unspecified output format"); case conformance::PROTOBUF: { - GOOGLE_ABSL_CHECK( + ABSL_CHECK( test_message->SerializeToString(response.mutable_protobuf_payload())); break; } case conformance::JSON: { std::string proto_binary; - GOOGLE_ABSL_CHECK(test_message->SerializeToString(&proto_binary)); + ABSL_CHECK(test_message->SerializeToString(&proto_binary)); absl::Status status = BinaryToJsonString(resolver_.get(), type_url_, proto_binary, response.mutable_json_payload()); @@ -208,7 +208,7 @@ absl::StatusOr Harness::RunTest( case conformance::TEXT_FORMAT: { TextFormat::Printer printer; printer.SetHideUnknownFields(!request.print_unknown_fields()); - GOOGLE_ABSL_CHECK(printer.PrintToString(*test_message, + ABSL_CHECK(printer.PrintToString(*test_message, response.mutable_text_payload())); break; } @@ -234,7 +234,7 @@ absl::StatusOr Harness::ServeConformanceRequest() { RETURN_IF_ERROR(ReadFd(STDIN_FILENO, &serialized_input[0], in_len)); ConformanceRequest request; - GOOGLE_ABSL_CHECK(request.ParseFromString(serialized_input)); + ABSL_CHECK(request.ParseFromString(serialized_input)); absl::StatusOr response = RunTest(request); RETURN_IF_ERROR(response.status()); @@ -247,7 +247,7 @@ absl::StatusOr Harness::ServeConformanceRequest() { RETURN_IF_ERROR(WriteFd(STDOUT_FILENO, serialized_output.data(), out_len)); if (verbose_) { - GOOGLE_ABSL_LOG(INFO) << "conformance-cpp: request=" << request.ShortDebugString() + ABSL_LOG(INFO) << "conformance-cpp: request=" << request.ShortDebugString() << ", response=" << response->ShortDebugString(); } return false; @@ -262,13 +262,13 @@ int main() { while (true) { auto is_done = harness.ServeConformanceRequest(); if (!is_done.ok()) { - GOOGLE_ABSL_LOG(FATAL) << is_done.status(); + ABSL_LOG(FATAL) << is_done.status(); } if (*is_done) { break; } total_runs++; } - GOOGLE_ABSL_LOG(INFO) << "conformance-cpp: received EOF from test runner after " + ABSL_LOG(INFO) << "conformance-cpp: received EOF from test runner after " << total_runs << " tests"; } diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 95c6a96f64fa..e5d2907ab252 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -40,7 +40,7 @@ #include "google/protobuf/util/field_comparator.h" #include "google/protobuf/util/json_util.h" #include "google/protobuf/util/message_differencer.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" @@ -147,7 +147,7 @@ ConformanceTestSuite::ConformanceRequestSetting::ConformanceRequestSetting( } default: - GOOGLE_ABSL_LOG(FATAL) << "Unspecified input format"; + ABSL_LOG(FATAL) << "Unspecified input format"; } request_.set_test_category(test_category); @@ -181,7 +181,7 @@ ConformanceTestSuite::ConformanceRequestSetting::ConformanceLevelToString( case RECOMMENDED: return "Recommended"; } - GOOGLE_ABSL_LOG(FATAL) << "Unknown value: " << level; + ABSL_LOG(FATAL) << "Unknown value: " << level; return ""; } @@ -195,7 +195,7 @@ string ConformanceTestSuite::ConformanceRequestSetting::InputFormatString( case conformance::TEXT_FORMAT: return "TextFormatInput"; default: - GOOGLE_ABSL_LOG(FATAL) << "Unspecified output format"; + ABSL_LOG(FATAL) << "Unspecified output format"; } return ""; } @@ -210,7 +210,7 @@ string ConformanceTestSuite::ConformanceRequestSetting::OutputFormatString( case conformance::TEXT_FORMAT: return "TextFormatOutput"; default: - GOOGLE_ABSL_LOG(FATAL) << "Unspecified output format"; + ABSL_LOG(FATAL) << "Unspecified output format"; } return ""; } @@ -315,7 +315,7 @@ void ConformanceTestSuite::RunValidInputTest( const ConformanceRequestSetting& setting, const string& equivalent_text_format) { std::unique_ptr reference_message(setting.NewTestMessage()); - GOOGLE_ABSL_CHECK(TextFormat::ParseFromString(equivalent_text_format, + ABSL_CHECK(TextFormat::ParseFromString(equivalent_text_format, reference_message.get())) << "Failed to parse data for test case: " << setting.GetTestName() << ", data: " << equivalent_text_format; @@ -343,7 +343,7 @@ void ConformanceTestSuite::VerifyResponse( ConformanceLevel level = setting.GetLevel(); std::unique_ptr reference_message = setting.NewTestMessage(); - GOOGLE_ABSL_CHECK(reference_message->ParseFromString(equivalent_wire_format)) + ABSL_CHECK(reference_message->ParseFromString(equivalent_wire_format)) << "Failed to parse wire data for test case: " << test_name; switch (response.result_case()) { @@ -378,7 +378,7 @@ void ConformanceTestSuite::VerifyResponse( bool check = false; if (require_same_wire_format) { - GOOGLE_ABSL_DCHECK_EQ(response.result_case(), + ABSL_DCHECK_EQ(response.result_case(), ConformanceResponse::kProtobufPayload); const string& protobuf_payload = response.protobuf_payload(); check = equivalent_wire_format == protobuf_payload; @@ -404,7 +404,7 @@ void ConformanceTestSuite::RunTest(const string& test_name, const ConformanceRequest& request, ConformanceResponse* response) { if (test_names_.insert(test_name).second == false) { - GOOGLE_ABSL_LOG(FATAL) << "Duplicated test name: " << test_name; + ABSL_LOG(FATAL) << "Duplicated test name: " << test_name; } string serialized_request; @@ -439,7 +439,7 @@ string ConformanceTestSuite::WireFormatToString(WireFormat wire_format) { case conformance::UNSPECIFIED: return "UNSPECIFIED"; default: - GOOGLE_ABSL_LOG(FATAL) << "unknown wire type: " << wire_format; + ABSL_LOG(FATAL) << "unknown wire type: " << wire_format; } return ""; } diff --git a/conformance/conformance_test_runner.cc b/conformance/conformance_test_runner.cc index cb308f74d609..19497a1e1d05 100644 --- a/conformance/conformance_test_runner.cc +++ b/conformance/conformance_test_runner.cc @@ -65,7 +65,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "conformance/conformance.pb.h" #include "conformance_test.h" @@ -161,7 +161,7 @@ void ForkPipeRunner::RunTest(const std::string &test_name, if (!TryRead(read_fd_, &len, sizeof(uint32_t))) { // We failed to read from the child, assume a crash and try to reap. - GOOGLE_ABSL_LOG(INFO) << "Trying to reap child, pid=" << child_pid_; + ABSL_LOG(INFO) << "Trying to reap child, pid=" << child_pid_; int status = 0; waitpid(child_pid_, &status, WEXITED); @@ -183,7 +183,7 @@ void ForkPipeRunner::RunTest(const std::string &test_name, absl::StrAppendFormat(&error_msg, "child killed by signal %d", WTERMSIG(status)); } - GOOGLE_ABSL_LOG(INFO) << error_msg; + ABSL_LOG(INFO) << error_msg; child_pid_ = -1; response_obj.SerializeToString(response); @@ -312,10 +312,10 @@ void ForkPipeRunner::SpawnTestProgram() { std::vector argv; argv.push_back(executable.get()); - GOOGLE_ABSL_LOG(INFO) << argv[0]; + ABSL_LOG(INFO) << argv[0]; for (size_t i = 0; i < executable_args_.size(); ++i) { argv.push_back(executable_args_[i].c_str()); - GOOGLE_ABSL_LOG(INFO) << executable_args_[i]; + ABSL_LOG(INFO) << executable_args_[i]; } argv.push_back(nullptr); // Never returns. @@ -325,7 +325,7 @@ void ForkPipeRunner::SpawnTestProgram() { void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) { if (static_cast(write(fd, buf, len)) != len) { - GOOGLE_ABSL_LOG(FATAL) << current_test_name_ + ABSL_LOG(FATAL) << current_test_name_ << ": error writing to test program: " << strerror(errno); } } @@ -343,7 +343,7 @@ bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) { if (performance_) { status = future.wait_for(std::chrono::seconds(5)); if (status == std::future_status::timeout) { - GOOGLE_ABSL_LOG(ERROR) << current_test_name_ << ": timeout from test program"; + ABSL_LOG(ERROR) << current_test_name_ << ": timeout from test program"; kill(child_pid_, SIGQUIT); // TODO(sandyzhang): Only log in flag-guarded mode, since reading output // from SIGQUIT is slow and verbose. @@ -356,7 +356,7 @@ bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) { read(fd, (void *)&err[err_ofs], err.size() - err_ofs); err_ofs += err_bytes_read; } while (err_bytes_read > 0 && err_ofs < err.size()); - GOOGLE_ABSL_LOG(ERROR) << "child_pid_=" << child_pid_ << " SIGQUIT: \n" + ABSL_LOG(ERROR) << "child_pid_=" << child_pid_ << " SIGQUIT: \n" << &err[0]; return false; } @@ -365,11 +365,11 @@ bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) { } ssize_t bytes_read = future.get(); if (bytes_read == 0) { - GOOGLE_ABSL_LOG(ERROR) << current_test_name_ + ABSL_LOG(ERROR) << current_test_name_ << ": unexpected EOF from test program"; return false; } else if (bytes_read < 0) { - GOOGLE_ABSL_LOG(ERROR) << current_test_name_ + ABSL_LOG(ERROR) << current_test_name_ << ": error reading from test program: " << strerror(errno); return false; @@ -384,7 +384,7 @@ bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) { void ForkPipeRunner::CheckedRead(int fd, void *buf, size_t len) { if (!TryRead(fd, buf, len)) { - GOOGLE_ABSL_LOG(FATAL) << current_test_name_ + ABSL_LOG(FATAL) << current_test_name_ << ": error reading from test program: " << strerror(errno); } } diff --git a/conformance/text_format_conformance_suite.cc b/conformance/text_format_conformance_suite.cc index c3ba248fb111..10a8b1ede4de 100644 --- a/conformance/text_format_conformance_suite.cc +++ b/conformance/text_format_conformance_suite.cc @@ -32,7 +32,7 @@ #include "google/protobuf/any.pb.h" #include "google/protobuf/text_format.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "conformance_test.h" #include "google/protobuf/test_messages_proto2.pb.h" @@ -70,7 +70,7 @@ bool TextFormatConformanceTestSuite::ParseTextFormatResponse( parser.AllowFieldNumber(true); } if (!parser.ParseFromString(response.text_payload(), test_message)) { - GOOGLE_ABSL_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode " + ABSL_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode " << "yielded unparseable proto. Text payload: " << response.text_payload(); return false; @@ -127,7 +127,7 @@ bool TextFormatConformanceTestSuite::ParseResponse( } default: - GOOGLE_ABSL_LOG(FATAL) << test_name + ABSL_LOG(FATAL) << test_name << ": unknown payload type: " << response.result_case(); } diff --git a/kokoro/common/setup_kokoro_environment.sh b/kokoro/common/setup_kokoro_environment.sh index 65c10b66e507..2696e7062b67 100755 --- a/kokoro/common/setup_kokoro_environment.sh +++ b/kokoro/common/setup_kokoro_environment.sh @@ -9,3 +9,8 @@ sudo apt-get -y update && \ gcc-7 g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 --slave /usr/bin/g++ g++ /usr/bin/g++-7 sudo update-alternatives --set gcc /usr/bin/gcc-7 + +# TODO(b/265232445) Remove this once the patch is upstreamed +git submodule update --init --recursive +sed -i 's:random/mock_helpers.h:random/internal/mock_helpers.h:' third_party/abseil-cpp/CMake/AbseilDll.cmake +sed -i 's:ABSL_INTERNA_TEST_DLL_TARGETS:ABSL_INTERNAL_TEST_DLL_TARGETS:' third_party/abseil-cpp/CMake/AbseilDll.cmake diff --git a/kokoro/macos-next/cpp/build.sh b/kokoro/macos-next/cpp/build.sh index 1e2ae40d0d55..cb4dbc300a4a 100755 --- a/kokoro/macos-next/cpp/build.sh +++ b/kokoro/macos-next/cpp/build.sh @@ -24,6 +24,10 @@ cd $(dirname $0)/../../.. git submodule update --init --recursive ./regenerate_stale_files.sh +# TODO(b/265232445) Remove this once the patch is upstreamed +sed -i '' 's:random/mock_helpers.h:random/internal/mock_helpers.h:' third_party/abseil-cpp/CMake/AbseilDll.cmake +sed -i '' 's:ABSL_INTERNA_TEST_DLL_TARGETS:ABSL_INTERNAL_TEST_DLL_TARGETS:' third_party/abseil-cpp/CMake/AbseilDll.cmake + # # Run build # diff --git a/kokoro/windows/prepare_build_win64.bat b/kokoro/windows/prepare_build_win64.bat index bb1c96d0214b..24b5869f0986 100644 --- a/kokoro/windows/prepare_build_win64.bat +++ b/kokoro/windows/prepare_build_win64.bat @@ -9,6 +9,10 @@ Powershell.exe -Command "New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\C @rem Update git submodules. git submodule update --init --recursive +@rem TODO(b/265232445) Remove this once the patch is upstreamed +sed -i 's:random/mock_helpers.h:random/internal/mock_helpers.h:' third_party\abseil-cpp\CMake\AbseilDll.cmake +sed -i 's:ABSL_INTERNA_TEST_DLL_TARGETS:ABSL_INTERNAL_TEST_DLL_TARGETS:' third_party\abseil-cpp\CMake\AbseilDll.cmake + @rem Select Visual Studio 2017. call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 @@ -44,4 +48,7 @@ set BAZEL_FLAGS=--enable_runfiles --keep_going --test_output=errors ^ --remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/%KOKORO_JOB_NAME% @rem Regenerate stale CMake configs. +@rem LINT.IfChange(staleness_tests) bazel test //src:cmake_lists_staleness_test || call bazel-bin\src\cmake_lists_staleness_test.exe --fix +bazel test //src/google/protobuf:well_known_types_staleness_test || call bazel-bin\src\google\protobuf\well_known_types_staleness_test.exe --fix +@rem LINT.ThenChange(//depot/google3/third_party/protobuf/github/regenerate_stale_files.sh) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index b446eaeaf826..63ddc1b9004f 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -41,8 +41,8 @@ def protobuf_deps(): _github_archive( name = "com_google_absl", repo = "https://github.com/abseil/abseil-cpp", - commit = "10b627fbe944110d1672bdf3f8e23b5909721399", - sha256 = "138ec814b4b72a79a41b2ae6526150467ff7749d8a792a63742207a5d8578ed1", + commit = "f016820c2496845293659e181643aa1509487e03", + sha256 = "f4ad187e815deb34f70218173799659867087fa8925b9741934c0462b88d2f93", ) if not native.existing_rule("zlib"): diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index aa364744b818..de9a248073eb 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -32,7 +32,7 @@ #include "google/protobuf/pyext/descriptor.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #define PY_SSIZE_T_CLEAN #include @@ -406,7 +406,7 @@ PyObject* NewInternedDescriptor(PyTypeObject* type, std::unordered_map::iterator it = interned_descriptors->find(descriptor); if (it != interned_descriptors->end()) { - GOOGLE_ABSL_DCHECK(Py_TYPE(it->second) == type); + ABSL_DCHECK(Py_TYPE(it->second) == type); Py_INCREF(it->second); return it->second; } diff --git a/python/google/protobuf/pyext/descriptor_database.cc b/python/google/protobuf/pyext/descriptor_database.cc index f25443842ee5..eb5833865f91 100644 --- a/python/google/protobuf/pyext/descriptor_database.cc +++ b/python/google/protobuf/pyext/descriptor_database.cc @@ -38,7 +38,7 @@ #include #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "google/protobuf/pyext/message.h" #include "google/protobuf/pyext/scoped_pyobject_ptr.h" @@ -62,7 +62,7 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor, // Expected error: item was simply not found. PyErr_Clear(); } else { - GOOGLE_ABSL_LOG(ERROR) << "DescriptorDatabase method raised an error"; + ABSL_LOG(ERROR) << "DescriptorDatabase method raised an error"; PyErr_Print(); } return false; @@ -86,7 +86,7 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor, ScopedPyObjectPtr serialized_pb( PyObject_CallMethod(py_descriptor, "SerializeToString", nullptr)); if (serialized_pb == nullptr) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "DescriptorDatabase method did not return a FileDescriptorProto"; PyErr_Print(); return false; @@ -94,14 +94,14 @@ static bool GetFileDescriptorProto(PyObject* py_descriptor, char* str; Py_ssize_t len; if (PyBytes_AsStringAndSize(serialized_pb.get(), &str, &len) < 0) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "DescriptorDatabase method did not return a FileDescriptorProto"; PyErr_Print(); return false; } FileDescriptorProto file_proto; if (!file_proto.ParseFromArray(str, len)) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "DescriptorDatabase method did not return a FileDescriptorProto"; return false; } @@ -172,7 +172,7 @@ bool PyDescriptorDatabase::FindAllExtensionNumbers( ScopedPyObjectPtr item(PySequence_GetItem(py_list.get(), i)); item_value = PyLong_AsLong(item.get()); if (item_value < 0) { - GOOGLE_ABSL_LOG(ERROR) << "FindAllExtensionNumbers method did not return " + ABSL_LOG(ERROR) << "FindAllExtensionNumbers method did not return " << "valid extension numbers."; PyErr_Print(); return false; diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index ab9e9433ae84..3ff31e2670f9 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -42,7 +42,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/match.h" #ifndef PyVarObject_HEAD_INIT @@ -252,10 +252,10 @@ static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) { if (WKT_classes == nullptr) { ScopedPyObjectPtr well_known_types( PyImport_ImportModule(PROTOBUF_PYTHON_INTERNAL ".well_known_types")); - GOOGLE_ABSL_DCHECK(well_known_types != nullptr); + ABSL_DCHECK(well_known_types != nullptr); WKT_classes = PyObject_GetAttrString(well_known_types.get(), "WKTBASES"); - GOOGLE_ABSL_DCHECK(WKT_classes != nullptr); + ABSL_DCHECK(WKT_classes != nullptr); } PyObject* well_known_class = PyDict_GetItemString( @@ -680,7 +680,7 @@ bool IsValidUTF8(PyObject* obj) { bool AllowInvalidUTF8(const FieldDescriptor* field) { return false; } PyObject* CheckString(PyObject* arg, const FieldDescriptor* descriptor) { - GOOGLE_ABSL_DCHECK(descriptor->type() == FieldDescriptor::TYPE_STRING || + ABSL_DCHECK(descriptor->type() == FieldDescriptor::TYPE_STRING || descriptor->type() == FieldDescriptor::TYPE_BYTES); if (descriptor->type() == FieldDescriptor::TYPE_STRING) { if (!PyBytes_Check(arg) && !PyUnicode_Check(arg)) { @@ -784,7 +784,7 @@ bool CheckFieldBelongsToMessage(const FieldDescriptor* field_descriptor, namespace cmessage { PyMessageFactory* GetFactoryForMessage(CMessage* message) { - GOOGLE_ABSL_DCHECK(PyObject_TypeCheck(message, CMessage_Type)); + ABSL_DCHECK(PyObject_TypeCheck(message, CMessage_Type)); return reinterpret_cast(Py_TYPE(message))->py_message_factory; } @@ -856,7 +856,7 @@ int AssureWritable(CMessage* self) { } // Toplevel messages are always mutable. - GOOGLE_ABSL_DCHECK(self->parent); + ABSL_DCHECK(self->parent); if (AssureWritable(self->parent) == -1) { return -1; @@ -988,7 +988,7 @@ int DeleteRepeatedField( } Arena* arena = Arena::InternalGetArenaForAllocation(message); - GOOGLE_ABSL_DCHECK_EQ(arena, nullptr) + ABSL_DCHECK_EQ(arena, nullptr) << "python protobuf is expected to be allocated from heap"; // Remove items, starting from the end. for (; length > to; length--) { @@ -1001,10 +1001,10 @@ int DeleteRepeatedField( // // To work around a debug hardening (PROTOBUF_FORCE_COPY_IN_RELEASE), // explicitly use UnsafeArenaReleaseLast. To not break rare use cases where - // arena is used, we fallback to ReleaseLast (but GOOGLE_ABSL_DCHECK to find/fix + // arena is used, we fallback to ReleaseLast (but ABSL_DCHECK to find/fix // it). // - // Note that arena is likely null and GOOGLE_ABSL_DCHECK and ReleaesLast might be + // Note that arena is likely null and ABSL_DCHECK and ReleaesLast might be // redundant. The current approach takes extra cautious path not to disrupt // production. Message* sub_message = @@ -1269,8 +1269,8 @@ static void Dealloc(CMessage* self) { PyObject_ClearWeakRefs(reinterpret_cast(self)); } // At this point all dependent objects have been removed. - GOOGLE_ABSL_DCHECK(!self->child_submessages || self->child_submessages->empty()); - GOOGLE_ABSL_DCHECK(!self->composite_fields || self->composite_fields->empty()); + ABSL_DCHECK(!self->child_submessages || self->child_submessages->empty()); + ABSL_DCHECK(!self->composite_fields || self->composite_fields->empty()); delete self->child_submessages; delete self->composite_fields; if (self->unknown_field_set) { @@ -1715,7 +1715,7 @@ static PyObject* InternalSerializeToString( coded_out.SetSerializationDeterministic(deterministic); } self->message->SerializeWithCachedSizes(&coded_out); - GOOGLE_ABSL_CHECK(!coded_out.HadError()); + ABSL_CHECK(!coded_out.HadError()); return result; } diff --git a/python/google/protobuf/pyext/safe_numerics.h b/python/google/protobuf/pyext/safe_numerics.h index 418473bf28cd..aae8bc829a10 100644 --- a/python/google/protobuf/pyext/safe_numerics.h +++ b/python/google/protobuf/pyext/safe_numerics.h @@ -34,7 +34,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" namespace google { namespace protobuf { @@ -152,7 +152,7 @@ inline bool IsValidNumericCast(Source source) { // (this is static_asserted), though this could be supported if necessary. template inline Dest checked_numeric_cast(Source source) { - GOOGLE_ABSL_CHECK(IsValidNumericCast(source)); + ABSL_CHECK(IsValidNumericCast(source)); return static_cast(source); } diff --git a/regenerate_stale_files.sh b/regenerate_stale_files.sh index 4df6abb9438e..8c57c903fc36 100755 --- a/regenerate_stale_files.sh +++ b/regenerate_stale_files.sh @@ -9,8 +9,10 @@ set -ex cd $(dirname -- "$0") # Run and fix all staleness tests. +# LINT.IfChange(staleness_tests) bazel test //src:cmake_lists_staleness_test || ./bazel-bin/src/cmake_lists_staleness_test --fix bazel test //src/google/protobuf:well_known_types_staleness_test || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix +# LINT.ThenChange(//depot/google3/third_party/protobuf/github/kokoro/windows/prepare_build_win64.bat:staleness_tests) # Generate C# code. # This doesn't currently have Bazel staleness tests, but there's an existing diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index e2b97f3147ea..b5860ac74070 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -194,6 +194,8 @@ cc_library( ], deps = [ "//src/google/protobuf/stubs:lite", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/numeric:bits", ], ) @@ -208,6 +210,7 @@ cc_library( ], deps = [ "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:absl_log", ], ) @@ -262,6 +265,8 @@ cc_library( ":arena_cleanup", ":arena_config", "//src/google/protobuf/stubs:lite", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/synchronization", ], ) @@ -337,6 +342,8 @@ cc_library( "//src/google/protobuf/stubs:lite", "@com_google_absl//absl/container:btree", "@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/meta:type_traits", "@com_google_absl//absl/numeric:bits", "@com_google_absl//absl/strings:internal", @@ -410,6 +417,8 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/hash", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:internal", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", @@ -698,6 +707,7 @@ cc_library( deps = [ ":cc_lite_test_protos", ":test_util2", + "@com_google_absl//absl/log:absl_check", "@com_google_googletest//:gtest", ], ) @@ -734,6 +744,7 @@ cc_library( ":lite_test_util", "//src/google/protobuf/testing", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_check", "@com_google_googletest//:gtest", ], ) @@ -757,6 +768,7 @@ cc_test( deps = [ ":protobuf", ":test_util", + "@com_google_absl//absl/log:absl_check", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", ], @@ -845,6 +857,8 @@ cc_test( ":protobuf", "//src/google/protobuf/compiler:importer", "//src/google/protobuf/testing", + "@com_google_absl//absl/log:die_if_null", + "@com_google_absl//absl/log:scoped_mock_log", "@com_google_absl//absl/strings:str_format", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", @@ -1037,6 +1051,7 @@ cc_test( "//src/google/protobuf/io", "//src/google/protobuf/stubs", "//src/google/protobuf/testing", + "@com_google_absl//absl/log:scoped_mock_log", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", ], @@ -1193,6 +1208,7 @@ cc_test( "//src/google/protobuf/io", "//src/google/protobuf/stubs", "//src/google/protobuf/testing", + "@com_google_absl//absl/log:scoped_mock_log", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", ], @@ -1253,6 +1269,7 @@ cc_test( "//src/google/protobuf/io", "//src/google/protobuf/stubs", "//src/google/protobuf/testing", + "@com_google_absl//absl/log:scoped_mock_log", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", ], diff --git a/src/google/protobuf/any_test.cc b/src/google/protobuf/any_test.cc index 9ff0e34b3a69..8b544d9edadc 100644 --- a/src/google/protobuf/any_test.cc +++ b/src/google/protobuf/any_test.cc @@ -178,7 +178,7 @@ TEST(AnyTest, MoveAssignment) { EXPECT_EQ(12345, payload.int32_value()); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST #ifndef NDEBUG TEST(AnyTest, PackSelfDeath) { google::protobuf::Any any; @@ -186,7 +186,7 @@ TEST(AnyTest, PackSelfDeath) { EXPECT_DEATH(any.PackFrom(any, ""), "&message"); } #endif // !NDEBUG -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } // namespace diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 25ddcc3f1a32..d00093160544 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -94,7 +94,7 @@ static SerialArena::Memory AllocateMemory(const AllocationPolicy* policy_ptr, size = policy.start_block_size; } // Verify that min_bytes + kBlockHeaderSize won't overflow. - GOOGLE_ABSL_CHECK_LE(min_bytes, std::numeric_limits::max() - + ABSL_CHECK_LE(min_bytes, std::numeric_limits::max() - SerialArena::kBlockHeaderSize); size = std::max(size, SerialArena::kBlockHeaderSize + min_bytes); @@ -140,7 +140,7 @@ SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent) head_{b}, space_allocated_{b->size}, parent_{parent} { - GOOGLE_ABSL_DCHECK(!b->IsSentry()); + ABSL_DCHECK(!b->IsSentry()); } // It is guaranteed that this is the first SerialArena. Use sentry block. @@ -169,7 +169,7 @@ void SerialArena::Init(ArenaBlock* b, size_t offset) { } SerialArena* SerialArena::New(Memory mem, ThreadSafeArena& parent) { - GOOGLE_ABSL_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, + ABSL_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, mem.size); ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(), /*used=*/0, /*allocated=*/mem.size, @@ -279,7 +279,7 @@ void SerialArena::CleanupList() { do { char* limit = b->Limit(); char* it = reinterpret_cast(b->cleanup_nodes); - GOOGLE_ABSL_DCHECK(!b->IsSentry() || it == limit); + ABSL_DCHECK(!b->IsSentry() || it == limit); while (it < limit) { it += cleanup::DestroyNode(it); } @@ -352,7 +352,7 @@ class ThreadSafeArena::SerialArenaChunk { return Layout(capacity()).Slice(ptr()).first(safe_size()); } std::atomic& id(uint32_t i) { - GOOGLE_ABSL_DCHECK_LT(i, capacity()); + ABSL_DCHECK_LT(i, capacity()); return Layout(capacity()).Pointer(ptr())[i]; } @@ -364,11 +364,11 @@ class ThreadSafeArena::SerialArenaChunk { return Layout(capacity()).Slice(ptr()).first(safe_size()); } const std::atomic& arena(uint32_t i) const { - GOOGLE_ABSL_DCHECK_LT(i, capacity()); + ABSL_DCHECK_LT(i, capacity()); return Layout(capacity()).Pointer(ptr())[i]; } std::atomic& arena(uint32_t i) { - GOOGLE_ABSL_DCHECK_LT(i, capacity()); + ABSL_DCHECK_LT(i, capacity()); return Layout(capacity()).Pointer(ptr())[i]; } @@ -475,7 +475,7 @@ ThreadSafeArena::ThreadSafeArena(void* mem, size_t size, } ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size) { - GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast(buf) & 7, 0u); + ABSL_DCHECK_EQ(reinterpret_cast(buf) & 7, 0u); if (buf == nullptr || size <= kBlockHeaderSize) { return SentryArenaBlock(); } @@ -488,7 +488,7 @@ ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size, const AllocationPolicy& policy) { if (policy.IsDefault()) return FirstBlock(buf, size); - GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast(buf) & 7, 0u); + ABSL_DCHECK_EQ(reinterpret_cast(buf) & 7, 0u); SerialArena::Memory mem; if (buf == nullptr || size < kBlockHeaderSize + kAllocPolicySize) { @@ -510,26 +510,26 @@ void ThreadSafeArena::InitializeWithPolicy(const AllocationPolicy& policy) { #ifndef NDEBUG const uint64_t old_alloc_policy = alloc_policy_.get_raw(); // If there was a policy (e.g., in Reset()), make sure flags were preserved. -#define GOOGLE_ABSL_DCHECK_POLICY_FLAGS_() \ +#define ABSL_DCHECK_POLICY_FLAGS_() \ if (old_alloc_policy > 3) \ - GOOGLE_ABSL_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3) + ABSL_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3) #else -#define GOOGLE_ABSL_DCHECK_POLICY_FLAGS_() +#define ABSL_DCHECK_POLICY_FLAGS_() #endif // NDEBUG // We ensured enough space so this cannot fail. void* p; if (!first_arena_.MaybeAllocateAligned(kAllocPolicySize, &p)) { - GOOGLE_ABSL_LOG(FATAL) << "MaybeAllocateAligned cannot fail here."; + ABSL_LOG(FATAL) << "MaybeAllocateAligned cannot fail here."; return; } new (p) AllocationPolicy{policy}; // Low bits store flags, so they mustn't be overwritten. - GOOGLE_ABSL_DCHECK_EQ(0, reinterpret_cast(p) & 3); + ABSL_DCHECK_EQ(0, reinterpret_cast(p) & 3); alloc_policy_.set_policy(reinterpret_cast(p)); - GOOGLE_ABSL_DCHECK_POLICY_FLAGS_(); + ABSL_DCHECK_POLICY_FLAGS_(); -#undef GOOGLE_ABSL_DCHECK_POLICY_FLAGS_ +#undef ABSL_DCHECK_POLICY_FLAGS_ } uint64_t ThreadSafeArena::GetNextLifeCycleId() { @@ -645,10 +645,10 @@ SerialArena::Memory ThreadSafeArena::Free(size_t* space_allocated) { // necessary to Free and we should revisit this. (b/247560530) for (auto it = span.rbegin(); it != span.rend(); ++it) { SerialArena* serial = it->load(std::memory_order_relaxed); - GOOGLE_ABSL_DCHECK_NE(serial, nullptr); + ABSL_DCHECK_NE(serial, nullptr); // Always frees the first block of "serial" as it cannot be user-provided. SerialArena::Memory mem = serial->Free(deallocator); - GOOGLE_ABSL_DCHECK_NE(mem.ptr, nullptr); + ABSL_DCHECK_NE(mem.ptr, nullptr); deallocator(mem); } @@ -792,7 +792,7 @@ void ThreadSafeArena::CleanupList() { // and required not to break inter-object dependencies. (b/247560530) for (auto it = span.rbegin(); it != span.rend(); ++it) { SerialArena* serial = it->load(std::memory_order_relaxed); - GOOGLE_ABSL_DCHECK_NE(serial, nullptr); + ABSL_DCHECK_NE(serial, nullptr); serial->CleanupList(); } }); @@ -815,7 +815,7 @@ SerialArena* ThreadSafeArena::GetSerialArenaFallback(size_t n) { for (uint32_t i = 0; i < ids.size(); ++i) { if (ids[i].load(std::memory_order_relaxed) == id) { serial = chunk->arena(i).load(std::memory_order_relaxed); - GOOGLE_ABSL_DCHECK_NE(serial, nullptr); + ABSL_DCHECK_NE(serial, nullptr); break; } } diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 5c553cb7370d..23e6999c4c0c 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -314,7 +314,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { "CreateArray requires a trivially constructible type"); static_assert(std::is_trivially_destructible::value, "CreateArray requires a trivially destructible type"); - GOOGLE_ABSL_CHECK_LE(num_elements, std::numeric_limits::max() / sizeof(T)) + ABSL_CHECK_LE(num_elements, std::numeric_limits::max() / sizeof(T)) << "Requested size is too large to fit into size_t."; if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) { return static_cast(::operator new[](num_elements * sizeof(T))); diff --git a/src/google/protobuf/arena_align.h b/src/google/protobuf/arena_align.h index 573caf3a9637..958bb9d072b8 100644 --- a/src/google/protobuf/arena_align.h +++ b/src/google/protobuf/arena_align.h @@ -78,7 +78,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/bits.h" // Must be included last. @@ -175,8 +175,8 @@ struct ArenaAlign { inline ArenaAlign ArenaAlignAs(size_t align) { // align must be a non zero power of 2 >= 8 - GOOGLE_ABSL_DCHECK_NE(align, 0U); - GOOGLE_ABSL_DCHECK(absl::has_single_bit(align)) << "Invalid alignment " << align; + ABSL_DCHECK_NE(align, 0U); + ABSL_DCHECK(absl::has_single_bit(align)) << "Invalid alignment " << align; return ArenaAlign{align}; } diff --git a/src/google/protobuf/arena_align_test.cc b/src/google/protobuf/arena_align_test.cc index be71ff96facf..a73ba335e51e 100644 --- a/src/google/protobuf/arena_align_test.cc +++ b/src/google/protobuf/arena_align_test.cc @@ -72,9 +72,9 @@ TEST(ArenaAlignDefault, Padded) { EXPECT_THAT(align_default.Padded(0), Eq(0)); EXPECT_THAT(align_default.Padded(8), Eq(8)); EXPECT_THAT(align_default.Padded(64), Eq(64)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.Padded(1), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlignDefault, CeilPtr) { @@ -95,13 +95,13 @@ TEST(ArenaAlignDefault, CheckAligned) { EXPECT_THAT(align_default.CheckAligned(p + 0), Eq(p + 0)); EXPECT_THAT(align_default.CheckAligned(p + 8), Eq(p + 8)); EXPECT_THAT(align_default.CheckAligned(p + 16), Eq(p + 16)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 9), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 15), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 17), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlignDefault, CeilDefaultAligned) { @@ -110,13 +110,13 @@ TEST(ArenaAlignDefault, CeilDefaultAligned) { EXPECT_THAT(align_default.CeilDefaultAligned(p + 0), Eq(p + 0)); EXPECT_THAT(align_default.CeilDefaultAligned(p + 8), Eq(p + 8)); EXPECT_THAT(align_default.CeilDefaultAligned(p + 16), Eq(p + 16)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 9), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 15), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 17), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlignDefault, IsAligned) { @@ -161,12 +161,12 @@ TEST(ArenaAlign, Padded) { auto align_64 = ArenaAlignAs(64); EXPECT_THAT(align_64.Padded(64), Eq(64 + 64 - ArenaAlignDefault::align)); EXPECT_THAT(align_64.Padded(128), Eq(128 + 64 - ArenaAlignDefault::align)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST // TODO(mvels): there are direct callers of AllocateAligned() that violate // `size` being a multiple of `align`: that should be an error / assert. // EXPECT_DEBUG_DEATH(align_64.Padded(16), ".*"); EXPECT_DEBUG_DEATH(ArenaAlignAs(2).Padded(8), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlign, CeilPtr) { @@ -187,7 +187,7 @@ TEST(ArenaAlign, CheckAligned) { EXPECT_THAT(align_64.CheckAligned(p + 0), Eq(p)); EXPECT_THAT(align_64.CheckAligned(p + 64), Eq(p + 64)); EXPECT_THAT(align_64.CheckAligned(p + 128), Eq(p + 128)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 8), ".*"); @@ -197,7 +197,7 @@ TEST(ArenaAlign, CheckAligned) { EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 72), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 120), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 129), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlign, CeilDefaultAligned) { @@ -210,14 +210,14 @@ TEST(ArenaAlign, CeilDefaultAligned) { EXPECT_THAT(align_64.CeilDefaultAligned(p + 72), Eq(p + 128)); EXPECT_THAT(align_64.CeilDefaultAligned(p + 120), Eq(p + 128)); EXPECT_THAT(align_64.CeilDefaultAligned(p + 128), Eq(p + 128)); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 63), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 65), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 127), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 129), ".*"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(ArenaAlign, IsAligned) { diff --git a/src/google/protobuf/arena_cleanup.h b/src/google/protobuf/arena_cleanup.h index d48661f3d37f..5c7799f4a379 100644 --- a/src/google/protobuf/arena_cleanup.h +++ b/src/google/protobuf/arena_cleanup.h @@ -36,8 +36,8 @@ #include #include "absl/base/attributes.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" @@ -92,7 +92,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE void CreateNode(Tag tag, void* pos, void (*destructor)(void*)) { auto elem = reinterpret_cast(elem_raw); if (EnableSpecializedTags()) { - GOOGLE_ABSL_DCHECK_EQ(elem & 3, 0ULL); // Must be aligned + ABSL_DCHECK_EQ(elem & 3, 0ULL); // Must be aligned switch (tag) { case Tag::kString: { TaggedNode n = {elem | static_cast(Tag::kString)}; @@ -187,7 +187,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE Tag Type(void* raw) { case Tag::kCord: return Tag::kCord; default: - GOOGLE_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << (elem & 0x7ULL); + ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << (elem & 0x7ULL); return Tag::kDynamic; } } @@ -204,7 +204,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE size_t Size(Tag tag) { case Tag::kCord: return sizeof(TaggedNode); default: - GOOGLE_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << static_cast(tag); + ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << static_cast(tag); return sizeof(DynamicNode); } } diff --git a/src/google/protobuf/arena_test_util.cc b/src/google/protobuf/arena_test_util.cc index 40dc3500b512..1efa08a7984e 100644 --- a/src/google/protobuf/arena_test_util.cc +++ b/src/google/protobuf/arena_test_util.cc @@ -30,10 +30,10 @@ #include "google/protobuf/arena_test_util.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" -#define EXPECT_EQ GOOGLE_ABSL_CHECK_EQ +#define EXPECT_EQ ABSL_CHECK_EQ namespace google { namespace protobuf { diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h index e32ad4cc522e..7a6de35c805d 100644 --- a/src/google/protobuf/arena_test_util.h +++ b/src/google/protobuf/arena_test_util.h @@ -31,7 +31,7 @@ #ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ #define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/arena.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h" @@ -70,7 +70,7 @@ void TestParseCorruptedString(const T& message) { } // This next line is a low bar. But getting through the test without crashing // due to use-after-free or other bugs is a big part of what we're checking. - GOOGLE_ABSL_CHECK_GT(success_count, 0); + ABSL_CHECK_GT(success_count, 0); } namespace internal { @@ -105,8 +105,8 @@ class ArenaHolder { explicit ArenaHolder(Arena* arena) : field_(Arena::CreateMessage(arena)), owned_by_arena_(arena != nullptr) { - GOOGLE_ABSL_DCHECK(google::protobuf::Arena::is_arena_constructable::value); - GOOGLE_ABSL_DCHECK(google::protobuf::Arena::is_destructor_skippable::value); + ABSL_DCHECK(google::protobuf::Arena::is_arena_constructable::value); + ABSL_DCHECK(google::protobuf::Arena::is_destructor_skippable::value); } ~ArenaHolder() { diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index a40bb9926510..a1be800221b2 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -41,7 +41,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "absl/synchronization/barrier.h" #include "google/protobuf/arena_test_util.h" @@ -670,7 +670,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenas) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(arena1_message->set_allocated_optional_nested_message( arena2_submessage), "submessage_arena"); @@ -683,7 +683,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenas) { Arena::CreateMessage(&arena1); arena1_submessage->set_bb(42); TestAllTypes* heap_message = new TestAllTypes; -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH( heap_message->set_allocated_optional_nested_message(arena1_submessage), "submessage_arena"); @@ -739,7 +739,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH( r->SetAllocatedMessage(arena1_message, arena2_submessage, msg_field), "GetOwningArena"); @@ -752,7 +752,7 @@ TEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) { Arena::CreateMessage(&arena1); arena1_submessage->set_bb(42); TestAllTypes* heap_message = new TestAllTypes; -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH( r->SetAllocatedMessage(heap_message, arena1_submessage, msg_field), "GetOwningArena"); @@ -855,14 +855,13 @@ TEST(ArenaTest, AddAllocatedToRepeatedField) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH( - arena1_message->mutable_repeated_nested_message()->AddAllocated( - arena2_submessage), - "value_arena"); -#endif - // Should not receive object. - EXPECT_TRUE(arena1_message->repeated_nested_message().empty()); + arena1_message->mutable_repeated_nested_message()->AddAllocated( + arena2_submessage); + ASSERT_THAT(arena1_message->repeated_nested_message(), testing::SizeIs(1)); + EXPECT_EQ( + arena1_message->mutable_repeated_nested_message()->at(0).GetArena(), + &arena1); + arena1_message->clear_repeated_nested_message(); } // Arena->heap case. @@ -872,14 +871,12 @@ TEST(ArenaTest, AddAllocatedToRepeatedField) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH( - heap_message->mutable_repeated_nested_message()->AddAllocated( - arena2_submessage), - "value_arena"); -#endif - // Should not receive object. - EXPECT_TRUE(heap_message->repeated_nested_message().empty()); + heap_message->mutable_repeated_nested_message()->AddAllocated( + arena2_submessage); + ASSERT_THAT(heap_message->repeated_nested_message(), testing::SizeIs(1)); + EXPECT_EQ(heap_message->mutable_repeated_nested_message()->at(0).GetArena(), + nullptr); + heap_message->clear_repeated_nested_message(); } delete heap_message; @@ -977,13 +974,12 @@ TEST(ArenaTest, AddAllocatedToRepeatedFieldViaReflection) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH( - r->AddAllocatedMessage(arena1_message, fd, arena2_submessage), - "value_arena"); -#endif - // Should not receive object. - EXPECT_TRUE(arena1_message->repeated_nested_message().empty()); + r->AddAllocatedMessage(arena1_message, fd, arena2_submessage); + ASSERT_THAT(arena1_message->repeated_nested_message(), testing::SizeIs(1)); + EXPECT_EQ( + arena1_message->mutable_repeated_nested_message()->at(0).GetArena(), + &arena1); + arena1_message->clear_repeated_nested_message(); } // Arena->heap case. @@ -993,13 +989,11 @@ TEST(ArenaTest, AddAllocatedToRepeatedFieldViaReflection) { TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage(&arena2); arena2_submessage->set_bb(42); -#ifdef PROTOBUF_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH( - r->AddAllocatedMessage(heap_message, fd, arena2_submessage), - "value_arena"); -#endif - // Should not receive object. - EXPECT_TRUE(heap_message->repeated_nested_message().empty()); + r->AddAllocatedMessage(heap_message, fd, arena2_submessage); + ASSERT_THAT(heap_message->repeated_nested_message(), testing::SizeIs(1)); + EXPECT_EQ(heap_message->mutable_repeated_nested_message()->at(0).GetArena(), + nullptr); + heap_message->clear_repeated_nested_message(); } delete heap_message; } @@ -1450,7 +1444,7 @@ TEST(ArenaTest, Alignment) { Arena arena; for (int i = 0; i < 200; i++) { void* p = Arena::CreateArray(&arena, i); - GOOGLE_ABSL_CHECK_EQ(reinterpret_cast(p) % 8, 0) << i << ": " << p; + ABSL_CHECK_EQ(reinterpret_cast(p) % 8, 0) << i << ": " << p; } } diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc index de7c22cf04a2..dbf545d1b066 100644 --- a/src/google/protobuf/arenastring.cc +++ b/src/google/protobuf/arenastring.cc @@ -32,7 +32,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "google/protobuf/io/coded_stream.h" @@ -202,7 +202,7 @@ std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) { if (tagged_ptr_.IsMutable()) { return tagged_ptr_.Get(); } else { - GOOGLE_ABSL_DCHECK(IsDefault()); + ABSL_DCHECK(IsDefault()); // Allocate empty. The contents are not relevant. return NewString(arena); } @@ -211,7 +211,7 @@ std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) { template std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default) { - GOOGLE_ABSL_DCHECK(IsDefault()); + ABSL_DCHECK(IsDefault()); // For empty defaults, this ends up calling the default constructor which is // more efficient than a copy construction from @@ -285,7 +285,7 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr, ArenaStringPtr* s, Arena* arena) { ScopedCheckPtrInvariants check(&s->tagged_ptr_); - GOOGLE_ABSL_DCHECK(arena != nullptr); + ABSL_DCHECK(arena != nullptr); int size = ReadSize(&ptr); if (!ptr) return nullptr; diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 38783aa4d84e..5c13cfd03bbb 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -36,7 +36,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/arena.h" #include "google/protobuf/port.h" #include "absl/strings/string_view.h" @@ -197,11 +197,11 @@ class TaggedStringPtr { private: static inline void assert_aligned(const void* p) { - GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast(p) & kMask, 0UL); + ABSL_DCHECK_EQ(reinterpret_cast(p) & kMask, 0UL); } inline std::string* TagAs(Type type, std::string* p) { - GOOGLE_ABSL_DCHECK(p != nullptr); + ABSL_DCHECK(p != nullptr); assert_aligned(p); ptr_ = reinterpret_cast(reinterpret_cast(p) | type); return p; @@ -478,8 +478,8 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() { } inline std::string* ArenaStringPtr::UnsafeMutablePointer() { - GOOGLE_ABSL_DCHECK(tagged_ptr_.IsMutable()); - GOOGLE_ABSL_DCHECK(tagged_ptr_.Get() != nullptr); + ABSL_DCHECK(tagged_ptr_.IsMutable()); + ABSL_DCHECK(tagged_ptr_.Get() != nullptr); return tagged_ptr_.Get(); } diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index 2809920056f1..a709d84dec3a 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -40,7 +40,7 @@ #include "google/protobuf/generated_message_util.h" #include "google/protobuf/message_lite.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" diff --git a/src/google/protobuf/arenaz_sampler_test.cc b/src/google/protobuf/arenaz_sampler_test.cc index 0152d5f71798..9098af7afe44 100644 --- a/src/google/protobuf/arenaz_sampler_test.cc +++ b/src/google/protobuf/arenaz_sampler_test.cc @@ -445,7 +445,7 @@ class ThreadSafeArenazSamplerTestThread : public Thread { protobuf_test_messages::proto2::TestAllTypesProto2> message = google::protobuf::MakeArenaSafeUnique< protobuf_test_messages::proto2::TestAllTypesProto2>(arena_); - GOOGLE_ABSL_CHECK(message != nullptr); + ABSL_CHECK(message != nullptr); // Signal that a message on the arena has been created. This should create // a SerialArena for this thread. if (barrier_->Block()) { @@ -508,7 +508,7 @@ class SampleFirstArenaThread : public Thread { protobuf_test_messages::proto2::TestAllTypesProto2> message = google::protobuf::MakeArenaSafeUnique< protobuf_test_messages::proto2::TestAllTypesProto2>(&arena); - GOOGLE_ABSL_CHECK(message != nullptr); + ABSL_CHECK(message != nullptr); arena_created_.Notify(); samples_counted_.WaitForNotification(); } diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel index 3439f8859774..4cf0d173be41 100644 --- a/src/google/protobuf/compiler/BUILD.bazel +++ b/src/google/protobuf/compiler/BUILD.bazel @@ -38,6 +38,8 @@ cc_library( visibility = ["//visibility:public"], deps = [ "//src/google/protobuf:protobuf_nowkt", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) @@ -61,6 +63,8 @@ cc_library( deps = [ "//src/google/protobuf:protobuf_nowkt", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", ], @@ -86,6 +90,8 @@ cc_library( ":importer", "//src/google/protobuf:protobuf_nowkt", "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ], @@ -109,6 +115,7 @@ cc_library( "//src/google/protobuf/compiler/php", "//src/google/protobuf/compiler/python", "//src/google/protobuf/compiler/ruby", + "@com_google_absl//absl/log:initialize", ], ) diff --git a/src/google/protobuf/compiler/annotation_test_util.cc b/src/google/protobuf/compiler/annotation_test_util.cc index f5a6d39302bd..eec6c0ca3a3a 100644 --- a/src/google/protobuf/compiler/annotation_test_util.cc +++ b/src/google/protobuf/compiler/annotation_test_util.cc @@ -40,7 +40,7 @@ #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -72,7 +72,7 @@ class DescriptorCapturingGenerator : public CodeGenerator { } // namespace void AddFile(absl::string_view filename, absl::string_view data) { - GOOGLE_ABSL_CHECK_OK(File::SetContents( + ABSL_CHECK_OK(File::SetContents( absl::StrCat(TestTempDir(), "/", filename), data, true)); } @@ -96,7 +96,7 @@ bool RunProtoCompiler(const std::string& filename, bool DecodeMetadata(const std::string& path, GeneratedCodeInfo* info) { std::string data; - GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &data, true)); + ABSL_CHECK_OK(File::GetContents(path, &data, true)); io::ArrayInputStream input(data.data(), data.size()); return info->ParseFromZeroCopyStream(&input); } diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index f7c9bdf667c5..feaf0ccac500 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -38,7 +38,7 @@ #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -85,7 +85,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend( io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( const std::string& filename, const std::string& insertion_point) { - GOOGLE_ABSL_LOG(FATAL) << "This GeneratorContext does not support insertion."; + ABSL_LOG(FATAL) << "This GeneratorContext does not support insertion."; return nullptr; // make compiler happy } @@ -97,7 +97,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo( void GeneratorContext::ListParsedFiles( std::vector* output) { - GOOGLE_ABSL_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; + ABSL_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; } void GeneratorContext::GetCompilerVersion(Version* version) const { diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 5867680f8215..4dde92126be9 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -73,8 +73,8 @@ #endif #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "google/protobuf/compiler/subprocess.h" #include "google/protobuf/compiler/plugin.pb.h" #include "absl/container/flat_hash_set.h" @@ -142,7 +142,7 @@ void SetFdToTextMode(int fd) { #ifdef _WIN32 if (setmode(fd, _O_TEXT) == -1) { // This should never happen, I think. - GOOGLE_ABSL_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); + ABSL_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); } #endif // (Text and binary are the same on non-Windows platforms.) @@ -152,7 +152,7 @@ void SetFdToBinaryMode(int fd) { #ifdef _WIN32 if (setmode(fd, _O_BINARY) == -1) { // This should never happen, I think. - GOOGLE_ABSL_LOG(WARNING) << "setmode(" << fd + ABSL_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno); } #endif @@ -898,7 +898,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { data_pos += line_length; } - GOOGLE_ABSL_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size); + ABSL_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size); UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size()); } @@ -1112,7 +1112,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } if (!dependency_out_name_.empty()) { - GOOGLE_ABSL_DCHECK(disk_source_tree.get()); + ABSL_DCHECK(disk_source_tree.get()); if (!GenerateDependencyManifestFile(parsed_files, output_directories, disk_source_tree.get())) { return 1; @@ -1132,7 +1132,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { FileDescriptorProto file; file.set_name("empty_message.proto"); file.add_message_type()->set_name("EmptyMessage"); - GOOGLE_ABSL_CHECK(pool.BuildFile(file) != nullptr); + ABSL_CHECK(pool.BuildFile(file) != nullptr); codec_type_ = "EmptyMessage"; if (!EncodeOrDecode(&pool)) { return 1; @@ -1160,7 +1160,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } break; case PRINT_NONE: - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "If the code reaches here, it usually means a bug of " "flag parsing in the CommandLineInterface."; return 1; @@ -1565,7 +1565,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( input_files_.empty() && descriptor_set_in_names_.empty(); break; default: - GOOGLE_ABSL_LOG(FATAL) << "Unexpected mode: " << mode_; + ABSL_LOG(FATAL) << "Unexpected mode: " << mode_; } if (missing_proto_definitions) { std::cerr << "Missing input file." << std::endl; @@ -1770,7 +1770,7 @@ CommandLineInterface::InterpretArgument(const std::string& name, direct_dependencies_explicitly_set_ = true; std::vector direct = absl::StrSplit(value, ":", absl::SkipEmpty()); - GOOGLE_ABSL_DCHECK(direct_dependencies_.empty()); + ABSL_DCHECK(direct_dependencies_.empty()); direct_dependencies_.insert(direct.begin(), direct.end()); } else if (name == "--direct_dependencies_violation_msg") { @@ -2170,7 +2170,7 @@ bool CommandLineInterface::GenerateOutput( std::string error; if (output_directive.generator == nullptr) { // This is a plugin. - GOOGLE_ABSL_CHECK(absl::StartsWith(output_directive.name, "--") && + ABSL_CHECK(absl::StartsWith(output_directive.name, "--") && absl::EndsWith(output_directive.name, "_out")) << "Bad name for plugin generator: " << output_directive.name; diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index abbf7b159a99..967b5104de9a 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -38,7 +38,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -289,7 +289,7 @@ void CommandLineInterfaceTest::SetUp() { } // Create the temp directory. - GOOGLE_ABSL_CHECK_OK(File::CreateDir(temp_directory_, 0777)); + ABSL_CHECK_OK(File::CreateDir(temp_directory_, 0777)); // Register generators. CodeGenerator* generator = new MockCodeGenerator("test_generator"); @@ -362,7 +362,7 @@ void CommandLineInterfaceTest::RunWithArgs(std::vector args) { #endif if (plugin_path.empty() || !FileExists(plugin_path)) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "Plugin executable not found. Plugin tests are likely to fail." << plugin_path; } else { @@ -402,20 +402,20 @@ void CommandLineInterfaceTest::CreateTempFile(absl::string_view name, if (slash_pos != std::string::npos) { absl::string_view dir = name.substr(0, slash_pos); if (!FileExists(absl::StrCat(temp_directory_, "/", dir))) { - GOOGLE_ABSL_CHECK_OK(File::RecursivelyCreateDir( + ABSL_CHECK_OK(File::RecursivelyCreateDir( absl::StrCat(temp_directory_, "/", dir), 0777)); } } // Write file. std::string full_name = absl::StrCat(temp_directory_, "/", name); - GOOGLE_ABSL_CHECK_OK(File::SetContents( + ABSL_CHECK_OK(File::SetContents( full_name, absl::StrReplaceAll(contents, {{"$tmpdir", temp_directory_}}), true)); } void CommandLineInterfaceTest::CreateTempDir(absl::string_view name) { - GOOGLE_ABSL_CHECK_OK(File::RecursivelyCreateDir( + ABSL_CHECK_OK(File::RecursivelyCreateDir( absl::StrCat(temp_directory_, "/", name), 0777)); } @@ -504,7 +504,7 @@ void CommandLineInterfaceTest::ReadDescriptorSet( absl::string_view filename, FileDescriptorSet* descriptor_set) { std::string path = absl::StrCat(temp_directory_, "/", filename); std::string file_contents; - GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &file_contents, true)); + ABSL_CHECK_OK(File::GetContents(path, &file_contents, true)); if (!descriptor_set->ParseFromString(file_contents)) { FAIL() << "Could not parse file contents: " << path; @@ -514,7 +514,7 @@ void CommandLineInterfaceTest::ReadDescriptorSet( void CommandLineInterfaceTest::WriteDescriptorSet( absl::string_view filename, const FileDescriptorSet* descriptor_set) { std::string binary_proto; - GOOGLE_ABSL_CHECK(descriptor_set->SerializeToString(&binary_proto)); + ABSL_CHECK(descriptor_set->SerializeToString(&binary_proto)); CreateTempFile(filename, binary_proto); } @@ -540,7 +540,7 @@ void CommandLineInterfaceTest::ExpectFileContent(absl::string_view filename, absl::string_view content) { std::string path = absl::StrCat(temp_directory_, "/", filename); std::string file_contents; - GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &file_contents, true)); + ABSL_CHECK_OK(File::GetContents(path, &file_contents, true)); EXPECT_EQ(absl::StrReplaceAll(content, {{"$tmpdir", temp_directory_}}), file_contents); @@ -2240,7 +2240,7 @@ TEST_F(CommandLineInterfaceTest, PluginReceivesSourceCodeInfo) { Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto"); ExpectErrorSubstring( - "Saw message type MockCodeGenerator_HasSourceCodeInfo: 1."); + "Saw message type MockCodeGenerator_HasSourceCodeInfo: true."); } TEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) { @@ -2252,7 +2252,7 @@ TEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) { Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto"); - ExpectErrorSubstring("Saw json_name: 1"); + ExpectErrorSubstring("Saw json_name: true"); } TEST_F(CommandLineInterfaceTest, PluginReceivesCompilerVersion) { @@ -2567,8 +2567,8 @@ class EncodeDecodeTest : public testing::TestWithParam { void RedirectStdinFromText(const std::string& input) { std::string filename = absl::StrCat(TestTempDir(), "/test_stdin"); - GOOGLE_ABSL_CHECK_OK(File::SetContents(filename, input, true)); - GOOGLE_ABSL_CHECK(RedirectStdinFromFile(filename)); + ABSL_CHECK_OK(File::SetContents(filename, input, true)); + ABSL_CHECK(RedirectStdinFromFile(filename)); } bool RedirectStdinFromFile(const std::string& filename) { @@ -2637,7 +2637,7 @@ class EncodeDecodeTest : public testing::TestWithParam { void ExpectStdoutMatchesBinaryFile(const std::string& filename) { std::string expected_output; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(filename, &expected_output, true)); // Don't use EXPECT_EQ because we don't want to print raw binary data to @@ -2647,7 +2647,7 @@ class EncodeDecodeTest : public testing::TestWithParam { void ExpectStdoutMatchesTextFile(const std::string& filename) { std::string expected_output; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(filename, &expected_output, true)); ExpectStdoutMatchesText(expected_output); @@ -2680,11 +2680,11 @@ class EncodeDecodeTest : public testing::TestWithParam { protobuf_unittest_import::PublicImportMessage public_import_message; public_import_message.descriptor()->file()->CopyTo( file_descriptor_set.add_file()); - GOOGLE_ABSL_DCHECK(file_descriptor_set.IsInitialized()); + ABSL_DCHECK(file_descriptor_set.IsInitialized()); std::string binary_proto; - GOOGLE_ABSL_CHECK(file_descriptor_set.SerializeToString(&binary_proto)); - GOOGLE_ABSL_CHECK_OK(File::SetContents(unittest_proto_descriptor_set_filename_, + ABSL_CHECK(file_descriptor_set.SerializeToString(&binary_proto)); + ABSL_CHECK_OK(File::SetContents(unittest_proto_descriptor_set_filename_, binary_proto, true)); } diff --git a/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc index f87856ef8d41..222449959421 100644 --- a/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc @@ -53,7 +53,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/substitute.h" #include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/io/zero_copy_stream_impl.h" @@ -97,15 +97,15 @@ class MockGeneratorContext : public GeneratorContext { std::string expected_contents = *it->second; std::string actual_contents; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( absl::StrCat(TestUtil::TestSourceDir(), "/", physical_filename), &actual_contents, true)) << physical_filename; #ifdef WRITE_FILES // Define to debug mismatched files. - GOOGLE_ABSL_CHECK_OK(File::SetContents("/tmp/expected.cc", expected_contents, + ABSL_CHECK_OK(File::SetContents("/tmp/expected.cc", expected_contents, true)); - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::SetContents("/tmp/actual.cc", actual_contents, true)); #endif diff --git a/src/google/protobuf/compiler/cpp/field.cc b/src/google/protobuf/compiler/cpp/field.cc index 8defa53e3dee..1a10cf488fe1 100644 --- a/src/google/protobuf/compiler/cpp/field.cc +++ b/src/google/protobuf/compiler/cpp/field.cc @@ -41,7 +41,7 @@ #include "google/protobuf/descriptor.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" @@ -169,7 +169,7 @@ void FieldGeneratorBase::GenerateCopyConstructorCode(io::Printer* p) const { } void FieldGeneratorBase::GenerateIfHasField(io::Printer* p) const { - GOOGLE_ABSL_CHECK(internal::cpp::HasHasbit(descriptor_)); + ABSL_CHECK(internal::cpp::HasHasbit(descriptor_)); Formatter format(p); format("if (($has_hasbit$) != 0) {\n"); @@ -229,7 +229,7 @@ void HasBitVars(const FieldDescriptor* field, const Options& opts, return; } - GOOGLE_ABSL_CHECK(internal::cpp::HasHasbit(field)); + ABSL_CHECK(internal::cpp::HasHasbit(field)); int32_t index = *idx / 32; std::string mask = absl::StrFormat("0x%08xu", 1u << (*idx % 32)); @@ -250,12 +250,12 @@ void HasBitVars(const FieldDescriptor* field, const Options& opts, void InlinedStringVars(const FieldDescriptor* field, const Options& opts, absl::optional idx, std::vector& vars) { if (!IsStringInlined(field, opts)) { - GOOGLE_ABSL_CHECK(!idx.has_value()); + ABSL_CHECK(!idx.has_value()); return; } // The first bit is the tracking bit for on demand registering ArenaDtor. - GOOGLE_ABSL_CHECK_GT(*idx, 0) + ABSL_CHECK_GT(*idx, 0) << "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking"; int32_t index = *idx / 32; diff --git a/src/google/protobuf/compiler/cpp/field.h b/src/google/protobuf/compiler/cpp/field.h index bf4fd444e457..4446520d3f8f 100644 --- a/src/google/protobuf/compiler/cpp/field.h +++ b/src/google/protobuf/compiler/cpp/field.h @@ -43,7 +43,7 @@ #include "google/protobuf/descriptor.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/options.h" #include "google/protobuf/io/printer.h" @@ -103,7 +103,7 @@ class FieldGeneratorBase { virtual void GenerateDestructorCode(io::Printer* p) const {} virtual void GenerateArenaDestructorCode(io::Printer* p) const { - GOOGLE_ABSL_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone) + ABSL_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone) << descriptor_->cpp_type_name(); } @@ -400,7 +400,7 @@ class FieldGeneratorTable { absl::Span inlined_string_indices); const FieldGenerator& get(const FieldDescriptor* field) const { - GOOGLE_ABSL_CHECK_EQ(field->containing_type(), descriptor_); + ABSL_CHECK_EQ(field->containing_type(), descriptor_); return fields_[field->index()]; } diff --git a/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc b/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc index e75fa308d10c..b19a2a6567eb 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/enum_field.cc @@ -37,7 +37,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/memory/memory.h" #include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h" @@ -113,7 +113,7 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* /*printer*/) const override { - GOOGLE_ABSL_CHECK(!ShouldSplit(descriptor_, options_)); + ABSL_CHECK(!ShouldSplit(descriptor_, options_)); } void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( diff --git a/src/google/protobuf/compiler/cpp/field_generators/map_field.cc b/src/google/protobuf/compiler/cpp/field_generators/map_field.cc index 73d3709f95b6..f036bdf2f562 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/map_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/map_field.cc @@ -32,7 +32,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h" diff --git a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc index afbef124c91e..97cfd3a50a12 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/message_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/message_field.cc @@ -36,7 +36,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/cpp/field.h" diff --git a/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc b/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc index 86243329021b..cdcfcaccb9cb 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc @@ -39,7 +39,7 @@ #include "google/protobuf/descriptor.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/memory/memory.h" #include "absl/strings/substitute.h" #include "absl/types/optional.h" @@ -95,7 +95,7 @@ absl::optional FixedSize(FieldDescriptor::Type type) { // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return absl::nullopt; } @@ -335,7 +335,7 @@ class RepeatedPrimitive final : public FieldGeneratorBase { void GenerateConstructorCode(io::Printer* p) const override {} void GenerateCopyConstructorCode(io::Printer* p) const override { - GOOGLE_ABSL_CHECK(!ShouldSplit(field_, *opts_)); + ABSL_CHECK(!ShouldSplit(field_, *opts_)); } void GenerateConstexprAggregateInitializer(io::Printer* p) const override { diff --git a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc index 1f4dfc73f5dd..deb4aa4566c0 100644 --- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc +++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc @@ -36,7 +36,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/memory/memory.h" #include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h" @@ -160,7 +160,7 @@ class RepeatedStringFieldGenerator : public FieldGeneratorBase { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override {} void GenerateCopyConstructorCode(io::Printer* printer) const override { - GOOGLE_ABSL_CHECK(!ShouldSplit(descriptor_, options_)); + ABSL_CHECK(!ShouldSplit(descriptor_, options_)); } void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( @@ -430,7 +430,7 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { if (descriptor_->default_value_string().empty()) { format("$field$.ClearToEmpty();\n"); } else { - GOOGLE_ABSL_DCHECK(!inlined_); + ABSL_DCHECK(!inlined_); format( "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n"); } @@ -504,7 +504,7 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { if (inlined_ && descriptor_->default_value_string().empty()) { return; } - GOOGLE_ABSL_DCHECK(!inlined_); + ABSL_DCHECK(!inlined_); format("$field$.InitDefault();\n"); if (IsString(descriptor_, options_) && descriptor_->default_value_string().empty()) { @@ -558,7 +558,7 @@ void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { } // Explicitly calls ~InlinedStringField as its automatic call is disabled. // Destructor has been implicitly skipped as a union. - GOOGLE_ABSL_DCHECK(!ShouldSplit(descriptor_, options_)); + ABSL_DCHECK(!ShouldSplit(descriptor_, options_)); format("$field$.~InlinedStringField();\n"); } @@ -616,7 +616,7 @@ void StringFieldGenerator::GenerateAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); if (ShouldSplit(descriptor_, options_)) { - GOOGLE_ABSL_CHECK(!inlined_); + ABSL_CHECK(!inlined_); format("decltype(Impl_::Split::$name$_){}"); return; } diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index 9e5dc18b9cad..fb7039cddd29 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc @@ -375,7 +375,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* p, void FileGenerator::DoIncludeFile(absl::string_view google3_name, bool do_export, io::Printer* p) { constexpr absl::string_view prefix = "third_party/protobuf/"; - GOOGLE_ABSL_CHECK(absl::StartsWith(google3_name, prefix)) << google3_name; + ABSL_CHECK(absl::StartsWith(google3_name, prefix)) << google3_name; auto v = p->WithVars( {{"export_suffix", do_export ? "// IWYU pragma: export" : ""}}); @@ -1242,11 +1242,11 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* p) { IncludeFile("third_party/protobuf/implicit_weak_message.h", p); } if (HasWeakFields(file_, options_)) { - GOOGLE_ABSL_CHECK(!options_.opensource_runtime); + ABSL_CHECK(!options_.opensource_runtime); IncludeFile("third_party/protobuf/weak_field_map.h", p); } if (HasLazyFields(file_, options_, &scc_analyzer_)) { - GOOGLE_ABSL_CHECK(!options_.opensource_runtime); + ABSL_CHECK(!options_.opensource_runtime); IncludeFile("third_party/protobuf/lazy_field.h", p); } if (ShouldVerify(file_, options_, &scc_analyzer_)) { diff --git a/src/google/protobuf/compiler/cpp/file.h b/src/google/protobuf/compiler/cpp/file.h index f4822e938e31..6514df048fb2 100644 --- a/src/google/protobuf/compiler/cpp/file.h +++ b/src/google/protobuf/compiler/cpp/file.h @@ -45,7 +45,7 @@ #include "google/protobuf/compiler/scc.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/compiler/cpp/enum.h" #include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/field.h" @@ -179,7 +179,7 @@ class FileGenerator { bool IsDepWeak(const FileDescriptor* dep) const { if (weak_deps_.count(dep) != 0) { - GOOGLE_ABSL_CHECK(!options_.opensource_runtime); + ABSL_CHECK(!options_.opensource_runtime); return true; } return false; diff --git a/src/google/protobuf/compiler/cpp/generator.cc b/src/google/protobuf/compiler/cpp/generator.cc index fc2dc8026675..c485cdb2a1fc 100644 --- a/src/google/protobuf/compiler/cpp/generator.cc +++ b/src/google/protobuf/compiler/cpp/generator.cc @@ -78,7 +78,7 @@ absl::flat_hash_map CommonVars( // Warning: there is some clever naming/splitting here to avoid extract // script rewrites. The names of these variables must not be things that // the extract script will rewrite. That's why we use "CHK" (for example) - // instead of "GOOGLE_ABSL_CHECK". + // instead of "ABSL_CHECK". // // These values are things the extract script would rewrite if we did not // split them. It might not strictly matter since we don't generate @@ -87,12 +87,12 @@ absl::flat_hash_map CommonVars( {"GOOGLE_PROTOBUF", is_oss ? "GOOGLE_PROTOBUF" : "GOOGLE3_PROTOBU" "F"}, - {"CHK", is_oss ? "GOOGLE_ABSL_CHECK" - : "ABSL_CHEC" - "K"}, - {"DCHK", is_oss ? "GOOGLE_ABSL_DCHECK" - : "ABSL_DCHEC" - "K"}, + {"CHK", + "ABSL_CHEC" + "K"}, + {"DCHK", + "ABSL_DCHEC" + "K"}, }; } } // namespace @@ -300,7 +300,7 @@ bool CppGenerator::Generate(const FileDescriptor* file, // pb.cc file. If we have more files than messages, then some files will // be generated as empty placeholders. if (file_options.num_cc_files > 0) { - GOOGLE_ABSL_CHECK_LE(num_cc_files, file_options.num_cc_files) + ABSL_CHECK_LE(num_cc_files, file_options.num_cc_files) << "There must be at least as many numbered .cc files as messages " "and extensions."; num_cc_files = file_options.num_cc_files; diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index 86d6196d017f..9970e2e35290 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -50,8 +50,8 @@ #include "google/protobuf/dynamic_message.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -439,7 +439,7 @@ std::string ExtensionName(const FieldDescriptor* d) { std::string QualifiedExtensionName(const FieldDescriptor* d, const Options& options) { - GOOGLE_ABSL_DCHECK(d->is_extension()); + ABSL_DCHECK(d->is_extension()); return QualifiedFileLevelSymbol(d->file(), ExtensionName(d), options); } @@ -559,19 +559,19 @@ std::string FieldMemberName(const FieldDescriptor* field, bool split) { return absl::StrCat(prefix, split_prefix, FieldName(field), "_"); } // Oneof fields are never split. - GOOGLE_ABSL_CHECK(!split); + ABSL_CHECK(!split); return absl::StrCat(prefix, field->containing_oneof()->name(), "_.", FieldName(field), "_"); } std::string OneofCaseConstantName(const FieldDescriptor* field) { - GOOGLE_ABSL_DCHECK(field->containing_oneof()); + ABSL_DCHECK(field->containing_oneof()); std::string field_name = UnderscoresToCamelCase(field->name(), true); return absl::StrCat("k", field_name); } std::string QualifiedOneofCaseConstantName(const FieldDescriptor* field) { - GOOGLE_ABSL_DCHECK(field->containing_oneof()); + ABSL_DCHECK(field->containing_oneof()); const std::string qualification = QualifiedClassName(field->containing_type()); return absl::StrCat(qualification, "::", OneofCaseConstantName(field)); @@ -605,7 +605,7 @@ int EstimateAlignmentSize(const FieldDescriptor* field) { case FieldDescriptor::CPPTYPE_MESSAGE: return 8; } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return -1; // Make compiler happy. } @@ -667,7 +667,7 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type) { // CppTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return nullptr; } @@ -699,7 +699,7 @@ std::string PrimitiveTypeName(const Options& options, // CppTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return ""; } @@ -747,7 +747,7 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) { // No default because we want the compiler to complain if any new // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return ""; } @@ -838,7 +838,7 @@ std::string DefaultValue(const Options& options, const FieldDescriptor* field) { // Can't actually get here; make compiler happy. (We could add a default // case above but then we wouldn't get the nice compiler warning when a // new type is added.) - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return ""; } @@ -1117,13 +1117,13 @@ bool IsStringOrMessage(const FieldDescriptor* field) { return true; } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return false; } FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field, const Options& options) { - GOOGLE_ABSL_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING); + ABSL_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING); if (options.opensource_runtime) { // Open-source protobuf release only supports STRING ctype. return FieldOptions::STRING; @@ -1634,7 +1634,7 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, case EnforceOptimizeMode::kNoEnforcement: if (file->options().optimize_for() == FileOptions::CODE_SIZE) { if (HasBootstrapProblem(file, options, has_opt_codesize_extension)) { - GOOGLE_ABSL_LOG(WARNING) + ABSL_LOG(WARNING) << "Proto states optimize_for = CODE_SIZE, but we " "cannot honor that because it contains custom option " "extensions defined in the same proto."; @@ -1644,7 +1644,7 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, return file->options().optimize_for(); } - GOOGLE_ABSL_LOG(FATAL) << "Unknown optimization enforcement requested."; + ABSL_LOG(FATAL) << "Unknown optimization enforcement requested."; // The phony return below serves to silence a warning from GCC 8. return FileOptions::SPEED; } diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 78875ec52fd8..b0dd62a23213 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -44,7 +44,7 @@ #include "google/protobuf/compiler/scc.h" #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -340,7 +340,7 @@ inline bool UseUnknownFieldSet(const FileDescriptor* file, inline bool IsWeak(const FieldDescriptor* field, const Options& options) { if (field->options().weak()) { - GOOGLE_ABSL_CHECK(!options.opensource_runtime); + ABSL_CHECK(!options.opensource_runtime); return true; } return false; @@ -985,7 +985,7 @@ struct OneOfRangeImpl { value_type operator*() { return descriptor->oneof_decl(idx); } friend bool operator==(const Iterator& a, const Iterator& b) { - GOOGLE_ABSL_DCHECK(a.descriptor == b.descriptor); + ABSL_DCHECK(a.descriptor == b.descriptor); return a.idx == b.idx; } friend bool operator!=(const Iterator& a, const Iterator& b) { diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index 8b472fd7485a..a65491c71074 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -51,8 +51,8 @@ #include "google/protobuf/map_entry_lite.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -104,7 +104,7 @@ std::string ConditionalToCheckBitmasks( parts.push_back( absl::StrCat("((", has_bits_var, "[", i, "] & ", m, ") ^ ", m, ")")); } - GOOGLE_ABSL_CHECK(!parts.empty()); + ABSL_CHECK(!parts.empty()); // If we have multiple parts, each expected to be 0, then bitwise-or them. std::string result = parts.size() == 1 @@ -208,7 +208,7 @@ RunMap FindRuns(const std::vector& fields, // !HasHasbit(field). bool EmitFieldNonDefaultCondition(io::Printer* p, const std::string& prefix, const FieldDescriptor* field) { - GOOGLE_ABSL_CHECK(!HasHasbit(field)); + ABSL_CHECK(!HasHasbit(field)); Formatter format(p); auto v = p->WithVars({{ {"prefix", prefix}, @@ -273,7 +273,7 @@ bool HasInternalHasMethod(const FieldDescriptor* field) { void CollectMapInfo( const Options& options, const Descriptor* descriptor, absl::flat_hash_map* variables) { - GOOGLE_ABSL_CHECK(IsMapEntryMessage(descriptor)); + ABSL_CHECK(IsMapEntryMessage(descriptor)); absl::flat_hash_map& vars = *variables; const FieldDescriptor* key = descriptor->map_key(); const FieldDescriptor* val = descriptor->map_value(); @@ -359,16 +359,16 @@ std::vector> CollectFields( // masked to tell if any thing in "fields" is present. uint32_t GenChunkMask(const std::vector& fields, const std::vector& has_bit_indices) { - GOOGLE_ABSL_CHECK(!fields.empty()); + ABSL_CHECK(!fields.empty()); int first_index_offset = has_bit_indices[fields.front()->index()] / 32; uint32_t chunk_mask = 0; for (auto field : fields) { // "index" defines where in the _has_bits_ the field appears. int index = has_bit_indices[field->index()]; - GOOGLE_ABSL_CHECK_EQ(first_index_offset, index / 32); + ABSL_CHECK_EQ(first_index_offset, index / 32); chunk_mask |= static_cast(1) << (index % 32); } - GOOGLE_ABSL_CHECK_NE(0, chunk_mask); + ABSL_CHECK_NE(0, chunk_mask); return chunk_mask; } @@ -465,7 +465,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index, for (auto field : chunks_[chunk]) { int hasbit_index = has_bit_indices_[field->index()]; // Fields on a chunk must be in the same word. - GOOGLE_ABSL_CHECK_EQ(this_word, hasbit_index / 32); + ABSL_CHECK_EQ(this_word, hasbit_index / 32); mask |= 1 << (hasbit_index % 32); } } @@ -970,7 +970,7 @@ void MessageGenerator::GenerateSingularFieldHasBits( } if (HasHasbit(field)) { int has_bit_index = HasBitIndex(field); - GOOGLE_ABSL_CHECK_NE(has_bit_index, kNoHasbit); + ABSL_CHECK_NE(has_bit_index, kNoHasbit); auto v = p->WithVars(HasbitVars(has_bit_index)); format( @@ -1187,7 +1187,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { " }\n", descriptor_->field(0)->full_name()); } else { - GOOGLE_ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify); + ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify); format( " static bool ValidateKey(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1216,7 +1216,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { " }\n", descriptor_->field(1)->full_name()); } else { - GOOGLE_ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify); + ABSL_CHECK(utf8_check == Utf8CheckMode::kVerify); format( " static bool ValidateValue(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1836,7 +1836,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { format.Outdent(); format("};"); - GOOGLE_ABSL_DCHECK(!need_to_emit_cached_size); + ABSL_DCHECK(!need_to_emit_cached_size); } // NOLINT(readability/fn_size) void MessageGenerator::GenerateInlineMethods(io::Printer* p) { @@ -1875,8 +1875,8 @@ void MessageGenerator::GenerateSchema(io::Printer* p, int offset, if (inlined_string_indices_.empty()) { inlined_string_indices_offset = -1; } else { - GOOGLE_ABSL_DCHECK_NE(has_offset, -1); - GOOGLE_ABSL_DCHECK(!IsMapEntryMessage(descriptor_)); + ABSL_DCHECK_NE(has_offset, -1); + ABSL_DCHECK(!IsMapEntryMessage(descriptor_)); inlined_string_indices_offset = has_offset + has_bit_indices_.size(); } format("{ $1$, $2$, $3$, sizeof($classtype$)},\n", offset, has_offset, @@ -1959,7 +1959,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) { field_generators_.get(field).GenerateInternalAccessorDeclarations(p); if (HasHasbit(field)) { int has_bit_index = HasBitIndex(field); - GOOGLE_ABSL_CHECK_NE(has_bit_index, kNoHasbit) << field->full_name(); + ABSL_CHECK_NE(has_bit_index, kNoHasbit) << field->full_name(); format( "static void set_has_$1$(HasBits* has_bits) {\n" " (*has_bits)[$2$] |= $3$u;\n" @@ -2172,7 +2172,7 @@ std::pair MessageGenerator::GenerateOffsets(io::Printer* p) { format("PROTOBUF_FIELD_OFFSET($classtype$, _impl_.$1$_),\n", oneof->name()); count++; } - GOOGLE_ABSL_CHECK_EQ(count, descriptor_->real_oneof_decl_count()); + ABSL_CHECK_EQ(count, descriptor_->real_oneof_decl_count()); if (IsMapEntryMessage(descriptor_)) { entries += 2; @@ -2415,7 +2415,7 @@ ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const { } void MessageGenerator::GenerateArenaDestructorCode(io::Printer* p) { - GOOGLE_ABSL_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone); + ABSL_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone); Formatter format(p); @@ -2922,7 +2922,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) { bool chunk_is_split = !chunk.empty() && ShouldSplit(chunk.front(), options_); // All chunks after the first split chunk should also be split. - GOOGLE_ABSL_CHECK(!first_split_chunk_processed || chunk_is_split); + ABSL_CHECK(!first_split_chunk_processed || chunk_is_split); if (chunk_is_split && !first_split_chunk_processed) { // Some fields are cleared without checking has_bit. So we add the // condition here to avoid writing to the default split instance. @@ -2933,7 +2933,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) { for (const auto& field : chunk) { if (CanClearByZeroing(field)) { - GOOGLE_ABSL_CHECK(!saw_non_zero_init); + ABSL_CHECK(!saw_non_zero_init); if (!memset_start) memset_start = field; memset_end = field; } else { @@ -2959,8 +2959,8 @@ void MessageGenerator::GenerateClear(io::Printer* p) { // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_ABSL_DCHECK_LE(2, popcnt(chunk_mask)); - GOOGLE_ABSL_DCHECK_GE(8, popcnt(chunk_mask)); + ABSL_DCHECK_LE(2, popcnt(chunk_mask)); + ABSL_DCHECK_GE(8, popcnt(chunk_mask)); if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); @@ -2975,8 +2975,8 @@ void MessageGenerator::GenerateClear(io::Printer* p) { // For clarity, do not memset a single field. field_generators_.get(memset_start).GenerateMessageClearingCode(p); } else { - GOOGLE_ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_start, options_)); - GOOGLE_ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_end, options_)); + ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_start, options_)); + ABSL_CHECK_EQ(chunk_is_split, ShouldSplit(memset_end, options_)); format( "::memset(&$1$, 0, static_cast<::size_t>(\n" " reinterpret_cast(&$2$) -\n" @@ -3249,7 +3249,7 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* p) { void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { if (HasSimpleBaseClass(descriptor_, options_)) return; - // Generate the class-specific MergeFrom, which avoids the GOOGLE_ABSL_CHECK and + // Generate the class-specific MergeFrom, which avoids the ABSL_CHECK and // cast. Formatter format(p); if (!HasDescriptorMethods(descriptor_->file(), options_)) { @@ -3313,8 +3313,8 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_ABSL_DCHECK_LE(2, popcnt(chunk_mask)); - GOOGLE_ABSL_DCHECK_GE(8, popcnt(chunk_mask)); + ABSL_DCHECK_LE(2, popcnt(chunk_mask)); + ABSL_DCHECK_GE(8, popcnt(chunk_mask)); if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); @@ -3346,7 +3346,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { } else if (field->options().weak() || cached_has_word_index != HasWordIndex(field)) { // Check hasbit, not using cached bits. - GOOGLE_ABSL_CHECK(HasHasbit(field)); + ABSL_CHECK(HasHasbit(field)); auto v = p->WithVars(HasbitVars(HasBitIndex(field))); format( "if ((from.$has_bits$[$has_array_index$] & $has_mask$) != 0) {\n"); @@ -3356,7 +3356,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { format("}\n"); } else { // Check hasbit, using cached bits. - GOOGLE_ABSL_CHECK(HasHasbit(field)); + ABSL_CHECK(HasHasbit(field)); int has_bit_index = has_bit_indices_[field->index()]; const std::string mask = absl::StrCat( absl::Hex(1u << (has_bit_index % 32), absl::kZeroPad8)); @@ -3380,7 +3380,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { if (have_outer_if) { if (deferred_has_bit_changes) { // Flush the has bits for the primitives we deferred. - GOOGLE_ABSL_CHECK_LE(0, cached_has_word_index); + ABSL_CHECK_LE(0, cached_has_word_index); format("_this->$has_bits$[$1$] |= cached_has_bits;\n", cached_has_word_index); } @@ -3506,7 +3506,7 @@ void MessageGenerator::GenerateVerify(io::Printer* p) { void MessageGenerator::GenerateSerializeOneofFields( io::Printer* p, const std::vector& fields) { Formatter format(p); - GOOGLE_ABSL_CHECK(!fields.empty()); + ABSL_CHECK(!fields.empty()); if (fields.size() == 1) { GenerateSerializeOneField(p, fields[0], -1); return; @@ -3865,7 +3865,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( int num_fields = ordered_fields.size() + sorted_extensions.size(); constexpr int kLargePrime = 1000003; - GOOGLE_ABSL_CHECK_LT(num_fields, kLargePrime) + ABSL_CHECK_LT(num_fields, kLargePrime) << "Prime offset must be greater than the number of fields to ensure " "those are coprime."; @@ -4082,8 +4082,8 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) { // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. - GOOGLE_ABSL_DCHECK_LE(2, popcnt(chunk_mask)); - GOOGLE_ABSL_DCHECK_GE(8, popcnt(chunk_mask)); + ABSL_DCHECK_LE(2, popcnt(chunk_mask)); + ABSL_DCHECK_GE(8, popcnt(chunk_mask)); if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); diff --git a/src/google/protobuf/compiler/cpp/message_size_unittest.cc b/src/google/protobuf/compiler/cpp/message_size_unittest.cc index 6d6bf6e5c6fb..7884ba0913ec 100644 --- a/src/google/protobuf/compiler/cpp/message_size_unittest.cc +++ b/src/google/protobuf/compiler/cpp/message_size_unittest.cc @@ -30,7 +30,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/unittest.pb.h" @@ -43,8 +43,8 @@ namespace cpp { namespace cpp_unittest { -#if !defined(GOOGLE_ABSL_CHECK_MESSAGE_SIZE) -#define GOOGLE_ABSL_CHECK_MESSAGE_SIZE(t, expected) +#if !defined(ABSL_CHECK_MESSAGE_SIZE) +#define ABSL_CHECK_MESSAGE_SIZE(t, expected) #endif // Mock structures to lock down the size of messages in a platform-independent @@ -53,13 +53,13 @@ struct MockMessageBase { virtual ~MockMessageBase() = default; // 8 bytes vtable void* internal_metadata; // 8 bytes }; -GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockMessageBase, 16); +ABSL_CHECK_MESSAGE_SIZE(MockMessageBase, 16); struct MockZeroFieldsBase : public MockMessageBase { int cached_size; // 4 bytes // + 4 bytes padding }; -GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockZeroFieldsBase, 24); +ABSL_CHECK_MESSAGE_SIZE(MockZeroFieldsBase, 24); struct MockExtensionSet { void* arena; // 8 bytes @@ -67,7 +67,7 @@ struct MockExtensionSet { int16_t size; // 4 bytes void* data; // 8 bytes }; -GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockExtensionSet, 24); +ABSL_CHECK_MESSAGE_SIZE(MockExtensionSet, 24); struct MockRepeatedPtrField { void* arena; // 8 bytes @@ -75,24 +75,24 @@ struct MockRepeatedPtrField { int total_size; // 4 bytes void* data; // 8 bytes }; -GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockRepeatedPtrField, 24); +ABSL_CHECK_MESSAGE_SIZE(MockRepeatedPtrField, 24); struct MockRepeatedField { int current_size; // 4 bytes int total_size; // 4 bytes void* data; // 8 bytes }; -GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockRepeatedField, 16); +ABSL_CHECK_MESSAGE_SIZE(MockRepeatedField, 16); TEST(GeneratedMessageTest, MockSizes) { // Consistency checks -- if these fail, the tests below will definitely fail. - GOOGLE_ABSL_CHECK_EQ(sizeof(MessageLite), sizeof(MockMessageBase)); - GOOGLE_ABSL_CHECK_EQ(sizeof(Message), sizeof(MockMessageBase)); - GOOGLE_ABSL_CHECK_EQ(sizeof(internal::ZeroFieldsBase), sizeof(MockZeroFieldsBase)); - GOOGLE_ABSL_CHECK_EQ(sizeof(internal::ExtensionSet), sizeof(MockExtensionSet)); - GOOGLE_ABSL_CHECK_EQ(sizeof(RepeatedPtrField), + ABSL_CHECK_EQ(sizeof(MessageLite), sizeof(MockMessageBase)); + ABSL_CHECK_EQ(sizeof(Message), sizeof(MockMessageBase)); + ABSL_CHECK_EQ(sizeof(internal::ZeroFieldsBase), sizeof(MockZeroFieldsBase)); + ABSL_CHECK_EQ(sizeof(internal::ExtensionSet), sizeof(MockExtensionSet)); + ABSL_CHECK_EQ(sizeof(RepeatedPtrField), sizeof(MockRepeatedPtrField)); - GOOGLE_ABSL_CHECK_EQ(sizeof(RepeatedField), sizeof(MockRepeatedField)); + ABSL_CHECK_EQ(sizeof(RepeatedField), sizeof(MockRepeatedField)); } TEST(GeneratedMessageTest, EmptyMessageSize) { @@ -111,7 +111,7 @@ TEST(GeneratedMessageTest, EmptyMessageWithExtensionsSize) { int cached_size; // 4 bytes // + 4 bytes of padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); EXPECT_EQ(sizeof(protobuf_unittest::TestEmptyMessageWithExtensions), sizeof(MockGenerated)); } @@ -124,7 +124,7 @@ TEST(GeneratedMessageTest, RecursiveMessageSize) { int32_t i; // 4 bytes // + 4 bytes padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 40); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 40); EXPECT_EQ(sizeof(protobuf_unittest::TestRecursiveMessage), sizeof(MockGenerated)); } @@ -135,7 +135,7 @@ TEST(GeneratedMessageTest, OneStringSize) { int cached_size; // 4 bytes void* data; // 8 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::OneString), sizeof(MockGenerated)); } @@ -145,7 +145,7 @@ TEST(GeneratedMessageTest, MoreStringSize) { MockRepeatedPtrField data; // 24 bytes // + 4 bytes padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); EXPECT_EQ(sizeof(protobuf_unittest::MoreString), sizeof(MockGenerated)); } @@ -156,7 +156,7 @@ TEST(GeneratedMessageTest, Int32MessageSize) { int32_t data; // 4 bytes // + 4 bytes padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::Int32Message), sizeof(MockGenerated)); } @@ -166,7 +166,7 @@ TEST(GeneratedMessageTest, Int64MessageSize) { int cached_size; // 4 bytes int64_t data; // 8 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::Int64Message), sizeof(MockGenerated)); } @@ -177,7 +177,7 @@ TEST(GeneratedMessageTest, BoolMessageSize) { bool data; // 1 byte // + 3 bytes padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::BoolMessage), sizeof(MockGenerated)); } @@ -187,7 +187,7 @@ TEST(GeneratedMessageTest, OneofSize) { int cached_size; // 4 bytes uint32_t oneof_case[1]; // 4 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::TestOneof), sizeof(MockGenerated)); } @@ -202,7 +202,7 @@ TEST(GeneratedMessageTest, Oneof2Size) { void* bar; // 8 bytes uint32_t oneof_case[2]; // 8 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 64); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 64); EXPECT_EQ(sizeof(protobuf_unittest::TestOneof2), sizeof(MockGenerated)); } @@ -217,7 +217,7 @@ TEST(GeneratedMessageTest, FieldOrderingsSize) { float my_float; // 4 bytes // + 4 bytes of padding }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 80); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 80); EXPECT_EQ(sizeof(protobuf_unittest::TestFieldOrderings), sizeof(MockGenerated)); } @@ -234,7 +234,7 @@ TEST(GeneratedMessageTest, TestMessageSize) { int m5; // 4 bytes int64_t m6; // 8 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 56); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 56); EXPECT_EQ(sizeof(protobuf_unittest::TestMessageSize), sizeof(MockGenerated)); } @@ -263,7 +263,7 @@ TEST(GeneratedMessageTest, PackedTypesSize) { int packed_enum_cached_byte_size; // 4 bytes int cached_size; // 4 bytes }; - GOOGLE_ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8); + ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8); EXPECT_EQ(sizeof(protobuf_unittest::TestPackedTypes), sizeof(MockGenerated)); } diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc index 51df3d5bfdfa..8f97e0c2e0aa 100644 --- a/src/google/protobuf/compiler/cpp/metadata_test.cc +++ b/src/google/protobuf/compiler/cpp/metadata_test.cc @@ -37,7 +37,7 @@ #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/compiler/annotation_test_util.h" #include "google/protobuf/compiler/cpp/helpers.h" @@ -79,12 +79,12 @@ class CppMetadataTest : public ::testing::Test { absl::StrCat(TestTempDir(), "/", StripProto(filename)); if (pb_cc != nullptr) { - GOOGLE_ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".pb.cc"), + ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".pb.cc"), pb_cc, true)); } if (pb_h != nullptr && pb_h_info != nullptr) { - GOOGLE_ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".pb.h"), pb_h, + ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".pb.h"), pb_h, true)); if (!atu::DecodeMetadata(absl::StrCat(output_base, ".pb.h.meta"), pb_h_info)) { @@ -93,7 +93,7 @@ class CppMetadataTest : public ::testing::Test { } if (proto_h != nullptr && proto_h_info != nullptr) { - GOOGLE_ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".proto.h"), + ABSL_CHECK_OK(File::GetContents(absl::StrCat(output_base, ".proto.h"), proto_h, true)); if (!atu::DecodeMetadata(absl::StrCat(output_base, ".proto.h.meta"), proto_h_info)) { diff --git a/src/google/protobuf/compiler/cpp/padding_optimizer.cc b/src/google/protobuf/compiler/cpp/padding_optimizer.cc index 4ababbf08804..3746bb555f2c 100644 --- a/src/google/protobuf/compiler/cpp/padding_optimizer.cc +++ b/src/google/protobuf/compiler/cpp/padding_optimizer.cc @@ -30,7 +30,7 @@ #include "google/protobuf/compiler/cpp/padding_optimizer.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "google/protobuf/compiler/cpp/helpers.h" namespace google { @@ -138,7 +138,7 @@ static void OptimizeLayoutHelper(std::vector* fields, aligned_to_8[f].push_back(FieldGroup(j, field)); break; default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown alignment size " + ABSL_LOG(FATAL) << "Unknown alignment size " << EstimateAlignmentSize(field) << "for a field " << field->full_name() << "."; } diff --git a/src/google/protobuf/compiler/cpp/parse_function_generator.cc b/src/google/protobuf/compiler/cpp/parse_function_generator.cc index cf144aba4c30..7e93fcd6c2b3 100644 --- a/src/google/protobuf/compiler/cpp/parse_function_generator.cc +++ b/src/google/protobuf/compiler/cpp/parse_function_generator.cc @@ -37,7 +37,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/generated_message_tctable_gen.h" @@ -202,7 +202,7 @@ bool ParseFunctionGenerator::should_generate_tctable() const { } void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) { - GOOGLE_ABSL_CHECK(should_generate_tctable()); + ABSL_CHECK(should_generate_tctable()); // Generate an `_InternalParse` that starts the tail-calling loop. format( @@ -229,7 +229,7 @@ static bool NeedsUnknownEnumSupport(const Descriptor* descriptor) { void ParseFunctionGenerator::GenerateTailcallFallbackFunction( Formatter& format) { - GOOGLE_ABSL_CHECK(should_generate_tctable()); + ABSL_CHECK(should_generate_tctable()); format( "const char* $classname$::Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL) {\n" "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr\n"); @@ -421,7 +421,7 @@ static NumToEntryTable MakeNumToEntryTable( for (; field_entry_index != N; ++field_entry_index) { auto* field_descriptor = field_descriptors[field_entry_index]; uint32_t fnum = field_descriptor->number(); - GOOGLE_ABSL_CHECK_GT(fnum, last_skip_entry_start); + ABSL_CHECK_GT(fnum, last_skip_entry_start); if (start_new_block == false) { // If the next field number is within 15 of the last_skip_entry_start, we // continue writing just to that entry. If it's between 16 and 31 more, @@ -454,7 +454,7 @@ static NumToEntryTable MakeNumToEntryTable( } void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { - GOOGLE_ABSL_CHECK(should_generate_tctable()); + ABSL_CHECK(should_generate_tctable()); // All entries without a fast-path parsing function need a fallback. std::string fallback; if (tc_table_info_->use_generated_fallback) { @@ -565,7 +565,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { format("65535, 65535\n"); } if (ordered_fields_.empty()) { - GOOGLE_ABSL_LOG_IF(DFATAL, !tc_table_info_->aux_entries.empty()) + ABSL_DLOG_IF(FATAL, !tc_table_info_->aux_entries.empty()) << "Invalid message: " << descriptor_->full_name() << " has " << tc_table_info_->aux_entries.size() << " auxiliary field entries, but no fields"; @@ -662,7 +662,7 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) { format("{$1$, {$2$, $3$}},\n", info.func_name, info.coded_tag, info.nonfield_info); } else { - GOOGLE_ABSL_CHECK(!ShouldSplit(info.field, options_)); + ABSL_CHECK(!ShouldSplit(info.field, options_)); std::string func_name = info.func_name; if (GetOptimizeFor(info.field->file(), options_) == FileOptions::SPEED) { @@ -731,7 +731,7 @@ static void FormatFieldKind(Formatter& format, PROTOBUF_INTERNAL_TYPE_CARD_CASE(RawString); PROTOBUF_INTERNAL_TYPE_CARD_CASE(Utf8String); default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card; + ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card; } static constexpr const char* kRepNames[] = {"AString", "IString", "Cord", @@ -814,7 +814,7 @@ static void FormatFieldKind(Formatter& format, PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedSInt64); PROTOBUF_INTERNAL_TYPE_CARD_CASE(PackedDouble); default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card; + ABSL_LOG(FATAL) << "Unknown type_card: 0x" << type_card; } } } @@ -907,13 +907,13 @@ void ParseFunctionGenerator::GenerateArenaString(Formatter& format, "if (arena != nullptr) {\n" " ptr = ctx->ReadArenaString(ptr, &$msg$$field$, arena"); if (IsStringInlined(field, options_)) { - GOOGLE_ABSL_DCHECK(!inlined_string_indices_.empty()); + ABSL_DCHECK(!inlined_string_indices_.empty()); int inlined_string_index = inlined_string_indices_[field->index()]; - GOOGLE_ABSL_DCHECK_GT(inlined_string_index, 0); + ABSL_DCHECK_GT(inlined_string_index, 0); format(", &$msg$$inlined_string_donated_array$[0], $1$, $this$", inlined_string_index); } else { - GOOGLE_ABSL_DCHECK(field->default_value_string().empty()); + ABSL_DCHECK(field->default_value_string().empty()); } format( ");\n" @@ -1026,7 +1026,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, case FieldDescriptor::TYPE_MESSAGE: { if (field->is_map()) { const FieldDescriptor* val = field->message_type()->map_value(); - GOOGLE_ABSL_CHECK(val); + ABSL_CHECK(val); if (val->type() == FieldDescriptor::TYPE_ENUM && !internal::cpp::HasPreservingUnknownEnumSemantics(field)) { format( @@ -1114,7 +1114,7 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, break; } default: - GOOGLE_ABSL_LOG(FATAL) << "Illegal combination for length delimited wiretype " + ABSL_LOG(FATAL) << "Illegal combination for length delimited wiretype " << " filed type is " << field->type(); } } @@ -1229,7 +1229,7 @@ void ParseFunctionGenerator::GenerateFieldBody( break; } case WireFormatLite::WIRETYPE_END_GROUP: { - GOOGLE_ABSL_LOG(FATAL) << "Can't have end group field\n"; + ABSL_LOG(FATAL) << "Can't have end group field\n"; break; } } // switch (wire_type) @@ -1243,7 +1243,7 @@ static uint32_t ExpectedTag(const FieldDescriptor* field, if (field->is_packable()) { auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); - GOOGLE_ABSL_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + ABSL_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; uint32_t fallback_tag = WireFormatLite::MakeTag(field->number(), fallback_wiretype); diff --git a/src/google/protobuf/compiler/cpp/plugin_unittest.cc b/src/google/protobuf/compiler/cpp/plugin_unittest.cc index 360650524998..f1df83963ca3 100644 --- a/src/google/protobuf/compiler/cpp/plugin_unittest.cc +++ b/src/google/protobuf/compiler/cpp/plugin_unittest.cc @@ -42,7 +42,7 @@ #include "google/protobuf/compiler/command_line_interface.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -172,7 +172,7 @@ class TestGenerator : public CodeGenerator { // not verify that they are correctly-placed; that would require actually // compiling the output which is a bit more than I care to do for this test. TEST(CppPluginTest, PluginTest) { - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::SetContents(absl::StrCat(TestTempDir(), "/test.proto"), "syntax = \"proto2\";\n" "package foo;\n" diff --git a/src/google/protobuf/compiler/cpp/service.cc b/src/google/protobuf/compiler/cpp/service.cc index bd4b121bc4c2..329a7eb8fe60 100644 --- a/src/google/protobuf/compiler/cpp/service.cc +++ b/src/google/protobuf/compiler/cpp/service.cc @@ -212,12 +212,12 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { ::$proto_ns$::RpcController* controller, const ::$proto_ns$::Message* request, ::$proto_ns$::Message* response, ::google::protobuf::Closure* done) { - GOOGLE_ABSL_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$index$]); + ABSL_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$index$]); switch (method->index()) { $cases$; default: - GOOGLE_ABSL_LOG(FATAL) << "Bad method index; this should never happen."; + ABSL_LOG(FATAL) << "Bad method index; this should never happen."; break; } } @@ -253,12 +253,12 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, R"cc( const ::$proto_ns$::Message& $classname$::Get$which$Prototype( const ::$proto_ns$::MethodDescriptor* method) const { - GOOGLE_ABSL_DCHECK_EQ(method->service(), descriptor()); + ABSL_DCHECK_EQ(method->service(), descriptor()); switch (method->index()) { $cases$; default: - GOOGLE_ABSL_LOG(FATAL) << "Bad method index; this should never happen."; + ABSL_LOG(FATAL) << "Bad method index; this should never happen."; return *::$proto_ns$::MessageFactory::generated_factory() ->GetPrototype(method->$which_type$_type()); } diff --git a/src/google/protobuf/compiler/cpp/tracker.cc b/src/google/protobuf/compiler/cpp/tracker.cc index 003c0cdd53be..db9fbe225ad8 100644 --- a/src/google/protobuf/compiler/cpp/tracker.cc +++ b/src/google/protobuf/compiler/cpp/tracker.cc @@ -253,7 +253,7 @@ Getters StringFieldGetters(const FieldDescriptor* field, const Options& opts) { Getters StringOneofGetters(const FieldDescriptor* field, const OneofDescriptor* oneof, const Options& opts) { - GOOGLE_ABSL_CHECK(oneof != nullptr); + ABSL_CHECK(oneof != nullptr); std::string member = FieldMemberName(field, ShouldSplit(field, opts)); bool is_std_string = field->options().ctype() == FieldOptions::STRING; diff --git a/src/google/protobuf/compiler/cpp/unittest.inc b/src/google/protobuf/compiler/cpp/unittest.inc index 94b3f557df6e..f9499127e0a0 100644 --- a/src/google/protobuf/compiler/cpp/unittest.inc +++ b/src/google/protobuf/compiler/cpp/unittest.inc @@ -1331,7 +1331,7 @@ TEST_F(GENERATED_SERVICE_TEST_NAME, CallMethod) { TEST_F(GENERATED_SERVICE_TEST_NAME, CallMethodTypeFailure) { // Verify death if we call Foo() with Bar's message types. -#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet EXPECT_DEBUG_DEATH( mock_service_.CallMethod(foo_, &mock_controller_, &foo_request_, &bar_response_, done_.get()), @@ -1342,7 +1342,7 @@ TEST_F(GENERATED_SERVICE_TEST_NAME, CallMethodTypeFailure) { mock_service_.CallMethod(foo_, &mock_controller_, &bar_request_, &foo_response_, done_.get()), "dynamic_cast"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST_F(GENERATED_SERVICE_TEST_NAME, GetPrototypes) { diff --git a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc index 93180b725012..82649d6a32a1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc @@ -83,7 +83,7 @@ class MockGeneratorContext : public GeneratorContext { std::string expected_contents = *it->second; std::string actual_contents; - GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText( + ABSL_CHECK_OK(File::GetContentsAsText( absl::StrCat(TestSourceDir(), "/", physical_filename), &actual_contents, true)) << "Unable to get " << physical_filename; diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 6cf7b7c3bf09..ce9b28d3a74d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -35,7 +35,7 @@ #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" @@ -79,7 +79,7 @@ void EnumGenerator::Generate(io::Printer* printer) { // Make sure we don't get any duplicate names due to prefix removal. while (!used_names.insert(name).second) { // It's possible we'll end up giving this warning multiple times, but that's better than not at all. - GOOGLE_ABSL_LOG(WARNING) << "Duplicate enum value " << name << " (originally " + ABSL_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name << ") in " << descriptor_->name() << "; adding underscore to distinguish"; absl::StrAppend(&name, "_"); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 02f8043cd757..271d69f8b4ee 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -36,7 +36,7 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/names.h" #include "google/protobuf/descriptor.h" @@ -279,7 +279,7 @@ std::string FieldGeneratorBase::type_name(const FieldDescriptor* descriptor) { case FieldDescriptor::TYPE_SINT64: return "long"; default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown field type."; + ABSL_LOG(FATAL) << "Unknown field type."; return ""; } } @@ -321,7 +321,7 @@ bool FieldGeneratorBase::has_default_value() { case FieldDescriptor::TYPE_SINT64: return descriptor_->default_value_int64() != 0L; default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown field type."; + ABSL_LOG(FATAL) << "Unknown field type."; return true; } } @@ -425,7 +425,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) case FieldDescriptor::TYPE_SINT64: return absl::StrCat(descriptor->default_value_int64(), "L"); default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown field type."; + ABSL_LOG(FATAL) << "Unknown field type."; return ""; } } @@ -473,7 +473,7 @@ std::string FieldGeneratorBase::capitalized_type_name() { case FieldDescriptor::TYPE_SINT64: return "SInt64"; default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown field type."; + ABSL_LOG(FATAL) << "Unknown field type."; return ""; } } diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 8ac93cc7aa47..a08c1be0841b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -41,7 +41,7 @@ #include #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" @@ -108,7 +108,7 @@ CSharpType GetCSharpType(FieldDescriptor::Type type) { // No default because we want the compiler to complain if any new // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return (CSharpType) -1; } @@ -340,7 +340,7 @@ int GetFixedSize(FieldDescriptor::Type type) { // No default because we want the compiler to complain if any new // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return -1; } @@ -465,7 +465,7 @@ bool IsNullable(const FieldDescriptor* descriptor) { return true; default: - GOOGLE_ABSL_LOG(FATAL) << "Unknown field type."; + ABSL_LOG(FATAL) << "Unknown field type."; return true; } } diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 6619ca982779..fd69874536cf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -35,7 +35,7 @@ #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_enum.h" @@ -767,7 +767,7 @@ int MessageGenerator::GetPresenceIndex(const FieldDescriptor* descriptor) { index++; } } - GOOGLE_ABSL_LOG(DFATAL) << "Could not find presence index for field " + ABSL_DLOG(FATAL) << "Could not find presence index for field " << descriptor->name(); return -1; } diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h index 83f05048e616..742a634cd77d 100644 --- a/src/google/protobuf/compiler/importer.h +++ b/src/google/protobuf/compiler/importer.h @@ -222,7 +222,7 @@ class PROTOBUF_EXPORT MultiFileErrorCollector { ABSL_DEPRECATED("Use RecordError") virtual void AddError(const std::string& filename, int line, int column, const std::string& message) { - GOOGLE_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; + ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; } ABSL_DEPRECATED("Use RecordWarning") diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc index 026dca08be32..d1adb4e8b4d4 100644 --- a/src/google/protobuf/compiler/importer_unittest.cc +++ b/src/google/protobuf/compiler/importer_unittest.cc @@ -43,7 +43,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/substitute.h" @@ -269,7 +269,7 @@ class DiskSourceTreeTest : public testing::Test { if (FileExists(dirnames_[i])) { File::DeleteRecursively(dirnames_[i], NULL, NULL); } - GOOGLE_ABSL_CHECK_OK(File::CreateDir(dirnames_[i], 0777)); + ABSL_CHECK_OK(File::CreateDir(dirnames_[i], 0777)); } } @@ -282,11 +282,11 @@ class DiskSourceTreeTest : public testing::Test { } void AddFile(const std::string& filename, const char* contents) { - GOOGLE_ABSL_CHECK_OK(File::SetContents(filename, contents, true)); + ABSL_CHECK_OK(File::SetContents(filename, contents, true)); } void AddSubdir(const std::string& dirname) { - GOOGLE_ABSL_CHECK_OK(File::CreateDir(dirname, 0777)); + ABSL_CHECK_OK(File::CreateDir(dirname, 0777)); } void ExpectFileContents(const std::string& filename, @@ -400,7 +400,7 @@ TEST_F(DiskSourceTreeTest, OrderingTrumpsSpecificity) { // directory is more-specific than a former one. // Create the "bar" directory so we can put a file in it. - GOOGLE_ABSL_CHECK_OK(File::CreateDir(absl::StrCat(dirnames_[0], "/bar"), + ABSL_CHECK_OK(File::CreateDir(absl::StrCat(dirnames_[0], "/bar"), 0777)); // Add files and map paths. diff --git a/src/google/protobuf/compiler/java/context.cc b/src/google/protobuf/compiler/java/context.cc index 35178c1264ba..01d75b95fc4e 100644 --- a/src/google/protobuf/compiler/java/context.cc +++ b/src/google/protobuf/compiler/java/context.cc @@ -32,7 +32,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" @@ -159,7 +159,7 @@ void Context::InitializeFieldGeneratorInfoForFields( } } if (is_conflict[i]) { - GOOGLE_ABSL_LOG(WARNING) << "field \"" << field->full_name() + ABSL_LOG(WARNING) << "field \"" << field->full_name() << "\" is conflicting " << "with another field: " << conflict_reason[i]; } @@ -184,7 +184,7 @@ const FieldGeneratorInfo* Context::GetFieldGeneratorInfo( const FieldDescriptor* field) const { auto it = field_generator_info_map_.find(field); if (it == field_generator_info_map_.end()) { - GOOGLE_ABSL_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: " + ABSL_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: " << field->full_name(); } return &it->second; @@ -194,7 +194,7 @@ const OneofGeneratorInfo* Context::GetOneofGeneratorInfo( const OneofDescriptor* oneof) const { auto it = oneof_generator_info_map_.find(oneof); if (it == oneof_generator_info_map_.end()) { - GOOGLE_ABSL_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: " + ABSL_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: " << oneof->name(); } return &it->second; diff --git a/src/google/protobuf/compiler/java/enum_field.cc b/src/google/protobuf/compiler/java/enum_field.cc index 528220ca539a..59d56d4a35ab 100644 --- a/src/google/protobuf/compiler/java/enum_field.cc +++ b/src/google/protobuf/compiler/java/enum_field.cc @@ -38,8 +38,8 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" @@ -345,7 +345,7 @@ void ImmutableEnumFieldGenerator::GenerateMergingCode( " set$capitalized_name$Value(other.get$capitalized_name$Value());\n" "}\n"); } else { - GOOGLE_ABSL_LOG(FATAL) << "Can't reach here."; + ABSL_LOG(FATAL) << "Can't reach here."; } } @@ -429,7 +429,7 @@ ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {} void ImmutableEnumOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" @@ -464,7 +464,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" diff --git a/src/google/protobuf/compiler/java/enum_field_lite.cc b/src/google/protobuf/compiler/java/enum_field_lite.cc index c15e5e765d02..fc3cb1fa3f2a 100644 --- a/src/google/protobuf/compiler/java/enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/enum_field_lite.cc @@ -38,7 +38,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "google/protobuf/compiler/java/context.h" @@ -400,7 +400,7 @@ ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {} void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" @@ -476,7 +476,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" diff --git a/src/google/protobuf/compiler/java/field.cc b/src/google/protobuf/compiler/java/field.cc index d3f34951a2e3..552906daffe2 100644 --- a/src/google/protobuf/compiler/java/field.cc +++ b/src/google/protobuf/compiler/java/field.cc @@ -38,7 +38,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/substitute.h" #include "google/protobuf/compiler/java/context.h" @@ -186,7 +186,7 @@ static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) { // but this method should be overridden. // - This FieldGenerator doesn't support packing, and this method // should never have been called. - GOOGLE_ABSL_LOG(FATAL) << "GenerateBuilderParsingCodeFromPacked() " + ABSL_LOG(FATAL) << "GenerateBuilderParsingCodeFromPacked() " << "called on field generator that does not support packing."; } diff --git a/src/google/protobuf/compiler/java/field.h b/src/google/protobuf/compiler/java/field.h index a7ecc2d60048..79e2053e9c76 100644 --- a/src/google/protobuf/compiler/java/field.h +++ b/src/google/protobuf/compiler/java/field.h @@ -40,7 +40,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/port.h" @@ -135,7 +135,7 @@ class FieldGeneratorMap { template inline const FieldGeneratorType& FieldGeneratorMap::get( const FieldDescriptor* field) const { - GOOGLE_ABSL_CHECK_EQ(field->containing_type(), descriptor_); + ABSL_CHECK_EQ(field->containing_type(), descriptor_); return *field_generators_[field->index()]; } diff --git a/src/google/protobuf/compiler/java/file.cc b/src/google/protobuf/compiler/java/file.cc index c2be5e23a51c..e90bbfe6a008 100644 --- a/src/google/protobuf/compiler/java/file.cc +++ b/src/google/protobuf/compiler/java/file.cc @@ -38,7 +38,7 @@ #include #include "absl/container/btree_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/java/context.h" @@ -133,7 +133,7 @@ void CollectExtensions(const FileDescriptorProto& file_proto, // builder-pool to find out all extensions. const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName( file_proto.GetDescriptor()->full_name()); - GOOGLE_ABSL_CHECK(file_proto_desc) + ABSL_CHECK(file_proto_desc) << "Find unknown fields in FileDescriptorProto when building " << file_proto.name() << ". It's likely that those fields are custom options, however, " @@ -142,14 +142,14 @@ void CollectExtensions(const FileDescriptorProto& file_proto, DynamicMessageFactory factory; std::unique_ptr dynamic_file_proto( factory.GetPrototype(file_proto_desc)->New()); - GOOGLE_ABSL_CHECK(dynamic_file_proto.get() != NULL); - GOOGLE_ABSL_CHECK(dynamic_file_proto->ParseFromString(file_data)); + ABSL_CHECK(dynamic_file_proto.get() != NULL); + ABSL_CHECK(dynamic_file_proto->ParseFromString(file_data)); // Collect the extensions again from the dynamic message. There should be no // more unknown fields this time, i.e. all the custom options should be // parsed as extensions now. extensions->clear(); - GOOGLE_ABSL_CHECK(CollectExtensions(*dynamic_file_proto, extensions)) + ABSL_CHECK(CollectExtensions(*dynamic_file_proto, extensions)) << "Find unknown fields in FileDescriptorProto when building " << file_proto.name() << ". It's likely that those fields are custom options, however, " @@ -234,7 +234,7 @@ bool FileGenerator::Validate(std::string* error) { // because filenames are case-insensitive on those platforms. if (name_resolver_->HasConflictingClassName( file_, classname_, NameEquality::EQUAL_IGNORE_CASE)) { - GOOGLE_ABSL_LOG(WARNING) + ABSL_LOG(WARNING) << file_->name() << ": The file's outer class name, \"" << classname_ << "\", matches the name of one of the types declared inside it when " << "case is ignored. This can cause compilation issues on Windows / " @@ -246,7 +246,7 @@ bool FileGenerator::Validate(std::string* error) { // Print a warning if optimize_for = LITE_RUNTIME is used. if (file_->options().optimize_for() == FileOptions::LITE_RUNTIME && !options_.enforce_lite) { - GOOGLE_ABSL_LOG(WARNING) + ABSL_LOG(WARNING) << "The optimize_for = LITE_RUNTIME option is no longer supported by " << "protobuf Java code generator and is ignored--protoc will always " << "generate full runtime code for Java. To use Java Lite runtime, " diff --git a/src/google/protobuf/compiler/java/helpers.cc b/src/google/protobuf/compiler/java/helpers.cc index ab4dec6c03aa..8c3784d2e686 100644 --- a/src/google/protobuf/compiler/java/helpers.cc +++ b/src/google/protobuf/compiler/java/helpers.cc @@ -40,8 +40,8 @@ #include #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -108,7 +108,7 @@ void PrintEnumVerifierLogic( std::string UnderscoresToCamelCase(absl::string_view input, bool cap_next_letter) { - GOOGLE_ABSL_CHECK(!input.empty()); + ABSL_CHECK(!input.empty()); std::string result; // Note: I distrust ctype.h due to locales. for (int i = 0; i < input.size(); i++) { @@ -287,7 +287,7 @@ JavaType GetJavaType(const FieldDescriptor* field) { // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return JAVATYPE_INT; } @@ -316,7 +316,7 @@ absl::string_view PrimitiveTypeName(JavaType type) { // JavaTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return {}; } @@ -349,7 +349,7 @@ absl::string_view BoxedPrimitiveTypeName(JavaType type) { // JavaTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return {}; } @@ -382,7 +382,7 @@ absl::string_view KotlinTypeName(JavaType type) { // JavaTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return {}; } @@ -441,7 +441,7 @@ absl::string_view FieldTypeName(FieldDescriptor::Type field_type) { // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return {}; } @@ -532,7 +532,7 @@ std::string DefaultValue(const FieldDescriptor* field, bool immutable, // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return ""; } @@ -564,7 +564,7 @@ bool IsDefaultValueJavaDefault(const FieldDescriptor* field) { // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return false; } @@ -671,7 +671,7 @@ bool IsReferenceType(JavaType type) { // JavaTypes are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return false; } @@ -720,7 +720,7 @@ absl::string_view GetCapitalizedType(const FieldDescriptor* field, // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return {}; } @@ -770,7 +770,7 @@ int FixedSize(FieldDescriptor::Type type) { // No default because we want the compiler to complain if any new // types are added. } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return -1; } @@ -906,7 +906,7 @@ int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) { } else if (result > FieldDescriptor::TYPE_BYTES) { return result + 30; } else { - GOOGLE_ABSL_LOG(FATAL) << field->full_name() << " can't be packed."; + ABSL_LOG(FATAL) << field->full_name() << " can't be packed."; return 0; } } diff --git a/src/google/protobuf/compiler/java/map_field.cc b/src/google/protobuf/compiler/java/map_field.cc index ad820511249c..13354c4ad642 100644 --- a/src/google/protobuf/compiler/java/map_field.cc +++ b/src/google/protobuf/compiler/java/map_field.cc @@ -48,16 +48,16 @@ namespace java { namespace { const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); - GOOGLE_ABSL_CHECK(message->options().map_entry()); + ABSL_CHECK(message->options().map_entry()); return message->map_key(); } const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); - GOOGLE_ABSL_CHECK(message->options().map_entry()); + ABSL_CHECK(message->options().map_entry()); return message->map_value(); } diff --git a/src/google/protobuf/compiler/java/map_field_lite.cc b/src/google/protobuf/compiler/java/map_field_lite.cc index 87970ef65e07..ca4091a5abcc 100644 --- a/src/google/protobuf/compiler/java/map_field_lite.cc +++ b/src/google/protobuf/compiler/java/map_field_lite.cc @@ -50,16 +50,16 @@ namespace java { namespace { const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); - GOOGLE_ABSL_CHECK(message->options().map_entry()); + ABSL_CHECK(message->options().map_entry()); return message->map_key(); } const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); - GOOGLE_ABSL_CHECK(message->options().map_entry()); + ABSL_CHECK(message->options().map_entry()); return message->map_value(); } diff --git a/src/google/protobuf/compiler/java/message.cc b/src/google/protobuf/compiler/java/message.cc index 2b249ad92a55..1bd7449741dc 100644 --- a/src/google/protobuf/compiler/java/message.cc +++ b/src/google/protobuf/compiler/java/message.cc @@ -73,7 +73,7 @@ namespace { std::string MapValueImmutableClassdName(const Descriptor* descriptor, ClassNameResolver* name_resolver) { const FieldDescriptor* value_field = descriptor->map_value(); - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); return name_resolver->GetImmutableClassName(value_field->message_type()); } } // namespace @@ -85,7 +85,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor) for (int i = 0; i < descriptor_->field_count(); i++) { if (IsRealOneof(descriptor_->field(i))) { const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof(); - GOOGLE_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); + ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); } } } @@ -99,7 +99,7 @@ ImmutableMessageGenerator::ImmutableMessageGenerator( context_(context), name_resolver_(context->GetNameResolver()), field_generators_(descriptor, context_) { - GOOGLE_ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite())) + ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A non-lite message generator is used to " "generate lite messages."; } diff --git a/src/google/protobuf/compiler/java/message_builder.cc b/src/google/protobuf/compiler/java/message_builder.cc index b6caea648a14..7a88ebfccbd2 100644 --- a/src/google/protobuf/compiler/java/message_builder.cc +++ b/src/google/protobuf/compiler/java/message_builder.cc @@ -70,7 +70,7 @@ namespace { std::string MapValueImmutableClassdName(const Descriptor* descriptor, ClassNameResolver* name_resolver) { const FieldDescriptor* value_field = descriptor->map_value(); - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); + ABSL_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); return name_resolver->GetImmutableClassName(value_field->message_type()); } } // namespace @@ -81,13 +81,13 @@ MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor, context_(context), name_resolver_(context->GetNameResolver()), field_generators_(descriptor, context_) { - GOOGLE_ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite())) + ABSL_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A non-lite message generator is used to " "generate lite messages."; for (int i = 0; i < descriptor_->field_count(); i++) { if (IsRealOneof(descriptor_->field(i))) { const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof(); - GOOGLE_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); + ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); } } } diff --git a/src/google/protobuf/compiler/java/message_builder_lite.cc b/src/google/protobuf/compiler/java/message_builder_lite.cc index 4fbe45b7c068..5c2173a077e4 100644 --- a/src/google/protobuf/compiler/java/message_builder_lite.cc +++ b/src/google/protobuf/compiler/java/message_builder_lite.cc @@ -68,13 +68,13 @@ MessageBuilderLiteGenerator::MessageBuilderLiteGenerator( context_(context), name_resolver_(context->GetNameResolver()), field_generators_(descriptor, context_) { - GOOGLE_ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) + ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A lite message generator is used to " "generate non-lite messages."; for (int i = 0; i < descriptor_->field_count(); i++) { if (IsRealOneof(descriptor_->field(i))) { const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof(); - GOOGLE_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); + ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); } } } diff --git a/src/google/protobuf/compiler/java/message_field.cc b/src/google/protobuf/compiler/java/message_field.cc index 6c6c99d38b49..5fd8b6678def 100644 --- a/src/google/protobuf/compiler/java/message_field.cc +++ b/src/google/protobuf/compiler/java/message_field.cc @@ -36,7 +36,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" diff --git a/src/google/protobuf/compiler/java/message_lite.cc b/src/google/protobuf/compiler/java/message_lite.cc index a2e3ac295c35..02506bace4f2 100644 --- a/src/google/protobuf/compiler/java/message_lite.cc +++ b/src/google/protobuf/compiler/java/message_lite.cc @@ -76,13 +76,13 @@ ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator( context_(context), name_resolver_(context->GetNameResolver()), field_generators_(descriptor, context_) { - GOOGLE_ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) + ABSL_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite())) << "Generator factory error: A lite message generator is used to " "generate non-lite messages."; for (int i = 0; i < descriptor_->field_count(); i++) { if (IsRealOneof(descriptor_->field(i))) { const OneofDescriptor* oneof = descriptor_->field(i)->containing_oneof(); - GOOGLE_ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); + ABSL_CHECK(oneofs_.emplace(oneof->index(), oneof).first->second == oneof); } } } diff --git a/src/google/protobuf/compiler/java/message_serialization_unittest.cc b/src/google/protobuf/compiler/java/message_serialization_unittest.cc index fc8f2bf8158e..9a7a6964feeb 100644 --- a/src/google/protobuf/compiler/java/message_serialization_unittest.cc +++ b/src/google/protobuf/compiler/java/message_serialization_unittest.cc @@ -38,7 +38,7 @@ #include #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/command_line_interface.h" @@ -77,10 +77,10 @@ int CompileJavaProto(std::string proto_file_name) { } TEST(MessageSerializationTest, CollapseAdjacentExtensionRanges) { - GOOGLE_ABSL_CHECK_EQ(CompileJavaProto("message_serialization_unittest.proto"), 0); + ABSL_CHECK_EQ(CompileJavaProto("message_serialization_unittest.proto"), 0); std::string java_source; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( // Open-source codebase does not support file::JoinPath, so we manually // concatenate instead. absl::StrCat(TestTempDir(), diff --git a/src/google/protobuf/compiler/java/name_resolver.cc b/src/google/protobuf/compiler/java/name_resolver.cc index f070eaecb51d..0017e172a43f 100644 --- a/src/google/protobuf/compiler/java/name_resolver.cc +++ b/src/google/protobuf/compiler/java/name_resolver.cc @@ -32,7 +32,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/ascii.h" #include "absl/strings/str_replace.h" #include "absl/strings/substitute.h" @@ -106,7 +106,7 @@ std::string ClassNameWithoutPackage(const ServiceDescriptor* descriptor, absl::string_view full_name = StripPackageName(descriptor->full_name(), descriptor->file()); // We don't allow nested service definitions. - GOOGLE_ABSL_CHECK(!absl::StrContains(full_name, '.')); + ABSL_CHECK(!absl::StrContains(full_name, '.')); return std::string(full_name); } diff --git a/src/google/protobuf/compiler/java/plugin_unittest.cc b/src/google/protobuf/compiler/java/plugin_unittest.cc index 5982dc52534c..981affd6cdab 100644 --- a/src/google/protobuf/compiler/java/plugin_unittest.cc +++ b/src/google/protobuf/compiler/java/plugin_unittest.cc @@ -37,7 +37,7 @@ #include "google/protobuf/testing/file.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/command_line_interface.h" #include "google/protobuf/compiler/java/generator.h" @@ -81,7 +81,7 @@ class TestGenerator : public CodeGenerator { // not verify that they are correctly-placed; that would require actually // compiling the output which is a bit more than I care to do for this test. TEST(JavaPluginTest, PluginTest) { - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::SetContents(absl::StrCat(TestTempDir(), "/test.proto"), "syntax = \"proto2\";\n" "package foo;\n" @@ -114,7 +114,7 @@ TEST(JavaPluginTest, PluginTest) { // expect std::string output; - GOOGLE_ABSL_CHECK_OK(File::GetContents(absl::StrCat(TestTempDir(), "/Test.java"), + ABSL_CHECK_OK(File::GetContents(absl::StrCat(TestTempDir(), "/Test.java"), &output, true)); std::vector lines = absl::StrSplit(output, "\n"); bool found_generated_annotation = false; diff --git a/src/google/protobuf/compiler/java/primitive_field.cc b/src/google/protobuf/compiler/java/primitive_field.cc index 056db0387901..15a1edb46e7a 100644 --- a/src/google/protobuf/compiler/java/primitive_field.cc +++ b/src/google/protobuf/compiler/java/primitive_field.cc @@ -37,8 +37,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" @@ -449,7 +449,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateEqualsCode( case JAVATYPE_ENUM: case JAVATYPE_MESSAGE: default: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; break; } } @@ -500,7 +500,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateHashCode( case JAVATYPE_ENUM: case JAVATYPE_MESSAGE: default: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; break; } } @@ -527,7 +527,7 @@ ImmutablePrimitiveOneofFieldGenerator:: void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" @@ -550,7 +550,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" diff --git a/src/google/protobuf/compiler/java/primitive_field_lite.cc b/src/google/protobuf/compiler/java/primitive_field_lite.cc index 9317c4e91bf6..b7197b89adc6 100644 --- a/src/google/protobuf/compiler/java/primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/primitive_field_lite.cc @@ -37,7 +37,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" @@ -416,7 +416,7 @@ ImmutablePrimitiveOneofFieldLiteGenerator:: void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" @@ -464,7 +464,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" diff --git a/src/google/protobuf/compiler/java/service.cc b/src/google/protobuf/compiler/java/service.cc index 643b035050f9..d2cf0a2082a9 100644 --- a/src/google/protobuf/compiler/java/service.cc +++ b/src/google/protobuf/compiler/java/service.cc @@ -34,7 +34,7 @@ #include "google/protobuf/compiler/java/service.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" diff --git a/src/google/protobuf/compiler/java/string_field.cc b/src/google/protobuf/compiler/java/string_field.cc index ccd16e83ac47..96b8f02e9115 100644 --- a/src/google/protobuf/compiler/java/string_field.cc +++ b/src/google/protobuf/compiler/java/string_field.cc @@ -39,7 +39,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" @@ -522,7 +522,7 @@ ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {} void ImmutableStringOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" @@ -586,7 +586,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" diff --git a/src/google/protobuf/compiler/java/string_field_lite.cc b/src/google/protobuf/compiler/java/string_field_lite.cc index f92952d9bff5..274df5379056 100644 --- a/src/google/protobuf/compiler/java/string_field_lite.cc +++ b/src/google/protobuf/compiler/java/string_field_lite.cc @@ -39,7 +39,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/context.h" #include "google/protobuf/compiler/java/doc_comment.h" @@ -408,7 +408,7 @@ ImmutableStringOneofFieldLiteGenerator:: void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" @@ -486,7 +486,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - GOOGLE_ABSL_DCHECK(HasHazzer(descriptor_)); + ABSL_DCHECK(HasHazzer(descriptor_)); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override\n" diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index dfce4fbe3cd7..ea9adfb1e331 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -28,6 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "absl/log/initialize.h" #include "google/protobuf/compiler/command_line_interface.h" #include "google/protobuf/compiler/cpp/generator.h" #include "google/protobuf/compiler/csharp/csharp_generator.h" @@ -47,6 +48,7 @@ namespace protobuf { namespace compiler { int ProtobufMain(int argc, char* argv[]) { + absl::InitializeLog(); CommandLineInterface cli; cli.AllowPlugins("protoc-"); diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index b32f1a8c5fd1..56184a7b4914 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -45,8 +46,8 @@ #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.pb.h" #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/str_replace.h" @@ -110,7 +111,7 @@ void MockCodeGenerator::ExpectGenerated( absl::string_view first_parsed_file_name, absl::string_view output_directory) { std::string content; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( absl::StrCat(output_directory, "/", GetOutputFileName(name, file)), &content, true)); @@ -169,16 +170,16 @@ void MockCodeGenerator::CheckGeneratedAnnotations( absl::string_view name, absl::string_view file, absl::string_view output_directory) { std::string file_content; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( absl::StrCat(output_directory, "/", GetOutputFileName(name, file)), &file_content, true)); std::string meta_content; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(absl::StrCat(output_directory, "/", GetOutputFileName(name, file), ".pb.meta"), &meta_content, true)); GeneratedCodeInfo annotations; - GOOGLE_ABSL_CHECK(TextFormat::ParseFromString(meta_content, &annotations)); + ABSL_CHECK(TextFormat::ParseFromString(meta_content, &annotations)); ASSERT_EQ(7, annotations.annotation_size()); CheckSingleAnnotation("first_annotation", "first", file_content, @@ -219,40 +220,39 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, if (command == "Error") { *error = "Saw message type MockCodeGenerator_Error."; return false; - } else if (command == "Exit") { + } + if (command == "Exit") { std::cerr << "Saw message type MockCodeGenerator_Exit." << std::endl; exit(123); - } else if (command == "Abort") { - std::cerr << "Saw message type MockCodeGenerator_Abort." << std::endl; - abort(); - } else if (command == "HasSourceCodeInfo") { + } + ABSL_CHECK(command != "Abort") + << "Saw message type MockCodeGenerator_Abort."; + if (command == "HasSourceCodeInfo") { FileDescriptorProto file_descriptor_proto; file->CopySourceCodeInfoTo(&file_descriptor_proto); bool has_source_code_info = file_descriptor_proto.has_source_code_info() && file_descriptor_proto.source_code_info().location_size() > 0; - std::cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: " - << has_source_code_info << "." << std::endl; - abort(); + ABSL_LOG(FATAL) + << "Saw message type MockCodeGenerator_HasSourceCodeInfo: " + << has_source_code_info << "."; } else if (command == "HasJsonName") { FieldDescriptorProto field_descriptor_proto; file->message_type(i)->field(0)->CopyTo(&field_descriptor_proto); - std::cerr << "Saw json_name: " << field_descriptor_proto.has_json_name() - << std::endl; - abort(); + ABSL_LOG(FATAL) << "Saw json_name: " + << field_descriptor_proto.has_json_name(); } else if (command == "Annotate") { annotate = true; } else if (command == "ShowVersionNumber") { Version compiler_version; context->GetCompilerVersion(&compiler_version); - std::cerr << "Saw compiler_version: " - << compiler_version.major() * 1000000 + - compiler_version.minor() * 1000 + - compiler_version.patch() - << " " << compiler_version.suffix() << std::endl; - abort(); + ABSL_LOG(FATAL) << "Saw compiler_version: " + << compiler_version.major() * 1000000 + + compiler_version.minor() * 1000 + + compiler_version.patch() + << " " << compiler_version.suffix(); } else { - GOOGLE_ABSL_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; + ABSL_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; } } } diff --git a/src/google/protobuf/compiler/objectivec/extension.cc b/src/google/protobuf/compiler/objectivec/extension.cc index 821b322bf284..a38d8a661716 100644 --- a/src/google/protobuf/compiler/objectivec/extension.cc +++ b/src/google/protobuf/compiler/objectivec/extension.cc @@ -54,14 +54,9 @@ ExtensionGenerator::ExtensionGenerator(absl::string_view root_class_name, root_class_and_method_name_( absl::StrCat(root_class_name, "_", method_name_)), descriptor_(descriptor) { - if (descriptor->is_map()) { - // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some - // error cases, so it seems to be ok to use as a back door for errors. - std::cerr << "error: Extension is a map<>!" - << " That used to be blocked by the compiler." << std::endl; - std::cerr.flush(); - abort(); - } + ABSL_CHECK(!descriptor->is_map()) + << "error: Extension is a map<>!" + << " That used to be blocked by the compiler."; } void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) const { diff --git a/src/google/protobuf/compiler/objectivec/field.cc b/src/google/protobuf/compiler/objectivec/field.cc index ba5671ed3b57..a898f5de437f 100644 --- a/src/google/protobuf/compiler/objectivec/field.cc +++ b/src/google/protobuf/compiler/objectivec/field.cc @@ -36,8 +36,8 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/enum_field.h" #include "google/protobuf/compiler/objectivec/helpers.h" @@ -169,7 +169,7 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return false; } @@ -289,12 +289,8 @@ void FieldGenerator::SetNoHasBit() { variables_["has_index"] = "GPBNoHasBit"; } int FieldGenerator::ExtraRuntimeHasBitsNeeded() const { return 0; } void FieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) { - // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some - // error cases, so it seems to be ok to use as a back door for errors. - std::cerr << "Error: should have overridden SetExtraRuntimeHasBitsBase()." - << std::endl; - std::cerr.flush(); - abort(); + ABSL_LOG(FATAL) + << "Error: should have overridden SetExtraRuntimeHasBitsBase()."; } void FieldGenerator::SetOneofIndexBase(int index_base) { @@ -478,7 +474,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor) const FieldGenerator& FieldGeneratorMap::get( const FieldDescriptor* field) const { - GOOGLE_ABSL_CHECK_EQ(field->containing_type(), descriptor_); + ABSL_CHECK_EQ(field->containing_type(), descriptor_); return *field_generators_[field->index()]; } diff --git a/src/google/protobuf/compiler/objectivec/helpers.cc b/src/google/protobuf/compiler/objectivec/helpers.cc index cb13b0ed3180..118077f577f1 100644 --- a/src/google/protobuf/compiler/objectivec/helpers.cc +++ b/src/google/protobuf/compiler/objectivec/helpers.cc @@ -33,7 +33,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" @@ -67,7 +67,7 @@ std::string GetZeroEnumNameForFlagType(const FlagType flag_type) { case FLAGTYPE_FIELD: return "GPBFieldNone"; default: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return "0"; } } @@ -81,7 +81,7 @@ std::string GetEnumNameForFlagType(const FlagType flag_type) { case FLAGTYPE_FIELD: return "GPBFieldFlags"; default: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return std::string(); } } @@ -148,7 +148,7 @@ std::string GetCapitalizedType(const FieldDescriptor* field) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return std::string(); } @@ -197,7 +197,7 @@ ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return OBJECTIVECTYPE_INT32; } @@ -236,7 +236,7 @@ std::string GPBGenericValueFieldName(const FieldDescriptor* field) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return std::string(); } @@ -309,7 +309,7 @@ std::string DefaultValue(const FieldDescriptor* field) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return std::string(); } diff --git a/src/google/protobuf/compiler/objectivec/import_writer.cc b/src/google/protobuf/compiler/objectivec/import_writer.cc index 5d41274db4aa..d7ef3b9a3b8a 100644 --- a/src/google/protobuf/compiler/objectivec/import_writer.cc +++ b/src/google/protobuf/compiler/objectivec/import_writer.cc @@ -36,7 +36,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "google/protobuf/compiler/objectivec/line_consumer.h" @@ -197,7 +197,7 @@ void ImportWriter::PrintRuntimeImports(io::Printer* p, // If bundled, no need to do the framework support below. if (for_bundled_proto_) { - GOOGLE_ABSL_DCHECK(!default_cpp_symbol); + ABSL_DCHECK(!default_cpp_symbol); for (const auto& header : protobuf_imports_) { p->Print("#import \"$header$\"\n", "header", header); } diff --git a/src/google/protobuf/compiler/objectivec/map_field.cc b/src/google/protobuf/compiler/objectivec/map_field.cc index 2a90f4716e2b..f29372cfef1d 100644 --- a/src/google/protobuf/compiler/objectivec/map_field.cc +++ b/src/google/protobuf/compiler/objectivec/map_field.cc @@ -34,7 +34,7 @@ #include #include "absl/container/btree_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/names.h" @@ -79,7 +79,7 @@ const char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return nullptr; } diff --git a/src/google/protobuf/compiler/objectivec/message.cc b/src/google/protobuf/compiler/objectivec/message.cc index 4f65711b6616..5a4c91a4f576 100644 --- a/src/google/protobuf/compiler/objectivec/message.cc +++ b/src/google/protobuf/compiler/objectivec/message.cc @@ -38,7 +38,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/extension.h" @@ -129,7 +129,7 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return 0; } diff --git a/src/google/protobuf/compiler/objectivec/primitive_field.cc b/src/google/protobuf/compiler/objectivec/primitive_field.cc index ede7493150f1..6d910bb6f554 100644 --- a/src/google/protobuf/compiler/objectivec/primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/primitive_field.cc @@ -33,7 +33,7 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/io/printer.h" @@ -74,7 +74,7 @@ const char* PrimitiveTypeName(const FieldDescriptor* descriptor) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return nullptr; } @@ -108,7 +108,7 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) { // Some compilers report reaching end of function even though all cases of // the enum are handed in the switch. - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return nullptr; } diff --git a/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc b/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc index da2f02ef2860..b3083e697af7 100644 --- a/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc +++ b/src/google/protobuf/compiler/objectivec/text_format_decode_data.cc @@ -174,13 +174,10 @@ void TextFormatDecodeData::AddString(int32_t key, const std::string& desired_output) { for (std::vector::const_iterator i = entries_.begin(); i != entries_.end(); ++i) { - if (i->first == key) { - std::cerr << "error: duplicate key (" << key - << ") making TextFormat data, input: \"" << input_for_decode - << "\", desired: \"" << desired_output << "\"." << std::endl; - std::cerr.flush(); - abort(); - } + ABSL_CHECK(i->first != key) + << "error: duplicate key (" << key + << ") making TextFormat data, input: \"" << input_for_decode + << "\", desired: \"" << desired_output << "\"."; } const std::string& data = TextFormatDecodeData::DecodeDataForString( @@ -210,22 +207,14 @@ std::string TextFormatDecodeData::Data() const { // static std::string TextFormatDecodeData::DecodeDataForString( const std::string& input_for_decode, const std::string& desired_output) { - if (input_for_decode.empty() || desired_output.empty()) { - std::cerr << "error: got empty string for making TextFormat data, input: \"" - << input_for_decode << "\", desired: \"" << desired_output - << "\"." << std::endl; - std::cerr.flush(); - abort(); - } - if ((absl::StrContains(input_for_decode, '\0')) || - (absl::StrContains(desired_output, '\0'))) { - std::cerr - << "error: got a null char in a string for making TextFormat data," - << " input: \"" << absl::CEscape(input_for_decode) << "\", desired: \"" - << absl::CEscape(desired_output) << "\"." << std::endl; - std::cerr.flush(); - abort(); - } + ABSL_CHECK(!input_for_decode.empty() && !desired_output.empty()) + << "error: got empty string for making TextFormat data, input: \"" + << input_for_decode << "\", desired: \"" << desired_output << "\"."; + ABSL_CHECK(!absl::StrContains(input_for_decode, '\0') && + !absl::StrContains(desired_output, '\0')) + << "error: got a null char in a string for making TextFormat data," + << " input: \"" << absl::CEscape(input_for_decode) << "\", desired: \"" + << absl::CEscape(desired_output) << "\"."; DecodeDataBuilder builder; diff --git a/src/google/protobuf/compiler/objectivec/text_format_decode_data_unittest.cc b/src/google/protobuf/compiler/objectivec/text_format_decode_data_unittest.cc index 2891bcd314e4..d43322f28ace 100644 --- a/src/google/protobuf/compiler/objectivec/text_format_decode_data_unittest.cc +++ b/src/google/protobuf/compiler/objectivec/text_format_decode_data_unittest.cc @@ -119,30 +119,25 @@ TEST(ObjCHelper, TextFormatDecodeData_DecodeDataForString_ByteCodes) { } // Death tests do not work on Windows as of yet. -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(ObjCHelperDeathTest, TextFormatDecodeData_DecodeDataForString_Failures) { // Empty inputs. - EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString("", ""), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); - EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString("a", ""), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); - EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString("", "a"), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(TextFormatDecodeData::DecodeDataForString("", ""), + "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(TextFormatDecodeData::DecodeDataForString("a", ""), + "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(TextFormatDecodeData::DecodeDataForString("", "a"), + "error: got empty string for making TextFormat data, input:"); // Null char in the string. std::string str_with_null_char("ab\0c", 4); - EXPECT_EXIT( + EXPECT_DEATH( TextFormatDecodeData::DecodeDataForString(str_with_null_char, "def"), - ::testing::KilledBySignal(SIGABRT), "error: got a null char in a string for making TextFormat data, input:"); - EXPECT_EXIT( + EXPECT_DEATH( TextFormatDecodeData::DecodeDataForString("def", str_with_null_char), - ::testing::KilledBySignal(SIGABRT), "error: got a null char in a string for making TextFormat data, input:"); } #endif // PROTOBUF_HAS_DEATH_TEST @@ -214,33 +209,27 @@ TEST(ObjCHelper, TextFormatDecodeData_ByteCodes) { EXPECT_EQ(expected, decode_data.Data()); } -// Death tests do not work on Windows as of yet. -#ifdef PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(ObjCHelperDeathTest, TextFormatDecodeData_Failures) { TextFormatDecodeData decode_data; // Empty inputs. - EXPECT_EXIT(decode_data.AddString(1, "", ""), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); - EXPECT_EXIT(decode_data.AddString(1, "a", ""), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); - EXPECT_EXIT(decode_data.AddString(1, "", "a"), - ::testing::KilledBySignal(SIGABRT), - "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(decode_data.AddString(1, "", ""), + "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(decode_data.AddString(1, "a", ""), + "error: got empty string for making TextFormat data, input:"); + EXPECT_DEATH(decode_data.AddString(1, "", "a"), + "error: got empty string for making TextFormat data, input:"); // Null char in the string. std::string str_with_null_char("ab\0c", 4); - EXPECT_EXIT( + EXPECT_DEATH( decode_data.AddString(1, str_with_null_char, "def"), - ::testing::KilledBySignal(SIGABRT), "error: got a null char in a string for making TextFormat data, input:"); - EXPECT_EXIT( + EXPECT_DEATH( decode_data.AddString(1, "def", str_with_null_char), - ::testing::KilledBySignal(SIGABRT), "error: got a null char in a string for making TextFormat data, input:"); // Duplicate keys @@ -248,9 +237,8 @@ TEST(ObjCHelperDeathTest, TextFormatDecodeData_Failures) { decode_data.AddString(1, "abcdefghIJ", "abcdefghIJ"); decode_data.AddString(3, "abcdefghIJ", "_AbcdefghIJ"); decode_data.AddString(2, "abcdefghIJ", "Abcd_EfghIJ"); - EXPECT_EXIT(decode_data.AddString(2, "xyz", "x_yz"), - ::testing::KilledBySignal(SIGABRT), - "error: duplicate key \\(2\\) making TextFormat data, input:"); + EXPECT_DEATH(decode_data.AddString(2, "xyz", "x_yz"), + "error: duplicate key \\(2\\) making TextFormat data, input:"); } #endif // PROTOBUF_HAS_DEATH_TEST diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 14bdf3eb29c9..dde08a961910 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -48,8 +48,8 @@ #include "absl/base/casts.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -516,8 +516,8 @@ int Parser::LocationRecorder::CurrentPathSize() const { void Parser::LocationRecorder::AttachComments( std::string* leading, std::string* trailing, std::vector* detached_comments) const { - GOOGLE_ABSL_CHECK(!location_->has_leading_comments()); - GOOGLE_ABSL_CHECK(!location_->has_trailing_comments()); + ABSL_CHECK(!location_->has_leading_comments()); + ABSL_CHECK(!location_->has_trailing_comments()); if (!leading->empty()) { location_->mutable_leading_comments()->swap(*leading); @@ -670,7 +670,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { file->set_syntax(syntax_identifier_); } } else if (!stop_after_syntax_identifier_) { - GOOGLE_ABSL_LOG(WARNING) << "No syntax specified for the proto file: " + ABSL_LOG(WARNING) << "No syntax specified for the proto file: " << file->name() << ". Please use 'syntax = \"proto2\";' " << "or 'syntax = \"proto3\";' to specify a syntax " @@ -1487,7 +1487,7 @@ bool Parser::ParseOption(Message* options, // Create an entry in the uninterpreted_option field. const FieldDescriptor* uninterpreted_option_field = options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_ABSL_CHECK(uninterpreted_option_field != nullptr) + ABSL_CHECK(uninterpreted_option_field != nullptr) << "No field named \"uninterpreted_option\" in the Options proto."; const Reflection* reflection = options->GetReflection(); @@ -1540,7 +1540,7 @@ bool Parser::ParseOption(Message* options, switch (input_->current().type) { case io::Tokenizer::TYPE_START: - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << "Trying to read value before any tokens have been read."; return false; @@ -1550,9 +1550,9 @@ bool Parser::ParseOption(Message* options, case io::Tokenizer::TYPE_WHITESPACE: case io::Tokenizer::TYPE_NEWLINE: - GOOGLE_ABSL_CHECK(!input_->report_whitespace() && !input_->report_newlines()) + ABSL_CHECK(!input_->report_whitespace() && !input_->report_newlines()) << "Whitespace tokens were not requested."; - GOOGLE_ABSL_LOG(FATAL) << "Tokenizer reported whitespace."; + ABSL_LOG(FATAL) << "Tokenizer reported whitespace."; return false; case io::Tokenizer::TYPE_IDENTIFIER: { diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index b7b710300ecd..19e7210d3a61 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -46,7 +46,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/memory/memory.h" #include "absl/strings/str_join.h" #include "absl/strings/substitute.h" @@ -2971,14 +2971,14 @@ class SourceInfoTest : public ParserTest { while (*text != '\0') { if (*text == '$') { ++text; - GOOGLE_ABSL_CHECK_NE('\0', *text); + ABSL_CHECK_NE('\0', *text); if (*text == '$') { text_without_markers_ += '$'; ++column; } else { markers_[*text] = std::make_pair(line, column); ++text; - GOOGLE_ABSL_CHECK_EQ('$', *text); + ABSL_CHECK_EQ('$', *text); } } else if (*text == '\n') { ++line; diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 0401435ea034..b78ceef5ab1f 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -38,7 +38,7 @@ #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -2316,14 +2316,14 @@ bool Generator::GenerateAll(const std::vector& files, options.aggregate_metadata = true; for (const auto& prefix : absl::StrSplit(option_pair[1], "#", absl::AllowEmpty())) { options.aggregate_metadata_prefixes.emplace(prefix); - GOOGLE_ABSL_LOG(INFO) << prefix; + ABSL_LOG(INFO) << prefix; } } else if (option_pair[0] == "internal") { options.is_descriptor = true; } else if (option_pair[0] == "internal_generate_c_wkt") { GenerateCWellKnownTypes(files, generator_context); } else { - GOOGLE_ABSL_LOG(FATAL) << "Unknown codegen option: " << option_pair[0]; + ABSL_LOG(FATAL) << "Unknown codegen option: " << option_pair[0]; } } diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index cf8b6f18c0fc..517862b69476 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -353,7 +353,7 @@ Version::~Version() { } inline void Version::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.suffix_.Destroy(); } @@ -550,7 +550,7 @@ void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -687,7 +687,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { } inline void CodeGeneratorRequest::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.file_to_generate_.~RepeatedPtrField(); _impl_.proto_file_.~RepeatedPtrField(); _impl_.parameter_.Destroy(); @@ -712,7 +712,7 @@ void CodeGeneratorRequest::Clear() { _impl_.parameter_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.compiler_version_ != nullptr); + ABSL_DCHECK(_impl_.compiler_version_ != nullptr); _impl_.compiler_version_->Clear(); } } @@ -909,7 +909,7 @@ void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -1072,7 +1072,7 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { } inline void CodeGeneratorResponse_File::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.Destroy(); _impl_.insertion_point_.Destroy(); _impl_.content_.Destroy(); @@ -1101,7 +1101,7 @@ void CodeGeneratorResponse_File::Clear() { _impl_.content_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_ABSL_DCHECK(_impl_.generated_code_info_ != nullptr); + ABSL_DCHECK(_impl_.generated_code_info_ != nullptr); _impl_.generated_code_info_->Clear(); } } @@ -1293,7 +1293,7 @@ void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_ auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -1423,7 +1423,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() { } inline void CodeGeneratorResponse::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.file_.~RepeatedPtrField(); _impl_.error_.Destroy(); } @@ -1601,7 +1601,7 @@ void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 71c7e2cb9cb7..b1fd484b812a 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -194,7 +194,7 @@ class PROTOC_EXPORT Version final : } void UnsafeArenaSwap(Version* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -392,7 +392,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : } void UnsafeArenaSwap(CodeGeneratorRequest* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -615,7 +615,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : } void UnsafeArenaSwap(CodeGeneratorResponse_File* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -822,7 +822,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : } void UnsafeArenaSwap(CodeGeneratorResponse* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1157,7 +1157,7 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, std::string&& // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.file_to_generate_.Mutable(index)->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::set_file_to_generate(int index, absl::string_view value) { @@ -1181,7 +1181,7 @@ inline void CodeGeneratorRequest::add_file_to_generate(std::string&& value) { // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.file_to_generate_.Add()->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::add_file_to_generate(absl::string_view value) { diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index 60158190c863..58ffe0726cff 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc @@ -52,8 +52,8 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -168,7 +168,7 @@ std::string StringifyDefaultValue(const FieldDescriptor& field) { } // (We could add a default case above but then we wouldn't get the nice // compiler warning when a new type is added.) - GOOGLE_ABSL_LOG(FATAL) << "Not reached."; + ABSL_LOG(FATAL) << "Not reached."; return ""; } @@ -180,7 +180,7 @@ std::string StringifySyntax(FileDescriptor::Syntax syntax) { return "proto3"; case FileDescriptor::SYNTAX_UNKNOWN: default: - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 " "and proto3 syntax."; return ""; @@ -292,7 +292,7 @@ bool Generator::Generate(const FileDescriptor* file, } std::unique_ptr output(context->Open(filename)); - GOOGLE_ABSL_CHECK(output.get()); + ABSL_CHECK(output.get()); io::Printer printer(output.get(), '$'); printer_ = &printer; @@ -951,7 +951,7 @@ std::string Generator::FieldReferencingExpression( absl::string_view python_dict_name) const { // We should only ever be looking up fields in the current file. // The only things we refer to from other files are message descriptors. - GOOGLE_ABSL_CHECK_EQ(field.file(), file_) + ABSL_CHECK_EQ(field.file(), file_) << field.file()->name() << " vs. " << file_->name(); if (!containing_type) { return ResolveKeyword(field.name()); @@ -1017,7 +1017,7 @@ void Generator::FixForeignFieldsInExtensions() const { void Generator::FixForeignFieldsInExtension( const FieldDescriptor& extension_field) const { - GOOGLE_ABSL_CHECK(extension_field.is_extension()); + ABSL_CHECK(extension_field.is_extension()); absl::flat_hash_map m; // Confusingly, for FieldDescriptors that happen to be extensions, @@ -1232,7 +1232,7 @@ void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor, std::string sp; proto.SerializeToString(&sp); int offset = file_descriptor_serialized_.find(sp); - GOOGLE_ABSL_CHECK_GE(offset, 0); + ABSL_CHECK_GE(offset, 0); printer_->Print( "_globals['$name$']._serialized_start=$serialized_start$\n" diff --git a/src/google/protobuf/compiler/python/helpers.cc b/src/google/protobuf/compiler/python/helpers.cc index fe35a74f4fc3..70b3eacf26e8 100644 --- a/src/google/protobuf/compiler/python/helpers.cc +++ b/src/google/protobuf/compiler/python/helpers.cc @@ -34,7 +34,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_replace.h" diff --git a/src/google/protobuf/compiler/python/plugin_unittest.cc b/src/google/protobuf/compiler/python/plugin_unittest.cc index f1e86b3ffd35..2ecc8af8dcb8 100644 --- a/src/google/protobuf/compiler/python/plugin_unittest.cc +++ b/src/google/protobuf/compiler/python/plugin_unittest.cc @@ -40,7 +40,7 @@ #include "google/protobuf/compiler/python/generator.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_split.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -80,7 +80,7 @@ class TestGenerator : public CodeGenerator { TEST(PythonPluginTest, ImportTest) { // Create files test1.proto and test2.proto with the former importing the // latter. - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::SetContents(absl::StrCat(TestTempDir(), "/test1.proto"), "syntax = \"proto3\";\n" "package foo;\n" @@ -89,7 +89,7 @@ TEST(PythonPluginTest, ImportTest) { " Message2 message_2 = 1;\n" "}\n", true)); - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::SetContents(absl::StrCat(TestTempDir(), "/test2.proto"), "syntax = \"proto3\";\n" "package foo;\n" @@ -109,7 +109,7 @@ TEST(PythonPluginTest, ImportTest) { // Loop over the lines of the generated code and verify that we find an // ordinary Python import but do not find the string "importlib". std::string output; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(absl::StrCat(TestTempDir(), "/test1_pb2.py"), &output, true)); std::vector lines = absl::StrSplit(output, '\n'); diff --git a/src/google/protobuf/compiler/python/pyi_generator.cc b/src/google/protobuf/compiler/python/pyi_generator.cc index 8427169539f2..907a2773db92 100644 --- a/src/google/protobuf/compiler/python/pyi_generator.cc +++ b/src/google/protobuf/compiler/python/pyi_generator.cc @@ -35,8 +35,8 @@ #include #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "absl/strings/str_split.h" @@ -388,7 +388,7 @@ std::string PyiGenerator::GetFieldType( return name; } default: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported field type."; + ABSL_LOG(FATAL) << "Unsupported field type."; } return ""; } @@ -604,7 +604,7 @@ bool PyiGenerator::Generate(const FileDescriptor* file, } std::unique_ptr output(context->Open(filename)); - GOOGLE_ABSL_CHECK(output.get()); + ABSL_CHECK(output.get()); GeneratedCodeInfo annotations; io::AnnotationProtoCollector annotation_collector( &annotations); diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index bf196a9ecb28..fbeb2ef57223 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -35,7 +35,7 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "google/protobuf/compiler/plugin.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" @@ -123,7 +123,7 @@ std::string StringifySyntax(FileDescriptor::Syntax syntax) { return "proto3"; case FileDescriptor::SYNTAX_UNKNOWN: default: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported syntax; this generator only supports " + ABSL_LOG(FATAL) << "Unsupported syntax; this generator only supports " "proto2 and proto3 syntax."; return ""; } @@ -249,7 +249,7 @@ void GenerateOneof(const OneofDescriptor* oneof, io::Printer* printer) { bool GenerateMessage(const Descriptor* message, io::Printer* printer, std::string* error) { if (message->extension_range_count() > 0 || message->extension_count() > 0) { - GOOGLE_ABSL_LOG(WARNING) + ABSL_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files."; } @@ -426,7 +426,7 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) { if (package_name.find("::") != std::string::npos) { need_change_to_module = false; } else if (package_name.find('.') != std::string::npos) { - GOOGLE_ABSL_LOG(WARNING) << "ruby_package option should be in the form of:" + ABSL_LOG(WARNING) << "ruby_package option should be in the form of:" << " 'A::B::C' and not 'A.B.C'"; } } else { @@ -523,7 +523,7 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer, // TODO: Remove this when ruby supports extensions for proto2 syntax. if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 && file->extension_count() > 0) { - GOOGLE_ABSL_LOG(WARNING) + ABSL_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files."; } diff --git a/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc b/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc index 4b2a2a625c50..c81a42fe310a 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc @@ -68,18 +68,18 @@ void RubyTest(std::string proto_file, std::string import_proto_file = "") { // Copy generated_code.proto to the temporary test directory. std::string test_input; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( absl::StrCat(ruby_tests, proto_file, ".proto"), &test_input, true)); - GOOGLE_ABSL_CHECK_OK(File::SetContents( + ABSL_CHECK_OK(File::SetContents( absl::StrCat(TestTempDir(), proto_file, ".proto"), test_input, true)); // Copy generated_code_import.proto to the temporary test directory. std::string test_import; if (!import_proto_file.empty()) { - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(absl::StrCat(ruby_tests, import_proto_file, ".proto"), &test_import, true)); - GOOGLE_ABSL_CHECK_OK(File::SetContents( + ABSL_CHECK_OK(File::SetContents( absl::StrCat(TestTempDir(), import_proto_file, ".proto"), test_import, true)); } @@ -100,10 +100,10 @@ void RubyTest(std::string proto_file, std::string import_proto_file = "") { // Load the generated output and compare to the expected result. std::string output; - GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText( + ABSL_CHECK_OK(File::GetContentsAsText( absl::StrCat(TestTempDir(), proto_file, "_pb.rb"), &output, true)); std::string expected_output; - GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText( + ABSL_CHECK_OK(File::GetContentsAsText( absl::StrCat(ruby_tests, proto_file, "_pb.rb"), &expected_output, true)); EXPECT_EQ(expected_output, output); } diff --git a/src/google/protobuf/compiler/scc.h b/src/google/protobuf/compiler/scc.h index df5bb4a5e2b7..1ca1eb198f92 100644 --- a/src/google/protobuf/compiler/scc.h +++ b/src/google/protobuf/compiler/scc.h @@ -35,7 +35,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/memory/memory.h" #include "google/protobuf/descriptor.h" @@ -99,7 +99,7 @@ class PROTOC_EXPORT SCCAnalyzer { // Mark visited by inserting in map. auto ins = cache_.try_emplace(descriptor, absl::make_unique()); // Must not have visited already. - GOOGLE_ABSL_DCHECK(ins.second); + ABSL_DCHECK(ins.second); NodeData& result = *ins.first->second; // Initialize data structures. result.index = result.lowlink = index_++; @@ -107,7 +107,7 @@ class PROTOC_EXPORT SCCAnalyzer { // Recurse the fields / nodes in graph for (const auto* dep : DepsGenerator()(descriptor)) { - GOOGLE_ABSL_CHECK(dep); + ABSL_CHECK(dep); auto it = cache_.find(dep); if (it == cache_.end()) { // unexplored node @@ -150,7 +150,7 @@ class PROTOC_EXPORT SCCAnalyzer { absl::flat_hash_set seen; for (auto descriptor : scc->descriptors) { for (auto child_msg : DepsGenerator()(descriptor)) { - GOOGLE_ABSL_CHECK(child_msg); + ABSL_CHECK(child_msg); const SCC* child = GetSCC(child_msg); if (child == scc) continue; if (seen.insert(child).second) { diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index fdd29ed7fc78..6f9233da3643 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -43,8 +43,8 @@ #include #endif -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/substitute.h" @@ -59,7 +59,7 @@ namespace compiler { static void CloseHandleOrDie(HANDLE handle) { if (!CloseHandle(handle)) { - GOOGLE_ABSL_LOG(FATAL) << "CloseHandle: " + ABSL_LOG(FATAL) << "CloseHandle: " << Subprocess::Win32ErrorMessage(GetLastError()); } } @@ -87,21 +87,21 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { HANDLE stdout_pipe_write; if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) { - GOOGLE_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); + ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); } if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) { - GOOGLE_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); + ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); } // Make child side of the pipes inheritable. if (!SetHandleInformation(stdin_pipe_read, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { - GOOGLE_ABSL_LOG(FATAL) << "SetHandleInformation: " + ABSL_LOG(FATAL) << "SetHandleInformation: " << Win32ErrorMessage(GetLastError()); } if (!SetHandleInformation(stdout_pipe_write, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { - GOOGLE_ABSL_LOG(FATAL) << "SetHandleInformation: " + ABSL_LOG(FATAL) << "SetHandleInformation: " << Win32ErrorMessage(GetLastError()); } @@ -115,13 +115,13 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); if (startup_info.hStdError == INVALID_HANDLE_VALUE) { - GOOGLE_ABSL_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError()); + ABSL_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError()); } // get wide string version of program as the path may contain non-ascii characters std::wstring wprogram; if (!io::win32::strings::utf8_to_wcs(program.c_str(), &wprogram)) { - GOOGLE_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); + ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); } // Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'. @@ -130,7 +130,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { // get wide string version of command line as the path may contain non-ascii characters std::wstring wcommand_line; if (!io::win32::strings::utf8_to_wcs(command_line.c_str(), &wcommand_line)) { - GOOGLE_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); + ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); } // Using a malloc'ed string because CreateProcess() can mutate its second @@ -171,7 +171,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, return false; } - GOOGLE_ABSL_CHECK(child_handle_ != nullptr) << "Must call Start() first."; + ABSL_CHECK(child_handle_ != nullptr) << "Must call Start() first."; std::string input_data; if (!input.SerializeToString(&input_data)) { @@ -201,10 +201,10 @@ bool Subprocess::Communicate(const Message& input, Message* output, wait_result < WAIT_OBJECT_0 + handle_count) { signaled_handle = handles[wait_result - WAIT_OBJECT_0]; } else if (wait_result == WAIT_FAILED) { - GOOGLE_ABSL_LOG(FATAL) << "WaitForMultipleObjects: " + ABSL_LOG(FATAL) << "WaitForMultipleObjects: " << Win32ErrorMessage(GetLastError()); } else { - GOOGLE_ABSL_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: " + ABSL_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: " << wait_result; } @@ -248,16 +248,16 @@ bool Subprocess::Communicate(const Message& input, Message* output, DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE); if (wait_result == WAIT_FAILED) { - GOOGLE_ABSL_LOG(FATAL) << "WaitForSingleObject: " + ABSL_LOG(FATAL) << "WaitForSingleObject: " << Win32ErrorMessage(GetLastError()); } else if (wait_result != WAIT_OBJECT_0) { - GOOGLE_ABSL_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: " + ABSL_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: " << wait_result; } DWORD exit_code; if (!GetExitCodeProcess(child_handle_, &exit_code)) { - GOOGLE_ABSL_LOG(FATAL) << "GetExitCodeProcess: " + ABSL_LOG(FATAL) << "GetExitCodeProcess: " << Win32ErrorMessage(GetLastError()); } @@ -328,14 +328,14 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { int stdin_pipe[2]; int stdout_pipe[2]; - GOOGLE_ABSL_CHECK(pipe(stdin_pipe) != -1); - GOOGLE_ABSL_CHECK(pipe(stdout_pipe) != -1); + ABSL_CHECK(pipe(stdin_pipe) != -1); + ABSL_CHECK(pipe(stdout_pipe) != -1); char* argv[2] = {portable_strdup(program.c_str()), nullptr}; child_pid_ = fork(); if (child_pid_ == -1) { - GOOGLE_ABSL_LOG(FATAL) << "fork: " << strerror(errno); + ABSL_LOG(FATAL) << "fork: " << strerror(errno); } else if (child_pid_ == 0) { // We are the child. dup2(stdin_pipe[0], STDIN_FILENO); @@ -382,7 +382,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { bool Subprocess::Communicate(const Message& input, Message* output, std::string* error) { - GOOGLE_ABSL_CHECK_NE(child_stdin_, -1) << "Must call Start() first."; + ABSL_CHECK_NE(child_stdin_, -1) << "Must call Start() first."; // The "sighandler_t" typedef is GNU-specific, so define our own. typedef void SignalHandler(int); @@ -417,7 +417,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, // Interrupted by signal. Try again. continue; } else { - GOOGLE_ABSL_LOG(FATAL) << "select: " << strerror(errno); + ABSL_LOG(FATAL) << "select: " << strerror(errno); } } @@ -463,7 +463,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, int status; while (waitpid(child_pid_, &status, 0) == -1) { if (errno != EINTR) { - GOOGLE_ABSL_LOG(FATAL) << "waitpid: " << strerror(errno); + ABSL_LOG(FATAL) << "waitpid: " << strerror(errno); } } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 3aac439ea2dd..3410ba9726fb 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -53,8 +53,8 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/hash/hash.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" @@ -374,7 +374,7 @@ class FlatAllocatorImpl { template void PlanArray(int array_size) { // We can't call PlanArray after FinalizePlanning has been called. - GOOGLE_ABSL_CHECK(!has_allocated()); + ABSL_CHECK(!has_allocated()); if (std::is_trivially_destructible::value) { // Trivial types are aligned to 8 bytes. static_assert(alignof(U) <= 8, ""); @@ -395,13 +395,13 @@ class FlatAllocatorImpl { using TypeToUse = typename std::conditional::type; // We can only allocate after FinalizePlanning has been called. - GOOGLE_ABSL_CHECK(has_allocated()); + ABSL_CHECK(has_allocated()); TypeToUse*& data = pointers_.template Get(); int& used = used_.template Get(); U* res = reinterpret_cast(data + used); used += trivial ? RoundUpTo<8>(array_size * sizeof(U)) : array_size; - GOOGLE_ABSL_CHECK_LE(used, total_.template Get()); + ABSL_CHECK_LE(used, total_.template Get()); return res; } @@ -420,7 +420,7 @@ class FlatAllocatorImpl { // and the other 3 indices are specified in the result. void PlanFieldNames(const std::string& name, const std::string* opt_json_name) { - GOOGLE_ABSL_CHECK(!has_allocated()); + ABSL_CHECK(!has_allocated()); // Fast path for snake_case names, which follow the style guide. if (opt_json_name == nullptr) { @@ -461,7 +461,7 @@ class FlatAllocatorImpl { FieldNamesResult AllocateFieldNames(const std::string& name, const std::string& scope, const std::string* opt_json_name) { - GOOGLE_ABSL_CHECK(has_allocated()); + ABSL_CHECK(has_allocated()); std::string full_name = scope.empty() ? name : absl::StrCat(scope, ".", name); @@ -517,11 +517,11 @@ class FlatAllocatorImpl { template void FinalizePlanning(Alloc& alloc) { - GOOGLE_ABSL_CHECK(!has_allocated()); + ABSL_CHECK(!has_allocated()); pointers_ = alloc->CreateFlatAlloc(total_)->Pointers(); - GOOGLE_ABSL_CHECK(has_allocated()); + ABSL_CHECK(has_allocated()); } void ExpectConsumed() const { @@ -557,7 +557,7 @@ class FlatAllocatorImpl { template bool ExpectConsumed() const { - GOOGLE_ABSL_CHECK_EQ(total_.template Get(), used_.template Get()); + ABSL_CHECK_EQ(total_.template Get(), used_.template Get()); return true; } @@ -706,7 +706,7 @@ class Symbol { return absl::string_view(sub_package_file_descriptor()->file->package()) .substr(0, sub_package_file_descriptor()->name_size); default: - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); } return ""; } @@ -739,7 +739,7 @@ class Symbol { case METHOD: return {method_descriptor()->service(), method_descriptor()->name()}; default: - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); } return {}; } @@ -827,7 +827,7 @@ const char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) { case SYNTAX_UNKNOWN: return "unknown"; } - GOOGLE_ABSL_LOG(FATAL) << "can't reach here."; + ABSL_LOG(FATAL) << "can't reach here."; return nullptr; } @@ -1406,7 +1406,7 @@ DescriptorPool::Tables::Tables() { }); } -DescriptorPool::Tables::~Tables() { GOOGLE_ABSL_DCHECK(checkpoints_.empty()); } +DescriptorPool::Tables::~Tables() { ABSL_DCHECK(checkpoints_.empty()); } FileDescriptorTables::FileDescriptorTables() {} @@ -1426,7 +1426,7 @@ void DescriptorPool::Tables::AddCheckpoint() { } void DescriptorPool::Tables::ClearLastCheckpoint() { - GOOGLE_ABSL_DCHECK(!checkpoints_.empty()); + ABSL_DCHECK(!checkpoints_.empty()); checkpoints_.pop_back(); if (checkpoints_.empty()) { // All checkpoints have been cleared: we can now commit all of the pending @@ -1438,7 +1438,7 @@ void DescriptorPool::Tables::ClearLastCheckpoint() { } void DescriptorPool::Tables::RollbackToLastCheckpoint() { - GOOGLE_ABSL_DCHECK(!checkpoints_.empty()); + ABSL_DCHECK(!checkpoints_.empty()); const CheckPoint& checkpoint = checkpoints_.back(); for (size_t i = checkpoint.pending_symbols_before_checkpoint; @@ -1692,7 +1692,7 @@ inline void DescriptorPool::Tables::FindAllExtensions( bool DescriptorPool::Tables::AddSymbol(absl::string_view full_name, Symbol symbol) { - GOOGLE_ABSL_DCHECK_EQ(full_name, symbol.full_name()); + ABSL_DCHECK_EQ(full_name, symbol.full_name()); if (symbols_by_name_.insert(symbol).second) { symbols_after_checkpoint_.push_back(symbol); return true; @@ -1704,8 +1704,8 @@ bool DescriptorPool::Tables::AddSymbol(absl::string_view full_name, bool FileDescriptorTables::AddAliasUnderParent(const void* parent, absl::string_view name, Symbol symbol) { - GOOGLE_ABSL_DCHECK_EQ(name, symbol.parent_name_key().second); - GOOGLE_ABSL_DCHECK_EQ(parent, symbol.parent_name_key().first); + ABSL_DCHECK_EQ(name, symbol.parent_name_key().second); + ABSL_DCHECK_EQ(parent, symbol.parent_name_key().first); return symbols_by_parent_.insert(symbol).second; } @@ -1942,7 +1942,7 @@ void DescriptorPool::InternalAddGeneratedFile( // Therefore, when we parse one, we have to be very careful to avoid using // any descriptor-based operations, since this might cause infinite recursion // or deadlock. - GOOGLE_ABSL_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size)); + ABSL_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size)); } @@ -2246,13 +2246,13 @@ const EnumValueDescriptor* Descriptor::FindEnumValueByName( const FieldDescriptor* Descriptor::map_key() const { if (!options().map_entry()) return nullptr; - GOOGLE_ABSL_DCHECK_EQ(field_count(), 2); + ABSL_DCHECK_EQ(field_count(), 2); return field(0); } const FieldDescriptor* Descriptor::map_value() const { if (!options().map_entry()) return nullptr; - GOOGLE_ABSL_DCHECK_EQ(field_count(), 2); + ABSL_DCHECK_EQ(field_count(), 2); return field(1); } @@ -2489,7 +2489,7 @@ bool FieldDescriptor::is_map_message_type() const { std::string FieldDescriptor::DefaultValueAsString( bool quote_string_type) const { - GOOGLE_ABSL_CHECK(has_default_value()) << "No default value"; + ABSL_CHECK(has_default_value()) << "No default value"; switch (cpp_type()) { case CPPTYPE_INT32: return absl::StrCat(default_value_int32_t()); @@ -2518,10 +2518,10 @@ std::string FieldDescriptor::DefaultValueAsString( case CPPTYPE_ENUM: return default_value_enum()->name(); case CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(DFATAL) << "Messages can't have default values!"; + ABSL_DLOG(FATAL) << "Messages can't have default values!"; break; } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here: failed to get default value as string"; + ABSL_LOG(FATAL) << "Can't get here: failed to get default value as string"; return ""; } @@ -2575,7 +2575,7 @@ void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const { void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const { if (message_type_count() != proto->message_type_size() || extension_count() != proto->extension_size()) { - GOOGLE_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size."; + ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size."; return; } for (int i = 0; i < message_type_count(); i++) { @@ -2632,7 +2632,7 @@ void Descriptor::CopyJsonNameTo(DescriptorProto* proto) const { if (field_count() != proto->field_size() || nested_type_count() != proto->nested_type_size() || extension_count() != proto->extension_size()) { - GOOGLE_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size."; + ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size."; return; } for (int i = 0; i < field_count(); i++) { @@ -2854,7 +2854,7 @@ bool RetrieveOptions(int depth, const Message& options, return RetrieveOptionsAssumingRightPool(depth, *dynamic_options, option_entries); } else { - GOOGLE_ABSL_LOG(ERROR) << "Found invalid proto option data for: " + ABSL_LOG(ERROR) << "Found invalid proto option data for: " << options.GetDescriptor()->full_name(); return RetrieveOptionsAssumingRightPool(depth, options, option_entries); } @@ -3476,7 +3476,7 @@ void MethodDescriptor::DebugString( bool FileDescriptor::GetSourceLocation(const std::vector& path, SourceLocation* out_location) const { - GOOGLE_ABSL_CHECK(out_location != nullptr); + ABSL_CHECK(out_location != nullptr); if (source_code_info_) { if (const SourceCodeInfo_Location* loc = tables_->GetSourceLocation(path, source_code_info_)) { @@ -4130,11 +4130,11 @@ class DescriptorBuilder { const FileDescriptor* DescriptorPool::BuildFile( const FileDescriptorProto& proto) { - GOOGLE_ABSL_CHECK(fallback_database_ == nullptr) + ABSL_CHECK(fallback_database_ == nullptr) << "Cannot call BuildFile on a DescriptorPool that uses a " "DescriptorDatabase. You must instead find a way to get your file " "into the underlying database."; - GOOGLE_ABSL_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_ABSL_CHECK. + ABSL_CHECK(mutex_ == nullptr); // Implied by the above ABSL_CHECK. tables_->known_bad_symbols_.clear(); tables_->known_bad_files_.clear(); return DescriptorBuilder::New(this, tables_.get(), nullptr)->BuildFile(proto); @@ -4142,11 +4142,11 @@ const FileDescriptor* DescriptorPool::BuildFile( const FileDescriptor* DescriptorPool::BuildFileCollectingErrors( const FileDescriptorProto& proto, ErrorCollector* error_collector) { - GOOGLE_ABSL_CHECK(fallback_database_ == nullptr) + ABSL_CHECK(fallback_database_ == nullptr) << "Cannot call BuildFile on a DescriptorPool that uses a " "DescriptorDatabase. You must instead find a way to get your file " "into the underlying database."; - GOOGLE_ABSL_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_ABSL_CHECK. + ABSL_CHECK(mutex_ == nullptr); // Implied by the above ABSL_CHECK. tables_->known_bad_symbols_.clear(); tables_->known_bad_files_.clear(); return DescriptorBuilder::New(this, tables_.get(), error_collector) @@ -4186,10 +4186,10 @@ PROTOBUF_NOINLINE void DescriptorBuilder::AddError( const std::string& error) { if (error_collector_ == nullptr) { if (!had_errors_) { - GOOGLE_ABSL_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_ + ABSL_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_ << "\":"; } - GOOGLE_ABSL_LOG(ERROR) << " " << element_name << ": " << error; + ABSL_LOG(ERROR) << " " << element_name << ": " << error; } else { error_collector_->RecordError(filename_, element_name, &descriptor, location, error); @@ -4241,7 +4241,7 @@ PROTOBUF_NOINLINE void DescriptorBuilder::AddWarning( DescriptorPool::ErrorCollector::ErrorLocation location, const std::string& error) { if (error_collector_ == nullptr) { - GOOGLE_ABSL_LOG(WARNING) << filename_ << " " << element_name << ": " << error; + ABSL_LOG(WARNING) << filename_ << " " << element_name << ": " << error; } else { error_collector_->RecordWarning(filename_, element_name, &descriptor, location, error); @@ -4620,7 +4620,7 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name, // This is only possible if there was already an error adding something of // the same name. if (!had_errors_) { - GOOGLE_ABSL_LOG(DFATAL) << "\"" << full_name + ABSL_DLOG(FATAL) << "\"" << full_name << "\" not previously defined in " "symbols_by_name_, but was defined in " "symbols_by_parent_; this shouldn't be possible."; @@ -4870,7 +4870,7 @@ PROTOBUF_NOINLINE static bool ExistingFileMatchesProto( // necessary memory allocations that BuildXXX functions below will do on the // Tables object. // They *must* be kept in sync. If we miss some PlanArray call we won't have -// enough memory and will GOOGLE_ABSL_CHECK-fail. +// enough memory and will ABSL_CHECK-fail. static void PlanAllocationSize( const RepeatedPtrField& values, internal::FlatAllocator& alloc) { @@ -6406,7 +6406,7 @@ void DescriptorBuilder::CrossLinkMessage(Descriptor* message, // Verify that they are contiguous. // This is assumed by OneofDescriptor::field(i). // But only if there are no errors. - GOOGLE_ABSL_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_, + ABSL_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_, message->field(i)); } ++out_oneof_decl.field_count_; @@ -7355,7 +7355,7 @@ void DescriptorBuilder::ValidateJSType(FieldDescriptor* field, DescriptorBuilder::OptionInterpreter::OptionInterpreter( DescriptorBuilder* builder) : builder_(builder) { - GOOGLE_ABSL_CHECK(builder_); + ABSL_CHECK(builder_); } DescriptorBuilder::OptionInterpreter::~OptionInterpreter() {} @@ -7374,7 +7374,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions( // and clear them, since we're about to interpret them. const FieldDescriptor* uninterpreted_options_field = options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_ABSL_CHECK(uninterpreted_options_field != nullptr) + ABSL_CHECK(uninterpreted_options_field != nullptr) << "No field named \"uninterpreted_option\" in the Options proto."; options->GetReflection()->ClearField(options, uninterpreted_options_field); @@ -7385,7 +7385,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions( const FieldDescriptor* original_uninterpreted_options_field = original_options->GetDescriptor()->FindFieldByName( "uninterpreted_option"); - GOOGLE_ABSL_CHECK(original_uninterpreted_options_field != nullptr) + ABSL_CHECK(original_uninterpreted_options_field != nullptr) << "No field named \"uninterpreted_option\" in the Options proto."; const int num_uninterpreted_options = @@ -7478,7 +7478,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( // generated pool's mutex, so we can search it the straightforward way. options_descriptor = options->GetDescriptor(); } - GOOGLE_ABSL_CHECK(options_descriptor); + ABSL_CHECK(options_descriptor); // We iterate over the name parts to drill into the submessages until we find // the leaf field for the option. As we drill down we remember the current @@ -7615,7 +7615,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( case FieldDescriptor::TYPE_MESSAGE: { std::string* outstr = parent_unknown_fields->AddLengthDelimited((*iter)->number()); - GOOGLE_ABSL_CHECK(unknown_fields->SerializeToString(outstr)) + ABSL_CHECK(unknown_fields->SerializeToString(outstr)) << "Unexpected failure while serializing option submessage " << debug_msg_name << "\"."; break; @@ -7628,7 +7628,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( } default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << (*iter)->type(); return false; } @@ -7746,7 +7746,7 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting( const UninterpretedOption& uninterpreted_option, Message* options) { const FieldDescriptor* field = options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_ABSL_CHECK(field != nullptr); + ABSL_CHECK(field != nullptr); options->GetReflection() ->AddMessage(options, field) @@ -7806,7 +7806,7 @@ bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet( break; default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type; + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type; return false; } } @@ -8125,7 +8125,7 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption( const Descriptor* type = option_field->message_type(); std::unique_ptr dynamic(dynamic_factory_.GetPrototype(type)->New()); - GOOGLE_ABSL_CHECK(dynamic.get() != nullptr) + ABSL_CHECK(dynamic.get() != nullptr) << "Could not create an instance of " << option_field->DebugString(); AggregateErrorCollector collector; @@ -8145,7 +8145,7 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption( if (option_field->type() == FieldDescriptor::TYPE_MESSAGE) { unknown_fields->AddLengthDelimited(option_field->number(), serial); } else { - GOOGLE_ABSL_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP); + ABSL_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP); UnknownFieldSet* group = unknown_fields->AddGroup(option_field->number()); group->ParseFromString(serial); } @@ -8172,7 +8172,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt32( break; default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type; + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type; break; } } @@ -8195,7 +8195,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt64( break; default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type; + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type; break; } } @@ -8213,7 +8213,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt32( break; default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type; + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type; break; } } @@ -8231,7 +8231,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt64( break; default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type; + ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type; break; } } @@ -8274,7 +8274,7 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(absl::string_view name, // be looked up when the accessor for the type was called. Set type_, // enum_type_, message_type_, and default_value_enum_ appropriately. void FieldDescriptor::InternalTypeOnceInit() const { - GOOGLE_ABSL_CHECK(file()->finished_building_ == true); + ABSL_CHECK(file()->finished_building_ == true); const EnumDescriptor* enum_type = nullptr; const char* lazy_type_name = reinterpret_cast(type_once_ + 1); const char* lazy_default_value_enum_name = @@ -8310,7 +8310,7 @@ void FieldDescriptor::InternalTypeOnceInit() const { if (!default_value_enum_) { // We use the first defined value as the default // if a default is not explicitly defined. - GOOGLE_ABSL_CHECK(enum_type->value_count()); + ABSL_CHECK(enum_type->value_count()); default_value_enum_ = enum_type->value(0); } } @@ -8356,7 +8356,7 @@ const std::string& FieldDescriptor::PrintableNameForExtension() const { } void FileDescriptor::InternalDependenciesOnceInit() const { - GOOGLE_ABSL_CHECK(finished_building_ == true); + ABSL_CHECK(finished_building_ == true); const char* names_ptr = reinterpret_cast(dependencies_once_ + 1); for (int i = 0; i < dependency_count(); i++) { const char* name = names_ptr; @@ -8391,18 +8391,18 @@ const Descriptor* MethodDescriptor::output_type() const { namespace internal { void LazyDescriptor::Set(const Descriptor* descriptor) { - GOOGLE_ABSL_CHECK(!once_); + ABSL_CHECK(!once_); descriptor_ = descriptor; } void LazyDescriptor::SetLazy(absl::string_view name, const FileDescriptor* file) { // verify Init() has been called and Set hasn't been called yet. - GOOGLE_ABSL_CHECK(!descriptor_); - GOOGLE_ABSL_CHECK(!once_); - GOOGLE_ABSL_CHECK(file && file->pool_); - GOOGLE_ABSL_CHECK(file->pool_->lazily_build_dependencies_); - GOOGLE_ABSL_CHECK(!file->finished_building_); + ABSL_CHECK(!descriptor_); + ABSL_CHECK(!once_); + ABSL_CHECK(file && file->pool_); + ABSL_CHECK(file->pool_->lazily_build_dependencies_); + ABSL_CHECK(!file->finished_building_); once_ = ::new (file->pool_->tables_->AllocateBytes(static_cast( sizeof(absl::once_flag) + name.size() + 1))) absl::once_flag{}; char* lazy_name = reinterpret_cast(once_ + 1); @@ -8414,7 +8414,7 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) { if (once_) { absl::call_once(*once_, [&] { auto* file = service->file(); - GOOGLE_ABSL_CHECK(file->finished_building_); + ABSL_CHECK(file->finished_building_); const char* lazy_name = reinterpret_cast(once_ + 1); descriptor_ = file->pool_->CrossLinkOnDemandHelper(lazy_name, false).descriptor(); diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 40f255bc4fcb..21a97cb4c9dd 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -66,8 +66,8 @@ #include "absl/base/attributes.h" #include "absl/base/call_once.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" #include "google/protobuf/port.h" @@ -1799,7 +1799,7 @@ class PROTOBUF_EXPORT DescriptorPool { // this pool will be slower, since they will have to obtain locks too. // - An ErrorCollector may optionally be given to collect validation errors // in files loaded from the database. If not given, errors will be printed - // to GOOGLE_ABSL_LOG(ERROR). Remember that files are built on-demand, so this + // to ABSL_LOG(ERROR). Remember that files are built on-demand, so this // ErrorCollector may be called from any thread that calls one of the // Find*By*() methods. // - The DescriptorDatabase must not be mutated during the lifetime of @@ -1944,7 +1944,7 @@ class PROTOBUF_EXPORT DescriptorPool { const std::string& element_name, const Message* descriptor, ErrorLocation location, const std::string& message) { - GOOGLE_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; + ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; } ABSL_DEPRECATED("Use RecordWarning") virtual void AddWarning(const std::string& filename, @@ -1957,7 +1957,7 @@ class PROTOBUF_EXPORT DescriptorPool { // this DescriptorPool. All dependencies of the file must already be in // the pool. Returns the resulting FileDescriptor, or nullptr if there were // problems with the input (e.g. the message was invalid, or dependencies - // were missing). Details about the errors are written to GOOGLE_ABSL_LOG(ERROR). + // were missing). Details about the errors are written to ABSL_LOG(ERROR). const FileDescriptor* BuildFile(const FileDescriptorProto& proto); // Same as BuildFile() except errors are sent to the given ErrorCollector. @@ -2363,12 +2363,12 @@ inline const OneofDescriptor* FieldDescriptor::containing_oneof() const { } inline int FieldDescriptor::index_in_oneof() const { - GOOGLE_ABSL_DCHECK(is_oneof_); + ABSL_DCHECK(is_oneof_); return static_cast(this - scope_.containing_oneof->field(0)); } inline const Descriptor* FieldDescriptor::extension_scope() const { - GOOGLE_ABSL_CHECK(is_extension_); + ABSL_CHECK(is_extension_); return scope_.extension_scope; } @@ -2552,7 +2552,7 @@ struct FieldRangeImpl { value_type operator*() { return descriptor->field(idx); } friend bool operator==(const Iterator& a, const Iterator& b) { - GOOGLE_ABSL_DCHECK(a.descriptor == b.descriptor); + ABSL_DCHECK(a.descriptor == b.descriptor); return a.idx == b.idx; } friend bool operator!=(const Iterator& a, const Iterator& b) { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 84d346ec58ef..7cfe0468ab17 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1660,7 +1660,7 @@ FileDescriptorSet::~FileDescriptorSet() { } inline void FileDescriptorSet::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.file_.~RepeatedPtrField(); } @@ -1772,7 +1772,7 @@ void FileDescriptorSet::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -1959,7 +1959,7 @@ FileDescriptorProto::~FileDescriptorProto() { } inline void FileDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.dependency_.~RepeatedPtrField(); _impl_.message_type_.~RepeatedPtrField(); _impl_.enum_type_.~RepeatedPtrField(); @@ -2007,11 +2007,11 @@ void FileDescriptorProto::Clear() { _impl_.edition_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000010u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } if (cached_has_bits & 0x00000020u) { - GOOGLE_ABSL_DCHECK(_impl_.source_code_info_ != nullptr); + ABSL_DCHECK(_impl_.source_code_info_ != nullptr); _impl_.source_code_info_->Clear(); } } @@ -2476,7 +2476,7 @@ void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -2650,7 +2650,7 @@ DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { } inline void DescriptorProto_ExtensionRange::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete _impl_.options_; } @@ -2666,7 +2666,7 @@ void DescriptorProto_ExtensionRange::Clear() { cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } if (cached_has_bits & 0x00000006u) { @@ -2818,7 +2818,7 @@ void DescriptorProto_ExtensionRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -2919,7 +2919,7 @@ DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { } inline void DescriptorProto_ReservedRange::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); } void DescriptorProto_ReservedRange::SetCachedSize(int size) const { @@ -3059,7 +3059,7 @@ void DescriptorProto_ReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -3193,7 +3193,7 @@ DescriptorProto::~DescriptorProto() { } inline void DescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.field_.~RepeatedPtrField(); _impl_.nested_type_.~RepeatedPtrField(); _impl_.enum_type_.~RepeatedPtrField(); @@ -3230,7 +3230,7 @@ void DescriptorProto::Clear() { _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -3601,7 +3601,7 @@ void DescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -3721,7 +3721,7 @@ ExtensionRangeOptions::~ExtensionRangeOptions() { } inline void ExtensionRangeOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -3846,7 +3846,7 @@ void ExtensionRangeOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -4059,7 +4059,7 @@ FieldDescriptorProto::~FieldDescriptorProto() { } inline void FieldDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.Destroy(); _impl_.extendee_.Destroy(); _impl_.type_name_.Destroy(); @@ -4096,7 +4096,7 @@ void FieldDescriptorProto::Clear() { _impl_.json_name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000020u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -4482,7 +4482,7 @@ void FieldDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -4656,7 +4656,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { } inline void OneofDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.Destroy(); if (this != internal_default_instance()) delete _impl_.options_; } @@ -4677,7 +4677,7 @@ void OneofDescriptorProto::Clear() { _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -4809,7 +4809,7 @@ void OneofDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, c auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -4907,7 +4907,7 @@ EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() } inline void EnumDescriptorProto_EnumReservedRange::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); } void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const { @@ -5047,7 +5047,7 @@ void EnumDescriptorProto_EnumReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::M auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -5171,7 +5171,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { } inline void EnumDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.value_.~RepeatedPtrField(); _impl_.reserved_range_.~RepeatedPtrField(); _impl_.reserved_name_.~RepeatedPtrField(); @@ -5198,7 +5198,7 @@ void EnumDescriptorProto::Clear() { _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -5424,7 +5424,7 @@ void EnumDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -5562,7 +5562,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { } inline void EnumValueDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.Destroy(); if (this != internal_default_instance()) delete _impl_.options_; } @@ -5583,7 +5583,7 @@ void EnumValueDescriptorProto::Clear() { _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -5739,7 +5739,7 @@ void EnumValueDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_ms auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -5872,7 +5872,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { } inline void ServiceDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.method_.~RepeatedPtrField(); _impl_.name_.Destroy(); if (this != internal_default_instance()) delete _impl_.options_; @@ -5895,7 +5895,7 @@ void ServiceDescriptorProto::Clear() { _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -6056,7 +6056,7 @@ void ServiceDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -6233,7 +6233,7 @@ MethodDescriptorProto::~MethodDescriptorProto() { } inline void MethodDescriptorProto::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.Destroy(); _impl_.input_type_.Destroy(); _impl_.output_type_.Destroy(); @@ -6262,7 +6262,7 @@ void MethodDescriptorProto::Clear() { _impl_.output_type_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_ABSL_DCHECK(_impl_.options_ != nullptr); + ABSL_DCHECK(_impl_.options_ != nullptr); _impl_.options_->Clear(); } } @@ -6501,7 +6501,7 @@ void MethodDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -6865,7 +6865,7 @@ FileOptions::~FileOptions() { } inline void FileOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); _impl_.java_package_.Destroy(); @@ -7583,7 +7583,7 @@ void FileOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -7825,7 +7825,7 @@ MessageOptions::~MessageOptions() { } inline void MessageOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -8073,7 +8073,7 @@ void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const : auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -8250,7 +8250,7 @@ FieldOptions::~FieldOptions() { } inline void FieldOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -8635,7 +8635,7 @@ void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -8760,7 +8760,7 @@ OneofOptions::~OneofOptions() { } inline void OneofOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -8885,7 +8885,7 @@ void OneofOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::P auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -8995,7 +8995,7 @@ EnumOptions::~EnumOptions() { } inline void EnumOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -9196,7 +9196,7 @@ void EnumOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -9310,7 +9310,7 @@ EnumValueOptions::~EnumValueOptions() { } inline void EnumValueOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -9463,7 +9463,7 @@ void EnumValueOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -9563,7 +9563,7 @@ ServiceOptions::~ServiceOptions() { } inline void ServiceOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -9716,7 +9716,7 @@ void ServiceOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const : auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -9823,7 +9823,7 @@ MethodOptions::~MethodOptions() { } inline void MethodOptions::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_._extensions_.~ExtensionSet(); _impl_.uninterpreted_option_.~RepeatedPtrField(); } @@ -10010,7 +10010,7 @@ void MethodOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const :: auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -10136,7 +10136,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { } inline void UninterpretedOption_NamePart::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_part_.Destroy(); } @@ -10297,7 +10297,7 @@ void UninterpretedOption_NamePart::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -10465,7 +10465,7 @@ UninterpretedOption::~UninterpretedOption() { } inline void UninterpretedOption::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.name_.~RepeatedPtrField(); _impl_.identifier_value_.Destroy(); _impl_.string_value_.Destroy(); @@ -10755,7 +10755,7 @@ void UninterpretedOption::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, co auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -10921,7 +10921,7 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() { } inline void SourceCodeInfo_Location::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.path_.~RepeatedField(); _impl_.span_.~RepeatedField(); _impl_.leading_detached_comments_.~RepeatedPtrField(); @@ -11190,7 +11190,7 @@ void SourceCodeInfo_Location::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -11284,7 +11284,7 @@ SourceCodeInfo::~SourceCodeInfo() { } inline void SourceCodeInfo::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.location_.~RepeatedPtrField(); } @@ -11396,7 +11396,7 @@ void SourceCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const : auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -11514,7 +11514,7 @@ GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { } inline void GeneratedCodeInfo_Annotation::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.path_.~RepeatedField(); _impl_.source_file_.Destroy(); } @@ -11751,7 +11751,7 @@ void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& t auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -11850,7 +11850,7 @@ GeneratedCodeInfo::~GeneratedCodeInfo() { } inline void GeneratedCodeInfo::SharedDtor() { - GOOGLE_ABSL_DCHECK(GetArenaForAllocation() == nullptr); + ABSL_DCHECK(GetArenaForAllocation() == nullptr); _impl_.annotation_.~RepeatedPtrField(); } @@ -11962,7 +11962,7 @@ void GeneratedCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, cons auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - GOOGLE_ABSL_DCHECK_NE(&from, _this); + ABSL_DCHECK_NE(&from, _this); ::uint32_t cached_has_bits = 0; (void) cached_has_bits; diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 3c102ac45d0f..24247a1bcf34 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -554,7 +554,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final : } void UnsafeArenaSwap(FileDescriptorSet* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -716,7 +716,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final : } void UnsafeArenaSwap(FileDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1107,7 +1107,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : } void UnsafeArenaSwap(DescriptorProto_ExtensionRange* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1292,7 +1292,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : } void UnsafeArenaSwap(DescriptorProto_ReservedRange* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1461,7 +1461,7 @@ class PROTOBUF_EXPORT DescriptorProto final : } void UnsafeArenaSwap(DescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -1807,7 +1807,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : } void UnsafeArenaSwap(ExtensionRangeOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2122,7 +2122,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : } void UnsafeArenaSwap(FieldDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2479,7 +2479,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : } void UnsafeArenaSwap(OneofDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2654,7 +2654,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : } void UnsafeArenaSwap(EnumDescriptorProto_EnumReservedRange* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -2823,7 +2823,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : } void UnsafeArenaSwap(EnumDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3068,7 +3068,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : } void UnsafeArenaSwap(EnumValueDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3256,7 +3256,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : } void UnsafeArenaSwap(ServiceDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3451,7 +3451,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : } void UnsafeArenaSwap(MethodDescriptorProto* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -3684,7 +3684,7 @@ class PROTOBUF_EXPORT FileOptions final : } void UnsafeArenaSwap(FileOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -4309,7 +4309,7 @@ class PROTOBUF_EXPORT MessageOptions final : } void UnsafeArenaSwap(MessageOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -4690,7 +4690,7 @@ class PROTOBUF_EXPORT FieldOptions final : } void UnsafeArenaSwap(FieldOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -5219,7 +5219,7 @@ class PROTOBUF_EXPORT OneofOptions final : } void UnsafeArenaSwap(OneofOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -5534,7 +5534,7 @@ class PROTOBUF_EXPORT EnumOptions final : } void UnsafeArenaSwap(EnumOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -5889,7 +5889,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : } void UnsafeArenaSwap(EnumValueOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6218,7 +6218,7 @@ class PROTOBUF_EXPORT ServiceOptions final : } void UnsafeArenaSwap(ServiceOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6547,7 +6547,7 @@ class PROTOBUF_EXPORT MethodOptions final : } void UnsafeArenaSwap(MethodOptions* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -6908,7 +6908,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : } void UnsafeArenaSwap(UninterpretedOption_NamePart* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7083,7 +7083,7 @@ class PROTOBUF_EXPORT UninterpretedOption final : } void UnsafeArenaSwap(UninterpretedOption* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7335,7 +7335,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : } void UnsafeArenaSwap(SourceCodeInfo_Location* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7584,7 +7584,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final : } void UnsafeArenaSwap(SourceCodeInfo* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7748,7 +7748,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : } void UnsafeArenaSwap(GeneratedCodeInfo_Annotation* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -7988,7 +7988,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : } void UnsafeArenaSwap(GeneratedCodeInfo* other) { if (other == this) return; - GOOGLE_ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } @@ -8298,7 +8298,7 @@ inline void FileDescriptorProto::set_dependency(int index, std::string&& value) // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::set_dependency(int index, const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.dependency_.Mutable(index)->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::set_dependency(int index, absl::string_view value) { @@ -8322,7 +8322,7 @@ inline void FileDescriptorProto::add_dependency(std::string&& value) { // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::add_dependency(const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.dependency_.Add()->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::add_dependency(absl::string_view value) { @@ -9556,7 +9556,7 @@ inline void DescriptorProto::set_reserved_name(int index, std::string&& value) { // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::set_reserved_name(int index, const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Mutable(index)->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::set_reserved_name(int index, absl::string_view value) { @@ -9580,7 +9580,7 @@ inline void DescriptorProto::add_reserved_name(std::string&& value) { // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::add_reserved_name(const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Add()->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::add_reserved_name(absl::string_view value) { @@ -10661,7 +10661,7 @@ inline void EnumDescriptorProto::set_reserved_name(int index, std::string&& valu // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::set_reserved_name(int index, const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Mutable(index)->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::set_reserved_name(int index, absl::string_view value) { @@ -10685,7 +10685,7 @@ inline void EnumDescriptorProto::add_reserved_name(std::string&& value) { // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::add_reserved_name(const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Add()->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::add_reserved_name(absl::string_view value) { @@ -13880,7 +13880,7 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, st // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.leading_detached_comments_.Mutable(index)->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, absl::string_view value) { @@ -13904,7 +13904,7 @@ inline void SourceCodeInfo_Location::add_leading_detached_comments(std::string&& // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { - GOOGLE_ABSL_DCHECK(value != nullptr); _impl_.leading_detached_comments_.Add()->assign(value); + ABSL_DCHECK(value != nullptr); _impl_.leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::add_leading_detached_comments(absl::string_view value) { diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index cb4018b38dea..d7feb82e3077 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -54,7 +54,7 @@ namespace { void RecordMessageNames(const DescriptorProto& desc_proto, absl::string_view prefix, absl::btree_set* output) { - GOOGLE_ABSL_CHECK(desc_proto.has_name()); + ABSL_CHECK(desc_proto.has_name()); std::string full_name = prefix.empty() ? desc_proto.name() : absl::StrCat(prefix, ".", desc_proto.name()); @@ -84,7 +84,7 @@ bool ForAllFileProtos(DescriptorDatabase* db, Fn callback, for (const auto& f : file_names) { file_proto.Clear(); if (!db->FindFileByName(f, &file_proto)) { - GOOGLE_ABSL_LOG(ERROR) << "File not found in database (unexpected): " << f; + ABSL_LOG(ERROR) << "File not found in database (unexpected): " << f; return false; } callback(file_proto, &set); @@ -125,7 +125,7 @@ template bool SimpleDescriptorDatabase::DescriptorIndex::AddFile( const FileDescriptorProto& file, Value value) { if (!by_name_.emplace(file.name(), value).second) { - GOOGLE_ABSL_LOG(ERROR) << "File already exists in database: " << file.name(); + ABSL_LOG(ERROR) << "File already exists in database: " << file.name(); return false; } @@ -209,7 +209,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( // relies on the fact that '.' sorts before all other characters that are // valid in symbol names). if (!ValidateSymbolName(name)) { - GOOGLE_ABSL_LOG(ERROR) << "Invalid symbol name: " << name; + ABSL_LOG(ERROR) << "Invalid symbol name: " << name; return false; } @@ -224,7 +224,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( } if (IsSubSymbol(iter->first, name)) { - GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << name + ABSL_LOG(ERROR) << "Symbol name \"" << name << "\" conflicts with the existing " "symbol \"" << iter->first << "\"."; @@ -239,7 +239,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( ++iter; if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) { - GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << name + ABSL_LOG(ERROR) << "Symbol name \"" << name << "\" conflicts with the existing " "symbol \"" << iter->first << "\"."; @@ -281,7 +281,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddExtension( std::make_pair(field.extendee().substr(1), field.number()), value) .second) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "Extension conflicts with extension already in database: " "extend " << field.extendee() << " { " << field.name() << " = " @@ -570,7 +570,7 @@ bool EncodedDescriptorDatabase::Add(const void* encoded_file_descriptor, if (file.ParseFromArray(encoded_file_descriptor, size)) { return index_->AddFile(file, std::make_pair(encoded_file_descriptor, size)); } else { - GOOGLE_ABSL_LOG(ERROR) << "Invalid file descriptor data passed to " + ABSL_LOG(ERROR) << "Invalid file descriptor data passed to " "EncodedDescriptorDatabase::Add()."; return false; } @@ -642,7 +642,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file, all_values_.push_back({value.first, value.second, {}}); if (!ValidateSymbolName(file.package())) { - GOOGLE_ABSL_LOG(ERROR) << "Invalid package name: " << file.package(); + ABSL_LOG(ERROR) << "Invalid package name: " << file.package(); return false; } all_values_.back().encoded_package = EncodeString(file.package()); @@ -653,7 +653,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file, .second || std::binary_search(by_name_flat_.begin(), by_name_flat_.end(), file.name(), by_name_.key_comp())) { - GOOGLE_ABSL_LOG(ERROR) << "File already exists in database: " << file.name(); + ABSL_LOG(ERROR) << "File already exists in database: " << file.name(); return false; } @@ -680,7 +680,7 @@ static bool CheckForMutualSubsymbols(absl::string_view symbol_name, Iter* iter, Iter2 end, const Index& index) { if (*iter != end) { if (IsSubSymbol((*iter)->AsString(index), symbol_name)) { - GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name + ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name << "\" conflicts with the existing symbol \"" << (*iter)->AsString(index) << "\"."; return false; @@ -694,7 +694,7 @@ static bool CheckForMutualSubsymbols(absl::string_view symbol_name, Iter* iter, ++*iter; if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString(index))) { - GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name + ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name << "\" conflicts with the existing symbol \"" << (*iter)->AsString(index) << "\"."; return false; @@ -715,7 +715,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol( // relies on the fact that '.' sorts before all other characters that are // valid in symbol names). if (!ValidateSymbolName(symbol)) { - GOOGLE_ABSL_LOG(ERROR) << "Invalid symbol name: " << entry_as_string; + ABSL_LOG(ERROR) << "Invalid symbol name: " << entry_as_string; return false; } @@ -768,7 +768,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddExtension( by_extension_flat_.begin(), by_extension_flat_.end(), std::make_pair(field.extendee().substr(1), field.number()), by_extension_.key_comp())) { - GOOGLE_ABSL_LOG(ERROR) + ABSL_LOG(ERROR) << "Extension conflicts with extension already in database: " "extend " << field.extendee() << " { " << field.name() << " = " diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 4891f66df18f..f0335204461c 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -170,7 +170,7 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { // Adds the FileDescriptorProto to the database, making a copy. The object // can be deleted after Add() returns. Returns false if the file conflicted // with a file already in the database, in which case an error will have - // been written to GOOGLE_ABSL_LOG(ERROR). + // been written to ABSL_LOG(ERROR). bool Add(const FileDescriptorProto& file); // Adds the FileDescriptorProto to the database and takes ownership of it. diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 038aa00fcb67..2de814d58a03 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -44,6 +44,8 @@ #include "google/protobuf/descriptor.pb.h" #include "absl/container/btree_set.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/die_if_null.h" +#include "absl/log/scoped_mock_log.h" #include "absl/strings/str_format.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_custom_options.pb.h" @@ -56,8 +58,8 @@ #include #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "google/protobuf/unittest_lazy_dependencies.pb.h" #include "google/protobuf/unittest_lazy_dependencies_custom_option.pb.h" #include "google/protobuf/unittest_lazy_dependencies_enum.pb.h" @@ -2998,7 +3000,7 @@ class AllowUnknownDependenciesTest return pool_->FindFileByName(proto.name()); } } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return nullptr; } @@ -3223,7 +3225,7 @@ TEST_P(AllowUnknownDependenciesTest, const FileDescriptor* file = BuildFile(test_proto); ASSERT_TRUE(file != nullptr); - GOOGLE_ABSL_LOG(INFO) << file->DebugString(); + ABSL_LOG(INFO) << file->DebugString(); EXPECT_EQ(0, file->dependency_count()); ASSERT_EQ(1, file->message_type_count()); @@ -3932,7 +3934,7 @@ class ValidationErrorTest : public testing::Test { const FileDescriptor* BuildFile(const std::string& file_text) { FileDescriptorProto file_proto; EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto)); - return GOOGLE_CHECK_NOTNULL(pool_.BuildFile(file_proto)); + return ABSL_DIE_IF_NULL(pool_.BuildFile(file_proto)); } // Parse file_text as a FileDescriptorProto in text format and add it @@ -6096,7 +6098,7 @@ TEST_F(ValidationErrorTest, RollbackAfterError) { } TEST_F(ValidationErrorTest, ErrorsReportedToLogError) { - // Test that errors are reported to GOOGLE_ABSL_LOG(ERROR) if no error collector is + // Test that errors are reported to ABSL_LOG(ERROR) if no error collector is // provided. FileDescriptorProto file_proto; @@ -6105,19 +6107,15 @@ TEST_F(ValidationErrorTest, ErrorsReportedToLogError) { "message_type { name: \"Foo\" } " "message_type { name: \"Foo\" } ", &file_proto)); - - std::vector errors; - { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, + "Invalid proto descriptor for file \"foo.proto\":")); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, + " Foo: \"Foo\" is already defined.")); + log.StartCapturingLogs(); EXPECT_TRUE(pool_.BuildFile(file_proto) == nullptr); - errors = log.GetMessages(ERROR); } - - ASSERT_EQ(2, errors.size()); - - EXPECT_EQ("Invalid proto descriptor for file \"foo.proto\":", errors[0]); - EXPECT_EQ(" Foo: \"Foo\" is already defined.", errors[1]); } TEST_F(ValidationErrorTest, DisallowEnumAlias) { @@ -7350,15 +7348,13 @@ TEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) { ErrorDescriptorDatabase error_database; DescriptorPool pool(&error_database); - std::vector errors; - { - ScopedMemoryLog log; + absl::ScopedMockLog log; + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)) + .Times(testing::AtLeast(1)); + log.StartCapturingLogs(); EXPECT_TRUE(pool.FindFileByName("error.proto") == nullptr); - errors = log.GetMessages(ERROR); } - - EXPECT_FALSE(errors.empty()); } TEST_F(DatabaseBackedPoolTest, ErrorWithErrorCollector) { @@ -7543,11 +7539,11 @@ class ExponentialErrorDatabase : public DescriptorDatabase { absl::string_view end_with, int32_t* file_num) { if (!absl::ConsumePrefix(&name, begin_with)) return; if (!absl::ConsumeSuffix(&name, end_with)) return; - GOOGLE_ABSL_CHECK(absl::SimpleAtoi(name, file_num)); + ABSL_CHECK(absl::SimpleAtoi(name, file_num)); } bool PopulateFile(int file_num, FileDescriptorProto* output) { - GOOGLE_ABSL_CHECK_GE(file_num, 0); + ABSL_CHECK_GE(file_num, 0); output->Clear(); output->set_name(absl::Substitute("file$0.proto", file_num)); // file0.proto doesn't define Message0 @@ -7572,7 +7568,7 @@ TEST_F(DatabaseBackedPoolTest, DoesntReloadKnownBadFiles) { ExponentialErrorDatabase error_database; DescriptorPool pool(&error_database); - GOOGLE_ABSL_LOG(INFO) << "A timeout in this test probably indicates a real bug."; + ABSL_LOG(INFO) << "A timeout in this test probably indicates a real bug."; EXPECT_TRUE(pool.FindFileByName("file40.proto") == nullptr); EXPECT_TRUE(pool.FindMessageTypeByName("Message40") == nullptr); @@ -7617,7 +7613,7 @@ class AbortingErrorCollector : public DescriptorPool::ErrorCollector { void AddError(const std::string& filename, const std::string& element_name, const Message* message, ErrorLocation location, const std::string& error_message) override { - GOOGLE_ABSL_LOG(FATAL) << "AddError() called unexpectedly: " << filename << " [" + ABSL_LOG(FATAL) << "AddError() called unexpectedly: " << filename << " [" << element_name << "]: " << error_message; } }; @@ -7762,7 +7758,7 @@ TEST_F(SourceLocationTest, GetSourceLocation) { SourceLocation loc; const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); const Descriptor* a_desc = file_desc->FindMessageTypeByName("A"); EXPECT_TRUE(a_desc->GetSourceLocation(&loc)); @@ -7793,7 +7789,7 @@ TEST_F(SourceLocationTest, ExtensionSourceLocation) { SourceLocation loc; const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); const FieldDescriptor* int32_extension_desc = file_desc->FindExtensionByName("int32_extension"); @@ -7820,7 +7816,7 @@ TEST_F(SourceLocationTest, InterpretedOptionSourceLocation) { SourceLocation loc; const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); // File options { @@ -8183,7 +8179,7 @@ TEST_F(SourceLocationTest, GetSourceLocation_MissingSourceCodeInfo) { SourceLocation loc; const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); FileDescriptorProto proto; file_desc->CopyTo(&proto); // Note, this discards the SourceCodeInfo. @@ -8191,7 +8187,7 @@ TEST_F(SourceLocationTest, GetSourceLocation_MissingSourceCodeInfo) { DescriptorPool bad1_pool(&pool_); const FileDescriptor* bad1_file_desc = - GOOGLE_CHECK_NOTNULL(bad1_pool.BuildFile(proto)); + ABSL_DIE_IF_NULL(bad1_pool.BuildFile(proto)); const Descriptor* bad1_a_desc = bad1_file_desc->FindMessageTypeByName("A"); EXPECT_FALSE(bad1_a_desc->GetSourceLocation(&loc)); } @@ -8201,7 +8197,7 @@ TEST_F(SourceLocationTest, GetSourceLocation_BogusSourceCodeInfo) { SourceLocation loc; const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); FileDescriptorProto proto; file_desc->CopyTo(&proto); // Note, this discards the SourceCodeInfo. @@ -8217,7 +8213,7 @@ TEST_F(SourceLocationTest, GetSourceLocation_BogusSourceCodeInfo) { DescriptorPool bad2_pool(&pool_); const FileDescriptor* bad2_file_desc = - GOOGLE_CHECK_NOTNULL(bad2_pool.BuildFile(proto)); + ABSL_DIE_IF_NULL(bad2_pool.BuildFile(proto)); const Descriptor* bad2_a_desc = bad2_file_desc->FindMessageTypeByName("A"); EXPECT_FALSE(bad2_a_desc->GetSourceLocation(&loc)); } @@ -8248,7 +8244,7 @@ class CopySourceCodeInfoToTest : public testing::Test { TEST_F(CopySourceCodeInfoToTest, CopyTo_DoesNotCopySourceCodeInfo) { const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); FileDescriptorProto file_desc_proto; ASSERT_FALSE(file_desc_proto.has_source_code_info()); @@ -8258,7 +8254,7 @@ TEST_F(CopySourceCodeInfoToTest, CopyTo_DoesNotCopySourceCodeInfo) { TEST_F(CopySourceCodeInfoToTest, CopySourceCodeInfoTo) { const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); + ABSL_DIE_IF_NULL(pool_.FindFileByName("/test/test.proto")); FileDescriptorProto file_desc_proto; ASSERT_FALSE(file_desc_proto.has_source_code_info()); diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index b9f61d4e722f..16bebfd81572 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -178,7 +178,7 @@ int FieldSpaceUsed(const FieldDescriptor* field) { } } - GOOGLE_ABSL_LOG(DFATAL) << "Can't get here."; + ABSL_DLOG(FATAL) << "Can't get here."; return 0; } @@ -587,7 +587,7 @@ DynamicMessage::~DynamicMessage() { void DynamicMessage::CrossLinkPrototypes() { // This should only be called on the prototype message. - GOOGLE_ABSL_CHECK(is_prototype()); + ABSL_CHECK(is_prototype()); DynamicMessageFactory* factory = type_info_->factory; const Descriptor* descriptor = type_info_->type; diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index 737b3813d8e3..74a391cf2d02 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -162,7 +162,7 @@ class PROTOBUF_EXPORT DynamicMapSorter { #ifndef NDEBUG for (size_t j = 1; j < static_cast(map_size); j++) { if (!comparator(result[j - 1], result[j])) { - GOOGLE_ABSL_LOG(ERROR) << (comparator(result[j], result[j - 1]) + ABSL_LOG(ERROR) << (comparator(result[j], result[j - 1]) ? "internal error in map key sorting" : "map keys are not unique"); } @@ -211,7 +211,7 @@ class PROTOBUF_EXPORT DynamicMapSorter { return first < second; } default: - GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field."; + ABSL_DLOG(FATAL) << "Invalid key for map field."; return true; } } diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 42d0428f095d..7b6edf5d6bc4 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -59,7 +59,7 @@ namespace internal { namespace { inline WireFormatLite::FieldType real_type(FieldType type) { - GOOGLE_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); + ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); return static_cast(type); } @@ -92,7 +92,7 @@ void Register(const ExtensionInfo& info) { static auto local_static_registry = OnShutdownDelete(new ExtensionRegistry); global_registry = local_static_registry; if (!local_static_registry->insert(info).second) { - GOOGLE_ABSL_LOG(FATAL) << "Multiple extension registrations for type \"" + ABSL_LOG(FATAL) << "Multiple extension registrations for type \"" << info.message->GetTypeName() << "\", field number " << info.number << "."; } @@ -130,9 +130,9 @@ void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, bool is_packed, LazyEagerVerifyFnType verify_func) { - GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_ENUM); - GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE); - GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_GROUP); + ABSL_CHECK_NE(type, WireFormatLite::TYPE_ENUM); + ABSL_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE); + ABSL_CHECK_NE(type, WireFormatLite::TYPE_GROUP); ExtensionInfo info(extendee, number, type, is_repeated, is_packed, verify_func); Register(info); @@ -155,7 +155,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, bool is_packed, EnumValidityFunc* is_valid) { - GOOGLE_ABSL_CHECK_EQ(type, WireFormatLite::TYPE_ENUM); + ABSL_CHECK_EQ(type, WireFormatLite::TYPE_ENUM); ExtensionInfo info(extendee, number, type, is_repeated, is_packed, nullptr); info.enum_validity_check.func = CallNoArgValidityFunc; // See comment in CallNoArgValidityFunc() about why we use a c-style cast. @@ -168,7 +168,7 @@ void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee, bool is_repeated, bool is_packed, const MessageLite* prototype, LazyEagerVerifyFnType verify_func) { - GOOGLE_ABSL_CHECK(type == WireFormatLite::TYPE_MESSAGE || + ABSL_CHECK(type == WireFormatLite::TYPE_MESSAGE || type == WireFormatLite::TYPE_GROUP); ExtensionInfo info(extendee, number, type, is_repeated, is_packed, verify_func); @@ -219,7 +219,7 @@ void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat, bool ExtensionSet::Has(int number) const { const Extension* ext = FindOrNull(number); if (ext == nullptr) return false; - GOOGLE_ABSL_DCHECK(!ext->is_repeated); + ABSL_DCHECK(!ext->is_repeated); return !ext->is_cleared; } @@ -245,12 +245,12 @@ int ExtensionSet::ExtensionSize(int number) const { FieldType ExtensionSet::ExtensionType(int number) const { const Extension* ext = FindOrNull(number); if (ext == nullptr) { - GOOGLE_ABSL_LOG(DFATAL) + ABSL_DLOG(FATAL) << "Don't lookup extension types if they aren't present (1). "; return 0; } if (ext->is_cleared) { - GOOGLE_ABSL_LOG(DFATAL) + ABSL_DLOG(FATAL) << "Don't lookup extension types if they aren't present (2). "; } return ext->type; @@ -271,10 +271,10 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; } // namespace -#define GOOGLE_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ - GOOGLE_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, \ +#define ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ + ABSL_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, \ LABEL); \ - GOOGLE_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE) + ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE) // ------------------------------------------------------------------- // Primitives @@ -287,7 +287,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; if (extension == nullptr || extension->is_cleared) { \ return default_value; \ } else { \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ return extension->LOWERCASE##_value; \ } \ } \ @@ -298,7 +298,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; if (extension == nullptr || extension->is_cleared) { \ return default_value; \ } else { \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ return extension->LOWERCASE##_value; \ } \ } \ @@ -309,11 +309,11 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; Extension* extension; \ if (MaybeNewExtension(number, descriptor, &extension)) { \ extension->type = type; \ - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), \ + ABSL_DCHECK_EQ(cpp_type(extension->type), \ WireFormatLite::CPPTYPE_##UPPERCASE); \ extension->is_repeated = false; \ } else { \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \ } \ extension->is_cleared = false; \ extension->LOWERCASE##_value = value; \ @@ -322,27 +322,27 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; LOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) \ const { \ const Extension* extension = FindOrNull(number); \ - GOOGLE_ABSL_CHECK(extension != nullptr) \ + ABSL_CHECK(extension != nullptr) \ << "Index out-of-bounds (field is empty)."; \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ return extension->repeated_##LOWERCASE##_value->Get(index); \ } \ \ const LOWERCASE& ExtensionSet::GetRefRepeated##CAMELCASE(int number, \ int index) const { \ const Extension* extension = FindOrNull(number); \ - GOOGLE_ABSL_CHECK(extension != nullptr) \ + ABSL_CHECK(extension != nullptr) \ << "Index out-of-bounds (field is empty)."; \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ return extension->repeated_##LOWERCASE##_value->Get(index); \ } \ \ void ExtensionSet::SetRepeated##CAMELCASE(int number, int index, \ LOWERCASE value) { \ Extension* extension = FindOrNull(number); \ - GOOGLE_ABSL_CHECK(extension != nullptr) \ + ABSL_CHECK(extension != nullptr) \ << "Index out-of-bounds (field is empty)."; \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ extension->repeated_##LOWERCASE##_value->Set(index, value); \ } \ \ @@ -352,15 +352,15 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD }; Extension* extension; \ if (MaybeNewExtension(number, descriptor, &extension)) { \ extension->type = type; \ - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), \ + ABSL_DCHECK_EQ(cpp_type(extension->type), \ WireFormatLite::CPPTYPE_##UPPERCASE); \ extension->is_repeated = true; \ extension->is_packed = packed; \ extension->repeated_##LOWERCASE##_value = \ Arena::CreateMessage>(arena_); \ } else { \ - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ - GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, packed); \ + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \ + ABSL_DCHECK_EQ(extension->is_packed, packed); \ } \ extension->repeated_##LOWERCASE##_value->Add(value); \ } @@ -449,10 +449,10 @@ void* ExtensionSet::MutableRawRepeatedField(int number, FieldType field_type, } // Compatible version using old call signature. Does not create extensions when -// the don't already exist; instead, just GOOGLE_ABSL_CHECK-fails. +// the don't already exist; instead, just ABSL_CHECK-fails. void* ExtensionSet::MutableRawRepeatedField(int number) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Extension not found."; + ABSL_CHECK(extension != nullptr) << "Extension not found."; // We assume that all the RepeatedField<>* pointers have the same // size and alignment within the anonymous union in Extension. return extension->repeated_int32_t_value; @@ -467,7 +467,7 @@ int ExtensionSet::GetEnum(int number, int default_value) const { // Not present. Return the default value. return default_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); return extension->enum_value; } } @@ -479,7 +479,7 @@ const int& ExtensionSet::GetRefEnum(int number, // Not present. Return the default value. return default_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); return extension->enum_value; } } @@ -489,10 +489,10 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); extension->is_repeated = false; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM); } extension->is_cleared = false; extension->enum_value = value; @@ -500,22 +500,22 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value, int ExtensionSet::GetRepeatedEnum(int number, int index) const { const Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); return extension->repeated_enum_value->Get(index); } const int& ExtensionSet::GetRefRepeatedEnum(int number, int index) const { const Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); return extension->repeated_enum_value->Get(index); } void ExtensionSet::SetRepeatedEnum(int number, int index, int value) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); extension->repeated_enum_value->Set(index, value); } @@ -524,14 +524,14 @@ void ExtensionSet::AddEnum(int number, FieldType type, bool packed, int value, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); extension->is_repeated = true; extension->is_packed = packed; extension->repeated_enum_value = Arena::CreateMessage>(arena_); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); - GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, packed); + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM); + ABSL_DCHECK_EQ(extension->is_packed, packed); } extension->repeated_enum_value->Add(value); } @@ -546,7 +546,7 @@ const std::string& ExtensionSet::GetString( // Not present. Return the default value. return default_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING); return *extension->string_value; } } @@ -556,11 +556,11 @@ std::string* ExtensionSet::MutableString(int number, FieldType type, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); extension->is_repeated = false; extension->string_value = Arena::Create(arena_); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING); } extension->is_cleared = false; return extension->string_value; @@ -569,15 +569,15 @@ std::string* ExtensionSet::MutableString(int number, FieldType type, const std::string& ExtensionSet::GetRepeatedString(int number, int index) const { const Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); return extension->repeated_string_value->Get(index); } std::string* ExtensionSet::MutableRepeatedString(int number, int index) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); return extension->repeated_string_value->Mutable(index); } @@ -586,13 +586,13 @@ std::string* ExtensionSet::AddString(int number, FieldType type, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); extension->is_repeated = true; extension->is_packed = false; extension->repeated_string_value = Arena::CreateMessage>(arena_); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING); } return extension->repeated_string_value->Add(); } @@ -607,7 +607,7 @@ const MessageLite& ExtensionSet::GetMessage( // Not present. Return the default value. return default_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); if (extension->is_lazy) { return extension->lazymessage_value->GetMessage(default_value, arena_); } else { @@ -627,14 +627,14 @@ MessageLite* ExtensionSet::MutableMessage(int number, FieldType type, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); extension->is_repeated = false; extension->is_lazy = false; extension->message_value = prototype.New(arena_); extension->is_cleared = false; return extension->message_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); extension->is_cleared = false; if (extension->is_lazy) { return extension->lazymessage_value->MutableMessage(prototype, arena_); @@ -656,13 +656,13 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type, ClearExtension(number); return; } - GOOGLE_ABSL_DCHECK(message->GetOwningArena() == nullptr || + ABSL_DCHECK(message->GetOwningArena() == nullptr || message->GetOwningArena() == arena_); Arena* message_arena = message->GetOwningArena(); Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); extension->is_repeated = false; extension->is_lazy = false; if (message_arena == arena_) { @@ -675,7 +675,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type, extension->message_value->CheckTypeAndMergeFrom(*message); } } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); if (extension->is_lazy) { extension->lazymessage_value->SetAllocatedMessage(message, arena_); } else { @@ -706,12 +706,12 @@ void ExtensionSet::UnsafeArenaSetAllocatedMessage( Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); extension->is_repeated = false; extension->is_lazy = false; extension->message_value = message; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); if (extension->is_lazy) { extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message, arena_); @@ -732,7 +732,7 @@ MessageLite* ExtensionSet::ReleaseMessage(int number, // Not present. Return nullptr. return nullptr; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); MessageLite* ret = nullptr; if (extension->is_lazy) { ret = extension->lazymessage_value->ReleaseMessage(prototype, arena_); @@ -761,7 +761,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage( // Not present. Return nullptr. return nullptr; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE); MessageLite* ret = nullptr; if (extension->is_lazy) { ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(prototype, @@ -784,15 +784,15 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage( const MessageLite& ExtensionSet::GetRepeatedMessage(int number, int index) const { const Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); return extension->repeated_message_value->Get(index); } MessageLite* ExtensionSet::MutableRepeatedMessage(int number, int index) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); return extension->repeated_message_value->Mutable(index); } @@ -802,12 +802,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type, Extension* extension; if (MaybeNewExtension(number, descriptor, &extension)) { extension->type = type; - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); extension->is_repeated = true; extension->repeated_message_value = Arena::CreateMessage>(arena_); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); + ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE); } // RepeatedPtrField does not know how to Add() since it cannot @@ -827,12 +827,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type, // const Descriptor* message_type, // MessageFactory* factory) -#undef GOOGLE_ABSL_DCHECK_TYPE +#undef ABSL_DCHECK_TYPE void ExtensionSet::RemoveLast(int number) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK(extension->is_repeated); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK(extension->is_repeated); switch (cpp_type(extension->type)) { case WireFormatLite::CPPTYPE_INT32: @@ -870,24 +870,24 @@ void ExtensionSet::RemoveLast(int number) { MessageLite* ExtensionSet::ReleaseLast(int number) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK(extension->is_repeated); - GOOGLE_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK(extension->is_repeated); + ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE); return extension->repeated_message_value->ReleaseLast(); } MessageLite* ExtensionSet::UnsafeArenaReleaseLast(int number) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK(extension->is_repeated); - GOOGLE_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK(extension->is_repeated); + ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE); return extension->repeated_message_value->UnsafeArenaReleaseLast(); } void ExtensionSet::SwapElements(int number, int index1, int index2) { Extension* extension = FindOrNull(number); - GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; - GOOGLE_ABSL_DCHECK(extension->is_repeated); + ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; + ABSL_DCHECK(extension->is_repeated); switch (cpp_type(extension->type)) { case WireFormatLite::CPPTYPE_INT32: @@ -994,9 +994,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee, extension->is_packed = other_extension.is_packed; extension->is_repeated = true; } else { - GOOGLE_ABSL_DCHECK_EQ(extension->type, other_extension.type); - GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed); - GOOGLE_ABSL_DCHECK(extension->is_repeated); + ABSL_DCHECK_EQ(extension->type, other_extension.type); + ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed); + ABSL_DCHECK(extension->is_repeated); } switch (cpp_type(other_extension.type)) { @@ -1090,9 +1090,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee, *other_extension.message_value); } } else { - GOOGLE_ABSL_DCHECK_EQ(extension->type, other_extension.type); - GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed); - GOOGLE_ABSL_DCHECK(!extension->is_repeated); + ABSL_DCHECK_EQ(extension->type, other_extension.type); + ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed); + ABSL_DCHECK(!extension->is_repeated); if (other_extension.is_lazy) { if (extension->is_lazy) { extension->lazymessage_value->MergeFrom( @@ -1200,7 +1200,7 @@ void ExtensionSet::UnsafeShallowSwapExtension(ExtensionSet* other, int number) { if (this_ext == other_ext) return; - GOOGLE_ABSL_DCHECK_EQ(GetArena(), other->GetArena()); + ABSL_DCHECK_EQ(GetArena(), other->GetArena()); if (this_ext != nullptr && other_ext != nullptr) { std::swap(*this_ext, *other_ext); @@ -1396,7 +1396,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const { case WireFormatLite::TYPE_BYTES: case WireFormatLite::TYPE_GROUP: case WireFormatLite::TYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; + ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; break; } @@ -1497,7 +1497,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const { } int ExtensionSet::Extension::GetSize() const { - GOOGLE_ABSL_DCHECK(is_repeated); + ABSL_DCHECK(is_repeated); switch (cpp_type(type)) { #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ case WireFormatLite::CPPTYPE_##UPPERCASE: \ @@ -1516,7 +1516,7 @@ int ExtensionSet::Extension::GetSize() const { #undef HANDLE_TYPE } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return 0; } @@ -1665,7 +1665,7 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) { hint = new_map.large->insert(hint, {it->first, it->second}); } flat_size_ = static_cast(-1); - GOOGLE_ABSL_DCHECK(is_large()); + ABSL_DCHECK(is_large()); } else { new_map.flat = Arena::CreateArray(arena_, new_flat_capacity); std::copy(begin, end, new_map.flat); @@ -1755,7 +1755,7 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray( case WireFormatLite::TYPE_BYTES: case WireFormatLite::TYPE_GROUP: case WireFormatLite::TYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; + ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; break; } } else { @@ -1883,7 +1883,7 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray( uint8_t* target, io::EpsCopyOutputStream* stream) const { if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { // Not a valid MessageSet extension, but serialize it the normal way. - GOOGLE_ABSL_LOG(WARNING) << "Invalid message set extension."; + ABSL_LOG(WARNING) << "Invalid message set extension."; return InternalSerializeFieldWithCachedSizesToArray(extendee, extension_set, number, target, stream); } diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index b137b7cc3295..ee381e54fd7c 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -46,7 +46,7 @@ #include "google/protobuf/stubs/common.h" #include "absl/container/btree_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/port.h" #include "google/protobuf/port.h" #include "google/protobuf/io/coded_stream.h" @@ -321,7 +321,7 @@ class PROTOBUF_EXPORT ExtensionSet { // This is an overload of MutableRawRepeatedField to maintain compatibility // with old code using a previous API. This version of - // MutableRawRepeatedField() will GOOGLE_ABSL_CHECK-fail on a missing extension. + // MutableRawRepeatedField() will ABSL_CHECK-fail on a missing extension. // (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.) void* MutableRawRepeatedField(int number); @@ -790,7 +790,7 @@ class PROTOBUF_EXPORT ExtensionSet { return false; } - GOOGLE_ABSL_DCHECK(extension->type > 0 && + ABSL_DCHECK(extension->type > 0 && extension->type <= WireFormatLite::MAX_FIELD_TYPE); auto real_type = static_cast(extension->type); @@ -1257,7 +1257,7 @@ class EnumTypeTraits { } static inline void Set(int number, FieldType field_type, ConstType value, ExtensionSet* set) { - GOOGLE_ABSL_DCHECK(IsValid(value)); + ABSL_DCHECK(IsValid(value)); set->SetEnum(number, field_type, value, nullptr); } template @@ -1289,12 +1289,12 @@ class RepeatedEnumTypeTraits { } static inline void Set(int number, int index, ConstType value, ExtensionSet* set) { - GOOGLE_ABSL_DCHECK(IsValid(value)); + ABSL_DCHECK(IsValid(value)); set->SetRepeatedEnum(number, index, value); } static inline void Add(int number, FieldType field_type, bool is_packed, ConstType value, ExtensionSet* set) { - GOOGLE_ABSL_DCHECK(IsValid(value)); + ABSL_DCHECK(IsValid(value)); set->AddEnum(number, field_type, is_packed, value, nullptr); } static inline const RepeatedField& GetRepeated( diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index 7503d7d20156..32c2b86ac122 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -104,7 +104,7 @@ void ExtensionSet::AppendToList( } inline FieldDescriptor::Type real_type(FieldType type) { - GOOGLE_ABSL_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE); + ABSL_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE); return static_cast(type); } @@ -114,15 +114,15 @@ inline FieldDescriptor::CppType cpp_type(FieldType type) { } inline WireFormatLite::FieldType field_type(FieldType type) { - GOOGLE_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); + ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); return static_cast(type); } -#define GOOGLE_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ - GOOGLE_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \ +#define ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ + ABSL_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \ : FieldDescriptor::LABEL_OPTIONAL, \ FieldDescriptor::LABEL_##LABEL); \ - GOOGLE_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE) + ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE) const MessageLite& ExtensionSet::GetMessage(int number, const Descriptor* message_type, @@ -132,7 +132,7 @@ const MessageLite& ExtensionSet::GetMessage(int number, // Not present. Return the default value. return *factory->GetPrototype(message_type); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); if (extension->is_lazy) { return extension->lazymessage_value->GetMessage( *factory->GetPrototype(message_type), arena_); @@ -147,7 +147,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor, Extension* extension; if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) { extension->type = descriptor->type(); - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); extension->is_repeated = false; extension->is_packed = false; const MessageLite* prototype = @@ -157,7 +157,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor, extension->is_cleared = false; return extension->message_value; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); extension->is_cleared = false; if (extension->is_lazy) { return extension->lazymessage_value->MutableMessage( @@ -175,7 +175,7 @@ MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor, // Not present. Return nullptr. return nullptr; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); MessageLite* ret = nullptr; if (extension->is_lazy) { ret = extension->lazymessage_value->ReleaseMessage( @@ -203,7 +203,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage( // Not present. Return nullptr. return nullptr; } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); + ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); MessageLite* ret = nullptr; if (extension->is_lazy) { ret = extension->lazymessage_value->UnsafeArenaReleaseMessage( @@ -224,12 +224,12 @@ ExtensionSet::Extension* ExtensionSet::MaybeNewRepeatedExtension( Extension* extension; if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) { extension->type = descriptor->type(); - GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); + ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); extension->is_repeated = true; extension->repeated_message_value = Arena::CreateMessage >(arena_); } else { - GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED, MESSAGE); + ABSL_DCHECK_TYPE(*extension, REPEATED, MESSAGE); } return extension; } @@ -248,7 +248,7 @@ MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor, const MessageLite* prototype; if (extension->repeated_message_value->empty()) { prototype = factory->GetPrototype(descriptor->message_type()); - GOOGLE_ABSL_CHECK(prototype != nullptr); + ABSL_CHECK(prototype != nullptr); } else { prototype = &extension->repeated_message_value->Get(0); } @@ -290,7 +290,7 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) { if (extension->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { output->message_info.prototype = factory_->GetPrototype(extension->message_type()); - GOOGLE_ABSL_CHECK(output->message_info.prototype != nullptr) + ABSL_CHECK(output->message_info.prototype != nullptr) << "Extension factory's GetPrototype() returned nullptr; extension: " << extension->full_name(); } else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h index 29a944f52976..f7dc8300fd4f 100644 --- a/src/google/protobuf/extension_set_inl.h +++ b/src/google/protobuf/extension_set_inl.h @@ -76,7 +76,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( case WireFormatLite::TYPE_BYTES: case WireFormatLite::TYPE_GROUP: case WireFormatLite::TYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; + ABSL_LOG(FATAL) << "Non-primitive types can't be packed."; break; } } else { diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 3cef638ce0a7..ccd1c9b8d5cf 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -1186,7 +1186,7 @@ TEST(ExtensionSetTest, AbsentExtension) { .bb()); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(ExtensionSetTest, InvalidEnumDeath) { unittest::TestAllExtensions message; @@ -1196,7 +1196,7 @@ TEST(ExtensionSetTest, InvalidEnumDeath) { "IsValid"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(ExtensionSetTest, DynamicExtensions) { // Test adding a dynamic extension to a compiled-in message object. diff --git a/src/google/protobuf/generated_message_bases.cc b/src/google/protobuf/generated_message_bases.cc index c79c44553cf1..ebc4127526eb 100644 --- a/src/google/protobuf/generated_message_bases.cc +++ b/src/google/protobuf/generated_message_bases.cc @@ -101,7 +101,7 @@ ::uint8_t* ZeroFieldsBase::_InternalSerialize( void ZeroFieldsBase::MergeImpl(Message& to_param, const Message& from_param) { auto* to = static_cast(&to_param); const auto* from = static_cast(&from_param); - GOOGLE_ABSL_DCHECK_NE(from, to); + ABSL_DCHECK_NE(from, to); to->_internal_metadata_.MergeFrom(from->_internal_metadata_); } diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index babcc194b40e..80a3eb5e914c 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -43,8 +43,8 @@ #include "absl/base/casts.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" @@ -178,7 +178,7 @@ using internal::GetPointerAtOffset; void ReportReflectionUsageError(const Descriptor* descriptor, const FieldDescriptor* field, const char* method, const char* description) { - GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n" + ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n" " Method : google::protobuf::Reflection::" << method << "\n" @@ -200,7 +200,7 @@ const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = { static void ReportReflectionUsageTypeError( const Descriptor* descriptor, const FieldDescriptor* field, const char* method, FieldDescriptor::CppType expected_type) { - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n" " Method : google::protobuf::Reflection::" << method @@ -222,7 +222,7 @@ static void ReportReflectionUsageTypeError( static void ReportReflectionUsageEnumTypeError( const Descriptor* descriptor, const FieldDescriptor* field, const char* method, const EnumValueDescriptor* value) { - GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n" + ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n" " Method : google::protobuf::Reflection::" << method << "\n" @@ -509,7 +509,7 @@ struct OneofFieldMover { } break; default: - GOOGLE_ABSL_LOG(FATAL) << "unimplemented type: " << field->cpp_type(); + ABSL_LOG(FATAL) << "unimplemented type: " << field->cpp_type(); } if (unsafe_shallow_swap) { // Not clearing oneof case after move may cause unwanted "ClearOneof" @@ -593,7 +593,7 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs, auto* lhs_string = r->MutableRaw(lhs, field); auto* rhs_string = r->MutableRaw(rhs, field); uint32_t index = r->schema_.InlinedStringIndex(field); - GOOGLE_ABSL_DCHECK_GT(index, 0); + ABSL_DCHECK_GT(index, 0); uint32_t* lhs_array = r->MutableInlinedStringDonatedArray(lhs); uint32_t* rhs_array = r->MutableInlinedStringDonatedArray(rhs); uint32_t* lhs_state = &lhs_array[index / 32]; @@ -764,7 +764,7 @@ void SwapFieldHelper::SwapNonMessageNonStringField( SWAP_VALUES(ENUM, int); #undef SWAP_VALUES default: - GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); + ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); } } @@ -800,7 +800,7 @@ void Reflection::SwapField(Message* message1, Message* message2, break; default: - GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); + ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); } } else { switch (field->cpp_type()) { @@ -863,7 +863,7 @@ void Reflection::UnsafeShallowSwapField(Message* message1, Message* message2, break; default: - GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); + ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); } } @@ -957,7 +957,7 @@ void Reflection::SwapOneofField(Message* lhs, Message* rhs, const FieldDescriptor* field; }; - GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic()); + ABSL_DCHECK(!oneof_descriptor->is_synthetic()); uint32_t oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor); uint32_t oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor); @@ -998,7 +998,7 @@ void Reflection::Swap(Message* message1, Message* message2) const { if (message1 == message2) return; // TODO(kenton): Other Reflection methods should probably check this too. - GOOGLE_ABSL_CHECK_EQ(message1->GetReflection(), this) + ABSL_CHECK_EQ(message1->GetReflection(), this) << "First argument to Swap() (of type \"" << message1->GetDescriptor()->full_name() << "\") is not compatible with this reflection object (which is for type " @@ -1006,7 +1006,7 @@ void Reflection::Swap(Message* message1, Message* message2) const { << descriptor_->full_name() << "\"). Note that the exact same class is required; not just the same " "descriptor."; - GOOGLE_ABSL_CHECK_EQ(message2->GetReflection(), this) + ABSL_CHECK_EQ(message2->GetReflection(), this) << "Second argument to Swap() (of type \"" << message2->GetDescriptor()->full_name() << "\") is not compatible with this reflection object (which is for type " @@ -1053,7 +1053,7 @@ void Reflection::SwapFieldsImpl( if (message1 == message2) return; // TODO(kenton): Other Reflection methods should probably check this too. - GOOGLE_ABSL_CHECK_EQ(message1->GetReflection(), this) + ABSL_CHECK_EQ(message1->GetReflection(), this) << "First argument to SwapFields() (of type \"" << message1->GetDescriptor()->full_name() << "\") is not compatible with this reflection object (which is for type " @@ -1061,7 +1061,7 @@ void Reflection::SwapFieldsImpl( << descriptor_->full_name() << "\"). Note that the exact same class is required; not just the same " "descriptor."; - GOOGLE_ABSL_CHECK_EQ(message2->GetReflection(), this) + ABSL_CHECK_EQ(message2->GetReflection(), this) << "Second argument to SwapFields() (of type \"" << message2->GetDescriptor()->full_name() << "\") is not compatible with this reflection object (which is for type " @@ -1106,7 +1106,7 @@ void Reflection::SwapFieldsImpl( SwapBit(message1, message2, field); if (field->options().ctype() == FieldOptions::STRING && IsInlined(field)) { - GOOGLE_ABSL_DCHECK(!unsafe_shallow_swap || + ABSL_DCHECK(!unsafe_shallow_swap || message1->GetArenaForAllocation() == message2->GetArenaForAllocation()); SwapInlinedStringDonated(message1, message2, field); @@ -1126,7 +1126,7 @@ void Reflection::SwapFields( void Reflection::UnsafeShallowSwapFields( Message* message1, Message* message2, const std::vector& fields) const { - GOOGLE_ABSL_DCHECK_EQ(message1->GetArenaForAllocation(), + ABSL_DCHECK_EQ(message1->GetArenaForAllocation(), message2->GetArenaForAllocation()); SwapFieldsImpl(message1, message2, fields); @@ -1135,7 +1135,7 @@ void Reflection::UnsafeShallowSwapFields( void Reflection::UnsafeArenaSwapFields( Message* lhs, Message* rhs, const std::vector& fields) const { - GOOGLE_ABSL_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation()); + ABSL_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation()); UnsafeShallowSwapFields(lhs, rhs, fields); } @@ -1158,7 +1158,7 @@ bool Reflection::HasField(const Message& message, } void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const { - GOOGLE_ABSL_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena()); + ABSL_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena()); InternalSwap(lhs, rhs); } @@ -1227,7 +1227,7 @@ void Reflection::InternalSwap(Message* lhs, Message* rhs) const { ? 0 // One extra bit for the arena dtor tracking. : (inlined_string_count + 1 + 31) / 32; - GOOGLE_ABSL_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0, + ABSL_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0, (rhs_donated_array[0] & 0x1u) == 0); for (int i = 0; i < donated_array_size; i++) { std::swap(lhs_donated_array[i], rhs_donated_array[i]); @@ -1279,7 +1279,7 @@ int Reflection::FieldSize(const Message& message, } } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return 0; } } @@ -1535,7 +1535,7 @@ struct FieldNumberSorter { }; bool IsIndexInHasBitSet(const uint32_t* has_bit_set, uint32_t has_bit_index) { - GOOGLE_ABSL_DCHECK_NE(has_bit_index, ~0u); + ABSL_DCHECK_NE(has_bit_index, ~0u); return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) & static_cast(1)) != 0; } @@ -1622,14 +1622,14 @@ void Reflection::ListFields(const Message& message, // Descriptors of ExtensionSet are appended in their increasing order. GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_, output); - GOOGLE_ABSL_DCHECK(std::is_sorted(output->begin() + last_size, output->end(), + ABSL_DCHECK(std::is_sorted(output->begin() + last_size, output->end(), FieldNumberSorter())); if (output->size() != last_size) { CheckInOrder((*output)[last_size], &last); } } if (last != UINT32_MAX) { - GOOGLE_ABSL_DCHECK( + ABSL_DCHECK( std::is_sorted(output->begin(), output->end(), FieldNumberSorter())); } else { // ListFields() must sort output by field number. @@ -1772,7 +1772,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field, case FieldOptions::STRING: { if (IsInlined(field)) { const uint32_t index = schema_.InlinedStringIndex(field); - GOOGLE_ABSL_DCHECK_GT(index, 0); + ABSL_DCHECK_GT(index, 0); uint32_t* states = &MutableInlinedStringDonatedArray(message)[index / 32]; uint32_t mask = ~(static_cast(1) << (index % 32)); @@ -2148,7 +2148,7 @@ void Reflection::UnsafeArenaSetAllocatedMessage( void Reflection::SetAllocatedMessage(Message* message, Message* sub_message, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK( + ABSL_DCHECK( sub_message == nullptr || sub_message->GetOwningArena() == nullptr || sub_message->GetOwningArena() == message->GetArenaForAllocation()); @@ -2356,7 +2356,7 @@ void* Reflection::MutableRawRepeatedField(Message* message, ReportReflectionUsageTypeError(descriptor_, field, "MutableRawRepeatedField", cpptype); if (desc != nullptr) - GOOGLE_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type"; + ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type"; if (field->is_extension()) { return MutableExtensionSet(message)->MutableRawRepeatedField( field->number(), field->type(), field->is_packed(), field); @@ -2380,9 +2380,9 @@ const void* Reflection::GetRawRepeatedField(const Message& message, ReportReflectionUsageTypeError(descriptor_, field, "GetRawRepeatedField", cpptype); if (ctype >= 0) - GOOGLE_ABSL_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch"; + ABSL_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch"; if (desc != nullptr) - GOOGLE_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type"; + ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type"; if (field->is_extension()) { // Should use extension_set::GetRawRepeatedField. However, the required // parameter "default repeated value" is not very easy to get here. @@ -2506,7 +2506,7 @@ const Type& Reflection::GetRawNonOneof(const Message& message, } void Reflection::PrepareSplitMessageForWrite(Message* message) const { - GOOGLE_ABSL_DCHECK_NE(message, schema_.default_instance_); + ABSL_DCHECK_NE(message, schema_.default_instance_); void** split = MutableSplitField(message); const void* default_split = GetSplitField(schema_.default_instance_); if (*split == default_split) { @@ -2542,18 +2542,18 @@ Type* Reflection::MutableRaw(Message* message, } const uint32_t* Reflection::GetHasBits(const Message& message) const { - GOOGLE_ABSL_DCHECK(schema_.HasHasbits()); + ABSL_DCHECK(schema_.HasHasbits()); return &GetConstRefAtOffset(message, schema_.HasBitsOffset()); } uint32_t* Reflection::MutableHasBits(Message* message) const { - GOOGLE_ABSL_DCHECK(schema_.HasHasbits()); + ABSL_DCHECK(schema_.HasHasbits()); return GetPointerAtOffset(message, schema_.HasBitsOffset()); } uint32_t* Reflection::MutableOneofCase( Message* message, const OneofDescriptor* oneof_descriptor) const { - GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic()); + ABSL_DCHECK(!oneof_descriptor->is_synthetic()); return GetPointerAtOffset( message, schema_.GetOneofCaseOffset(oneof_descriptor)); } @@ -2581,13 +2581,13 @@ InternalMetadata* Reflection::MutableInternalMetadata(Message* message) const { const uint32_t* Reflection::GetInlinedStringDonatedArray( const Message& message) const { - GOOGLE_ABSL_DCHECK(schema_.HasInlinedString()); + ABSL_DCHECK(schema_.HasInlinedString()); return &GetConstRefAtOffset(message, schema_.InlinedStringDonatedOffset()); } uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const { - GOOGLE_ABSL_DCHECK(schema_.HasInlinedString()); + ABSL_DCHECK(schema_.HasInlinedString()); return GetPointerAtOffset(message, schema_.InlinedStringDonatedOffset()); } @@ -2596,7 +2596,7 @@ uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const { bool Reflection::IsInlinedStringDonated(const Message& message, const FieldDescriptor* field) const { uint32_t index = schema_.InlinedStringIndex(field); - GOOGLE_ABSL_DCHECK_GT(index, 0); + ABSL_DCHECK_GT(index, 0); return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), index); } @@ -2625,11 +2625,11 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs, // If one is undonated, both must have already registered ArenaDtor. uint32_t* lhs_array = MutableInlinedStringDonatedArray(lhs); uint32_t* rhs_array = MutableInlinedStringDonatedArray(rhs); - GOOGLE_ABSL_CHECK_EQ(lhs_array[0] & 0x1u, 0u); - GOOGLE_ABSL_CHECK_EQ(rhs_array[0] & 0x1u, 0u); + ABSL_CHECK_EQ(lhs_array[0] & 0x1u, 0u); + ABSL_CHECK_EQ(rhs_array[0] & 0x1u, 0u); // Swap donation status bit. uint32_t index = schema_.InlinedStringIndex(field); - GOOGLE_ABSL_DCHECK_GT(index, 0); + ABSL_DCHECK_GT(index, 0); if (rhs_donated) { SetInlinedStringDonated(index, lhs_array); ClearInlinedStringDonated(index, rhs_array); @@ -2642,7 +2642,7 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs, // Simple accessors for manipulating has_bits_. bool Reflection::HasBit(const Message& message, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!field->options().weak()); + ABSL_DCHECK(!field->options().weak()); if (schema_.HasBitIndex(field) != static_cast(-1)) { return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field)); } @@ -2701,13 +2701,13 @@ bool Reflection::HasBit(const Message& message, // handled above; avoid warning break; } - GOOGLE_ABSL_LOG(FATAL) << "Reached impossible case in HasBit()."; + ABSL_LOG(FATAL) << "Reached impossible case in HasBit()."; return false; } } void Reflection::SetBit(Message* message, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!field->options().weak()); + ABSL_DCHECK(!field->options().weak()); const uint32_t index = schema_.HasBitIndex(field); if (index == static_cast(-1)) return; MutableHasBits(message)[index / 32] |= @@ -2716,7 +2716,7 @@ void Reflection::SetBit(Message* message, const FieldDescriptor* field) const { void Reflection::ClearBit(Message* message, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!field->options().weak()); + ABSL_DCHECK(!field->options().weak()); const uint32_t index = schema_.HasBitIndex(field); if (index == static_cast(-1)) return; MutableHasBits(message)[index / 32] &= @@ -2725,7 +2725,7 @@ void Reflection::ClearBit(Message* message, void Reflection::SwapBit(Message* message1, Message* message2, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!field->options().weak()); + ABSL_DCHECK(!field->options().weak()); if (!schema_.HasHasbits()) { return; } @@ -2919,15 +2919,15 @@ void* Reflection::RepeatedFieldData(Message* message, const FieldDescriptor* field, FieldDescriptor::CppType cpp_type, const Descriptor* message_type) const { - GOOGLE_ABSL_CHECK(field->is_repeated()); - GOOGLE_ABSL_CHECK(field->cpp_type() == cpp_type || + ABSL_CHECK(field->is_repeated()); + ABSL_CHECK(field->cpp_type() == cpp_type || (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM && cpp_type == FieldDescriptor::CPPTYPE_INT32)) << "The type parameter T in RepeatedFieldRef API doesn't match " << "the actual field type (for enums T should be the generated enum " << "type or int32_t)."; if (message_type != nullptr) { - GOOGLE_ABSL_CHECK_EQ(message_type, field->message_type()); + ABSL_CHECK_EQ(message_type, field->message_type()); } if (field->is_extension()) { return MutableExtensionSet(message)->MutableRawRepeatedField( @@ -3074,7 +3074,7 @@ static internal::TailCallParseFunc GetFastParseFunction( }; auto it = map->find(name); if (it == map->end()) { - GOOGLE_ABSL_LOG(DFATAL) << "Failed to find function: " << name; + ABSL_DLOG(FATAL) << "Failed to find function: " << name; // Let's not crash in opt, just in case. // MiniParse is always a valid parser. return &internal::TcParser::MiniParse; @@ -3095,7 +3095,7 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTableForMessageSet() auto* full_table = ::new (p) Table{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, schema_.default_instance_, nullptr}, {{{&internal::TcParser::ReflectionParseLoop, {}}}}}; - GOOGLE_ABSL_DCHECK_EQ(static_cast(&full_table->header), + ABSL_DCHECK_EQ(static_cast(&full_table->header), static_cast(full_table)); return &full_table->header; } @@ -3197,7 +3197,7 @@ void Reflection::PopulateTcParseFieldAux( break; case internal::TailCallTableInfo::kSubTable: case internal::TailCallTableInfo::kSubMessageWeak: - GOOGLE_ABSL_LOG(FATAL) << "Not supported"; + ABSL_LOG(FATAL) << "Not supported"; break; case internal::TailCallTableInfo::kSubMessage: field_aux++->message_default_p = @@ -3208,7 +3208,7 @@ void Reflection::PopulateTcParseFieldAux( aux_entry.enum_range.size}; break; case internal::TailCallTableInfo::kEnumValidator: - GOOGLE_ABSL_LOG(FATAL) << "Not supported."; + ABSL_LOG(FATAL) << "Not supported."; break; case internal::TailCallTableInfo::kNumericOffset: field_aux++->offset = aux_entry.offset; @@ -3273,7 +3273,7 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const { inlined_string_indices); const size_t fast_entries_count = table_info.fast_path_fields.size(); - GOOGLE_ABSL_CHECK_EQ(fast_entries_count, 1 << table_info.table_size_log2); + ABSL_CHECK_EQ(fast_entries_count, 1 << table_info.table_size_log2); const uint16_t lookup_table_offset = AlignTo( sizeof(TcParseTableBase) + fast_entries_count * sizeof(TcParseTableBase::FastFieldEntry)); @@ -3316,7 +3316,7 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const { table_info.field_name_data.size()); } // Validation to make sure we used all the bytes correctly. - GOOGLE_ABSL_CHECK_EQ(res->name_data() + table_info.field_name_data.size() - + ABSL_CHECK_EQ(res->name_data() + table_info.field_name_data.size() - reinterpret_cast(res), byte_size); @@ -3472,7 +3472,7 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { const FileDescriptor* file = DescriptorPool::internal_generated_pool()->FindFileByName( table->filename); - GOOGLE_ABSL_CHECK(file != nullptr); + ABSL_CHECK(file != nullptr); MessageFactory* factory = MessageFactory::generated_factory(); diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 4561a9439be6..2f18639dbc83 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -140,7 +140,7 @@ struct ReflectionSchema { // Offset of a non-oneof field. Getting a field offset is slightly more // efficient when we know statically that it is not a oneof field. uint32_t GetFieldOffsetNonOneof(const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!InRealOneof(field)); + ABSL_DCHECK(!InRealOneof(field)); return OffsetValue(offsets_[field->index()], field->type()); } @@ -172,13 +172,13 @@ struct ReflectionSchema { // Bit index within the bit array of hasbits. Bit order is low-to-high. uint32_t HasBitIndex(const FieldDescriptor* field) const { if (has_bits_offset_ == -1) return static_cast(-1); - GOOGLE_ABSL_DCHECK(HasHasbits()); + ABSL_DCHECK(HasHasbits()); return has_bit_indices_[field->index()]; } // Byte offset of the hasbits array. uint32_t HasBitsOffset() const { - GOOGLE_ABSL_DCHECK(HasHasbits()); + ABSL_DCHECK(HasHasbits()); return static_cast(has_bits_offset_); } @@ -187,13 +187,13 @@ struct ReflectionSchema { // Bit index within the bit array of _inlined_string_donated_. Bit order is // low-to-high. uint32_t InlinedStringIndex(const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(HasInlinedString()); + ABSL_DCHECK(HasInlinedString()); return inlined_string_indices_[field->index()]; } // Byte offset of the _inlined_string_donated_ array. uint32_t InlinedStringDonatedOffset() const { - GOOGLE_ABSL_DCHECK(HasInlinedString()); + ABSL_DCHECK(HasInlinedString()); return static_cast(inlined_string_donated_offset_); } @@ -210,7 +210,7 @@ struct ReflectionSchema { // The offset of the ExtensionSet in this message. uint32_t GetExtensionSetOffset() const { - GOOGLE_ABSL_DCHECK(HasExtensionSet()); + ABSL_DCHECK(HasExtensionSet()); return static_cast(extensions_offset_); } @@ -231,7 +231,7 @@ struct ReflectionSchema { // Returns true if the field is implicitly backed by LazyField. bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE); + ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE); (void)field; return false; } @@ -245,12 +245,12 @@ struct ReflectionSchema { // Byte offset of _split_. uint32_t SplitOffset() const { - GOOGLE_ABSL_DCHECK(IsSplit()); + ABSL_DCHECK(IsSplit()); return static_cast(split_offset_); } uint32_t SizeofSplit() const { - GOOGLE_ABSL_DCHECK(IsSplit()); + ABSL_DCHECK(IsSplit()); return static_cast(sizeof_split_); } diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 639796caa860..f707cf5b95a3 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -51,7 +51,7 @@ #include #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/cord.h" #include "google/protobuf/map_test_util.h" #include "google/protobuf/map_unittest.pb.h" @@ -101,7 +101,7 @@ using ::testing::Property; const FieldDescriptor* F(const std::string& name) { const FieldDescriptor* result = unittest::TestAllTypes::descriptor()->FindFieldByName(name); - GOOGLE_ABSL_CHECK(result != nullptr); + ABSL_CHECK(result != nullptr); return result; } @@ -1273,7 +1273,7 @@ TEST(GeneratedMessageReflectionTest, ArenaReleaseOneofMessageTest) { EXPECT_TRUE(released == nullptr); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(GeneratedMessageReflectionTest, UsageErrors) { unittest::TestAllTypes message; @@ -1320,7 +1320,7 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) { " Problem : Field does not match message type."); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST using internal::IsDescendant; diff --git a/src/google/protobuf/generated_message_tctable_gen.cc b/src/google/protobuf/generated_message_tctable_gen.cc index fc1cd658a9f5..b829bb761ecd 100644 --- a/src/google/protobuf/generated_message_tctable_gen.cc +++ b/src/google/protobuf/generated_message_tctable_gen.cc @@ -53,7 +53,7 @@ namespace { bool GetEnumValidationRange(const EnumDescriptor* enum_type, int16_t& start, uint16_t& size) { - GOOGLE_ABSL_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString(); + ABSL_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString(); // Check if the enum values are a single, contiguous range. std::vector enum_values; @@ -149,7 +149,7 @@ void PopulateFastFieldEntry(const TailCallTableInfo::FieldEntryInfo& entry, name.append("c"); } else if (options.is_string_inlined) { name.append("i"); - GOOGLE_ABSL_CHECK(!field->is_repeated()); + ABSL_CHECK(!field->is_repeated()); aux_idx = static_cast(entry.inlined_string_idx); } } @@ -203,7 +203,7 @@ bool IsFieldEligibleForFastParsing( return false; } if (options.is_string_inlined) { - GOOGLE_ABSL_CHECK(!field->is_repeated()); + ABSL_CHECK(!field->is_repeated()); // For inlined strings, the donation state index is stored in the // `aux_idx` field of the fast parsing info. We need to check the range // of that value instead of the auxiliary index. @@ -218,7 +218,7 @@ bool IsFieldEligibleForFastParsing( if (cpp::HasHasbit(field)) { // The tailcall parser can only update the first 32 hasbits. Fields with // has-bits beyond the first 32 are handled by mini parsing/fallback. - GOOGLE_ABSL_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString(); + ABSL_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString(); if (entry.hasbit_idx >= 32) return false; } @@ -253,7 +253,7 @@ absl::optional GetEndGroupTag(const Descriptor* descriptor) { } uint32_t RecodeTagForFastParsing(uint32_t tag) { - GOOGLE_ABSL_DCHECK_LE(tag, 0x3FFF); + ABSL_DCHECK_LE(tag, 0x3FFF); // Construct the varint-coded tag. If it is more than 7 bits, we need to // shift the high bits and add a continue bit. if (uint32_t hibits = tag & 0xFFFFFF80) { @@ -316,7 +316,7 @@ std::vector SplitFastFieldsForSize( } // Fill in this field's entry: - GOOGLE_ABSL_CHECK(info.func_name.empty()) << info.func_name; + ABSL_CHECK(info.func_name.empty()) << info.func_name; PopulateFastFieldEntry(entry, options, info); info.field = field; info.coded_tag = tag; @@ -478,7 +478,7 @@ TailCallTableInfo::NumToEntryTable MakeNumToEntryTable( for (; field_entry_index != N; ++field_entry_index) { auto* field_descriptor = field_descriptors[field_entry_index]; uint32_t fnum = static_cast(field_descriptor->number()); - GOOGLE_ABSL_CHECK_GT(fnum, last_skip_entry_start); + ABSL_CHECK_GT(fnum, last_skip_entry_start); if (start_new_block == false) { // If the next field number is within 15 of the last_skip_entry_start, we // continue writing just to that entry. If it's between 16 and 31 more, @@ -760,7 +760,7 @@ TailCallTableInfo::TailCallTableInfo( } else if ((field->type() == FieldDescriptor::TYPE_STRING || field->type() == FieldDescriptor::TYPE_BYTES) && options.is_string_inlined) { - GOOGLE_ABSL_CHECK(!field->is_repeated()); + ABSL_CHECK(!field->is_repeated()); // Inlined strings have an extra marker to represent their donation state. int idx = inlined_string_indices[static_cast(field->index())]; // For mini parsing, the donation state index is stored as an `offset` @@ -781,7 +781,7 @@ TailCallTableInfo::TailCallTableInfo( size_t try_size = 1 << try_size_log2; auto split_fields = SplitFastFieldsForSize(end_group_tag, field_entries, try_size_log2, option_provider); - GOOGLE_ABSL_CHECK_EQ(split_fields.size(), try_size); + ABSL_CHECK_EQ(split_fields.size(), try_size); int try_num_fast_fields = 0; for (const auto& info : split_fields) { if (info.field != nullptr) ++try_num_fast_fields; @@ -818,7 +818,7 @@ TailCallTableInfo::TailCallTableInfo( ); num_to_entry_table = MakeNumToEntryTable(ordered_fields); - GOOGLE_ABSL_CHECK_EQ(field_entries.size(), ordered_fields.size()); + ABSL_CHECK_EQ(field_entries.size(), ordered_fields.size()); field_name_data = GenerateFieldNames(descriptor, field_entries); // If there are no fallback fields, and at most one extension range, the diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h index 0bd0d1e1e673..3d4edc50b37d 100644 --- a/src/google/protobuf/generated_message_tctable_impl.h +++ b/src/google/protobuf/generated_message_tctable_impl.h @@ -393,7 +393,7 @@ class PROTOBUF_EXPORT TcParser final { static_assert(sizeof(FieldType) == 1 || sizeof(FieldType) == 4 || sizeof(FieldType) == 8, ""); - std::abort(); // unreachable + ABSL_LOG(FATAL) << "This should be unreachable"; } // Functions referenced by generated fast tables (closed enum): @@ -777,7 +777,7 @@ Parse64FallbackPair(const char* p, int64_t res1) { // // Just as importantly, by keeping results in res1, res2, and res3, we take // advantage of the superscalar abilities of the CPU. - GOOGLE_ABSL_DCHECK_EQ(res1 >> 7, -1); + ABSL_DCHECK_EQ(res1 >> 7, -1); uint64_t ones = res1; // save the high 1 bits from res1 (input to SHLD) int64_t res2, res3; // accumulated result chunks diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index b14333725ea0..5c2486fb074f 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -59,13 +59,13 @@ using FieldEntry = TcParseTableBase::FieldEntry; #ifndef NDEBUG void AlignFail(std::integral_constant, std::uintptr_t address) { - GOOGLE_ABSL_LOG(FATAL) << "Unaligned (4) access at " << address; + ABSL_LOG(FATAL) << "Unaligned (4) access at " << address; // Explicit abort to let compilers know this function does not return abort(); } void AlignFail(std::integral_constant, std::uintptr_t address) { - GOOGLE_ABSL_LOG(FATAL) << "Unaligned (8) access at " << address; + ABSL_LOG(FATAL) << "Unaligned (8) access at " << address; // Explicit abort to let compilers know this function does not return abort(); @@ -1620,7 +1620,7 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table, case field_layout::kRepSString: case field_layout::kRepIString: default: - GOOGLE_ABSL_LOG(DFATAL) << "string rep not handled: " + ABSL_DLOG(FATAL) << "string rep not handled: " << (current_rep >> field_layout::kRepShift); return true; } @@ -1635,7 +1635,7 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table, break; } default: - GOOGLE_ABSL_LOG(DFATAL) << "message rep not handled: " + ABSL_DLOG(FATAL) << "message rep not handled: " << (current_rep >> field_layout::kRepShift); break; } @@ -1692,7 +1692,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) { PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); } } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) { PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); } @@ -1744,7 +1744,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedFixed( ptr2 = ReadTag(ptr, &next_tag); } while (next_tag == decoded_tag); } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) { PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); } @@ -1784,7 +1784,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) { auto& field = RefAt>(msg, entry.offset); ptr = ctx->ReadPackedFixed(ptr, size, &field); } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep32Bits)); auto& field = RefAt>(msg, entry.offset); ptr = ctx->ReadPackedFixed(ptr, size, &field); } @@ -1850,7 +1850,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) { } else if (rep == field_layout::kRep32Bits) { RefAt(base, entry.offset) = static_cast(tmp); } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); RefAt(base, entry.offset) = static_cast(tmp); } @@ -1912,7 +1912,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedVarint( if (ptr2 == nullptr) return Error(PROTOBUF_TC_PARAM_PASS); } while (next_tag == decoded_tag); } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); auto& field = RefAt>(msg, entry.offset); const char* ptr2 = ptr; uint32_t next_tag; @@ -1972,7 +1972,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) { }); } } else { - GOOGLE_ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); + ABSL_DCHECK_EQ(rep, static_cast(field_layout::kRep8Bits)); auto* field = &RefAt>(msg, entry.offset); return ctx->ReadPackedVarint( ptr, [field](uint64_t value) { field->Add(value); }); @@ -2130,7 +2130,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString( #ifndef NDEBUG default: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported repeated string rep: " << rep; + ABSL_LOG(FATAL) << "Unsupported repeated string rep: " << rep; break; #endif } @@ -2200,7 +2200,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) { if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) { def = table->field_aux(&entry)->message_default(); } else { - GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask, + ABSL_DCHECK_EQ(type_card & field_layout::kTvMask, +field_layout::kTvWeakPtr); def = table->field_aux(&entry)->message_default_weak(); } @@ -2216,7 +2216,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) { const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) { const auto& entry = RefAt(table, data.entry_offset()); const uint16_t type_card = entry.type_card; - GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kFcMask, + ABSL_DCHECK_EQ(type_card & field_layout::kFcMask, static_cast(field_layout::kFcRepeated)); const uint32_t decoded_tag = data.tag(); const uint32_t decoded_wiretype = decoded_tag & 7; @@ -2259,7 +2259,7 @@ const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) { if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) { def = aux.message_default(); } else { - GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask, + ABSL_DCHECK_EQ(type_card & field_layout::kTvMask, +field_layout::kTvWeakPtr); def = aux.message_default_weak(); } diff --git a/src/google/protobuf/generated_message_tctable_lite_test.cc b/src/google/protobuf/generated_message_tctable_lite_test.cc index b1c960daf8b4..e242d839eed5 100644 --- a/src/google/protobuf/generated_message_tctable_lite_test.cc +++ b/src/google/protobuf/generated_message_tctable_lite_test.cc @@ -180,7 +180,7 @@ TEST(FastVarints, NameHere) { ParseContext ctx(io::CodedInputStream::GetDefaultRecursionLimit(), /* aliasing= */ false, &ptr, serialized); #if 0 // FOR_DEBUGGING - GOOGLE_ABSL_LOG(ERROR) << "size=" << size << " i=" << i << " ptr points to " // + ABSL_LOG(ERROR) << "size=" << size << " i=" << i << " ptr points to " // << +ptr[0] << "," << +ptr[1] << "," // << +ptr[2] << "," << +ptr[3] << "," // << +ptr[4] << "," << +ptr[5] << "," // @@ -393,7 +393,7 @@ TEST_F(FindFieldEntryTest, SequentialFieldRange) { IsEntryForFieldNum(&table, i, table_field_numbers)); } for (int i : {0, 1, 6, 7, 110, 112, 500000000}) { - GOOGLE_ABSL_LOG(WARNING) << "Field " << i; + ABSL_LOG(WARNING) << "Field " << i; EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr)); } } diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 0884b8e19a44..647e9841932d 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -317,7 +317,7 @@ class AccessorHelper { }; void SerializeNotImplemented(int field) { - GOOGLE_ABSL_LOG(FATAL) << "Not implemented field number " << field; + ABSL_LOG(FATAL) << "Not implemented field number " << field; } // When switching to c++11 we should make these constexpr functions @@ -389,9 +389,9 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) { MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena) { - GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena); - GOOGLE_ABSL_DCHECK(message_arena != submessage_arena); - GOOGLE_ABSL_DCHECK_EQ(submessage_arena, nullptr); + ABSL_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena); + ABSL_DCHECK(message_arena != submessage_arena); + ABSL_DCHECK_EQ(submessage_arena, nullptr); if (message_arena != nullptr && submessage_arena == nullptr) { message_arena->Own(submessage); return submessage; diff --git a/src/google/protobuf/inlined_string_field.h b/src/google/protobuf/inlined_string_field.h index ba7b9386bd71..06eede106f95 100644 --- a/src/google/protobuf/inlined_string_field.h +++ b/src/google/protobuf/inlined_string_field.h @@ -35,7 +35,7 @@ #include #include "google/protobuf/port.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/arenastring.h" #include "google/protobuf/message_lite.h" diff --git a/src/google/protobuf/inlined_string_field_unittest.cc b/src/google/protobuf/inlined_string_field_unittest.cc index 1a7fcdeabe59..cfd116c4d838 100644 --- a/src/google/protobuf/inlined_string_field_unittest.cc +++ b/src/google/protobuf/inlined_string_field_unittest.cc @@ -40,7 +40,7 @@ #include "google/protobuf/arenastring.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" diff --git a/src/google/protobuf/io/BUILD.bazel b/src/google/protobuf/io/BUILD.bazel index e61a2a26a7ce..8f39625c2834 100644 --- a/src/google/protobuf/io/BUILD.bazel +++ b/src/google/protobuf/io/BUILD.bazel @@ -28,6 +28,8 @@ cc_library( ":io_win32", "//src/google/protobuf:arena", "//src/google/protobuf/stubs:lite", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:internal", ], ) @@ -41,6 +43,7 @@ cc_library( deps = [ ":io", "//src/google/protobuf/stubs", + "@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/types:optional", ], ) @@ -95,6 +98,8 @@ cc_library( "@com_google_absl//absl/cleanup", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/functional:function_ref", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:optional", @@ -118,6 +123,7 @@ cc_library( deps = [ ":io", "//src/google/protobuf/stubs", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ], @@ -132,6 +138,8 @@ cc_library( deps = [ ":io", "//src/google/protobuf/stubs", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", ] + select({ "//build_defs:config_msvc": [], "//conditions:default": ["@zlib//:zlib"], @@ -171,6 +179,7 @@ cc_test( "//src/google/protobuf:test_util2", "//src/google/protobuf/testing", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:scoped_mock_log", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_googletest//:gtest", diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index ef623ea281c1..b2bb0cc68053 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -48,8 +48,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" #include "absl/strings/internal/resize_uninitialized.h" #include "absl/strings/string_view.h" @@ -175,7 +175,7 @@ CodedInputStream::Limit CodedInputStream::ReadLengthAndPushLimit() { bool CodedInputStream::DecrementRecursionDepthAndPopLimit(Limit limit) { bool result = ConsumedEntireMessage(); PopLimit(limit); - GOOGLE_ABSL_DCHECK_LT(recursion_budget_, recursion_limit_); + ABSL_DCHECK_LT(recursion_budget_, recursion_limit_); ++recursion_budget_; return result; } @@ -207,7 +207,7 @@ int CodedInputStream::BytesUntilTotalBytesLimit() const { } void CodedInputStream::PrintTotalBytesLimitError() { - GOOGLE_ABSL_LOG(ERROR) << "A protocol message was rejected because it was too " + ABSL_LOG(ERROR) << "A protocol message was rejected because it was too " "big (more than " << total_bytes_limit_ << " bytes). To increase the limit (or to disable these " @@ -280,7 +280,7 @@ bool CodedInputStream::ReadString(std::string* buffer, int size) { if (z.second) { // Oddly enough, memcpy() requires its first two args to be non-NULL even // if we copy 0 bytes. So, we have ensured that z.first is non-NULL here. - GOOGLE_ABSL_DCHECK(z.first != NULL); + ABSL_DCHECK(z.first != NULL); memcpy(z.first, buffer_, size); Advance(size); } @@ -324,7 +324,7 @@ bool CodedInputStream::ReadStringFallback(std::string* buffer, int size) { } bool CodedInputStream::ReadCord(absl::Cord* output, int size) { - GOOGLE_ABSL_DCHECK_NE(output, nullptr); + ABSL_DCHECK_NE(output, nullptr); // security: size is often user-supplied if (size < 0) { @@ -405,7 +405,7 @@ namespace { // subtracting 0x80 at each iteration, it subtracts properly shifted mask once. template const uint8_t* DecodeVarint64KnownSize(const uint8_t* buffer, uint64_t* value) { - GOOGLE_ABSL_DCHECK_GT(N, 0); + ABSL_DCHECK_GT(N, 0); uint64_t result = static_cast(buffer[N - 1]) << (7 * (N - 1)); for (size_t i = 0, offset = 0; i < N - 1; i++, offset += 7) { result += static_cast(buffer[i] - 0x80) << offset; @@ -426,8 +426,8 @@ inline ::std::pair ReadVarint32FromArray( uint32_t first_byte, const uint8_t* buffer, uint32_t* value) { // Fast path: We have enough bytes left in the buffer to guarantee that // this read won't cross the end, so we can skip the checks. - GOOGLE_ABSL_DCHECK_EQ(*buffer, first_byte); - GOOGLE_ABSL_DCHECK_EQ(first_byte & 0x80, 0x80) << first_byte; + ABSL_DCHECK_EQ(*buffer, first_byte); + ABSL_DCHECK_EQ(first_byte & 0x80, 0x80) << first_byte; const uint8_t* ptr = buffer; uint32_t b; uint32_t result = first_byte - 0x80; @@ -470,7 +470,7 @@ PROTOBUF_ALWAYS_INLINE::std::pair ReadVarint64FromArray( inline ::std::pair ReadVarint64FromArray( const uint8_t* buffer, uint64_t* value) { // Assumes varint64 is at least 2 bytes. - GOOGLE_ABSL_DCHECK_GE(buffer[0], 128); + ABSL_DCHECK_GE(buffer[0], 128); const uint8_t* next; if (buffer[1] < 128) { @@ -515,7 +515,7 @@ int64_t CodedInputStream::ReadVarint32Fallback(uint32_t first_byte_or_zero) { // Optimization: We're also safe if the buffer is non-empty and it ends // with a byte that would terminate a varint. (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) { - GOOGLE_ABSL_DCHECK_NE(first_byte_or_zero, 0) + ABSL_DCHECK_NE(first_byte_or_zero, 0) << "Caller should provide us with *buffer_ when buffer is non-empty"; uint32_t temp; ::std::pair p = @@ -590,7 +590,7 @@ uint32_t CodedInputStream::ReadTagFallback(uint32_t first_byte_or_zero) { // Optimization: We're also safe if the buffer is non-empty and it ends // with a byte that would terminate a varint. (buf_size > 0 && !(buffer_end_[-1] & 0x80))) { - GOOGLE_ABSL_DCHECK_EQ(first_byte_or_zero, buffer_[0]); + ABSL_DCHECK_EQ(first_byte_or_zero, buffer_[0]); if (first_byte_or_zero == 0) { ++buffer_; return 0; @@ -670,7 +670,7 @@ std::pair CodedInputStream::ReadVarint64Fallback() { } bool CodedInputStream::Refresh() { - GOOGLE_ABSL_DCHECK_EQ(0, BufferSize()); + ABSL_DCHECK_EQ(0, BufferSize()); if (buffer_size_after_limit_ > 0 || overflow_bytes_ > 0 || total_bytes_read_ == current_limit_) { @@ -691,7 +691,7 @@ bool CodedInputStream::Refresh() { if (NextNonEmpty(input_, &void_buffer, &buffer_size)) { buffer_ = reinterpret_cast(void_buffer); buffer_end_ = buffer_ + buffer_size; - GOOGLE_ABSL_CHECK_GE(buffer_size, 0); + ABSL_CHECK_GE(buffer_size, 0); if (total_bytes_read_ <= INT_MAX - buffer_size) { total_bytes_read_ += buffer_size; @@ -738,8 +738,8 @@ int64_t EpsCopyOutputStream::ByteCount(uint8_t* ptr) const { int EpsCopyOutputStream::Flush(uint8_t* ptr) { while (buffer_end_ && ptr > end_) { int overrun = ptr - end_; - GOOGLE_ABSL_DCHECK(!had_error_); - GOOGLE_ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT + ABSL_DCHECK(!had_error_); + ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT ptr = Next() + overrun; if (had_error_) return 0; } @@ -753,7 +753,7 @@ int EpsCopyOutputStream::Flush(uint8_t* ptr) { s = end_ + kSlopBytes - ptr; buffer_end_ = ptr; } - GOOGLE_ABSL_DCHECK(s >= 0); // NOLINT + ABSL_DCHECK(s >= 0); // NOLINT return s; } @@ -841,7 +841,7 @@ uint8_t* EpsCopyOutputStream::GetDirectBufferForNBytesAndAdvance(int size, } uint8_t* EpsCopyOutputStream::Next() { - GOOGLE_ABSL_DCHECK(!had_error_); // NOLINT + ABSL_DCHECK(!had_error_); // NOLINT if (PROTOBUF_PREDICT_FALSE(stream_ == nullptr)) return Error(); if (buffer_end_) { // We're in the patch buffer and need to fill up the previous buffer. @@ -863,7 +863,7 @@ uint8_t* EpsCopyOutputStream::Next() { buffer_end_ = nullptr; return ptr; } else { - GOOGLE_ABSL_DCHECK(size > 0); // NOLINT + ABSL_DCHECK(size > 0); // NOLINT // Buffer to small std::memmove(buffer_, end_, kSlopBytes); buffer_end_ = ptr; @@ -882,11 +882,11 @@ uint8_t* EpsCopyOutputStream::EnsureSpaceFallback(uint8_t* ptr) { do { if (PROTOBUF_PREDICT_FALSE(had_error_)) return buffer_; int overrun = ptr - end_; - GOOGLE_ABSL_DCHECK(overrun >= 0); // NOLINT - GOOGLE_ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT + ABSL_DCHECK(overrun >= 0); // NOLINT + ABSL_DCHECK(overrun <= kSlopBytes); // NOLINT ptr = Next() + overrun; } while (ptr >= end_); - GOOGLE_ABSL_DCHECK(ptr < end_); // NOLINT + ABSL_DCHECK(ptr < end_); // NOLINT return ptr; } @@ -1029,7 +1029,7 @@ uint8_t* CodedOutputStream::WriteCordToArray(const absl::Cord& cord, uint8_t* CodedOutputStream::WriteStringWithSizeToArray(const std::string& str, uint8_t* target) { - GOOGLE_ABSL_DCHECK_LE(str.size(), std::numeric_limits::max()); + ABSL_DCHECK_LE(str.size(), std::numeric_limits::max()); target = WriteVarint32ToArray(str.size(), target); return WriteStringToArray(str, target); } diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 1c923905eb7c..94fc6e9a61c6 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -129,7 +129,7 @@ #include "google/protobuf/stubs/common.h" #include "absl/base/attributes.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/bits.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" @@ -844,7 +844,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { inline uint8_t* Next(); int Flush(uint8_t* ptr); std::ptrdiff_t GetSize(uint8_t* ptr) const { - GOOGLE_ABSL_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT + ABSL_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT return end_ + kSlopBytes - ptr; } @@ -865,7 +865,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { PROTOBUF_ALWAYS_INLINE uint8_t* WriteTag(uint32_t num, uint32_t wt, uint8_t* ptr) { - GOOGLE_ABSL_DCHECK(ptr < end_); // NOLINT + ABSL_DCHECK(ptr < end_); // NOLINT return UnsafeVarint((num << 3) | wt, ptr); } @@ -1074,7 +1074,7 @@ class PROTOBUF_EXPORT CodedOutputStream { // errors. bool HadError() { cur_ = impl_.FlushAndResetBuffer(cur_); - GOOGLE_ABSL_DCHECK(cur_); + ABSL_DCHECK(cur_); return impl_.HadError(); } diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index 1e55faf4e0bc..8b9544130864 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -46,8 +46,10 @@ #include "google/protobuf/stubs/common.h" #include #include "absl/base/casts.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/base/log_severity.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" +#include "absl/log/scoped_mock_log.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/zero_copy_stream_impl.h" @@ -63,7 +65,6 @@ namespace protobuf { namespace io { namespace { - // =================================================================== // Data-Driven Test Infrastructure @@ -239,10 +240,10 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) { return count_++ < 2; } void BackUp(int count) override { - GOOGLE_ABSL_LOG(FATAL) << "Tests never call this."; + ABSL_LOG(FATAL) << "Tests never call this."; } bool Skip(int count) override { - GOOGLE_ABSL_LOG(FATAL) << "Tests never call this."; + ABSL_LOG(FATAL) << "Tests never call this."; return false; } int64_t ByteCount() const override { return 0; } @@ -1378,19 +1379,17 @@ TEST_F(CodedStreamTest, TotalBytesLimit) { EXPECT_TRUE(coded_input.ReadString(&str, 16)); EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit()); - std::vector errors; - { - ScopedMemoryLog error_log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL( + log, + Log(absl::LogSeverity::kError, testing::_, + testing::HasSubstr( + "A protocol message was rejected because it was too big"))); + log.StartCapturingLogs(); EXPECT_FALSE(coded_input.ReadString(&str, 1)); - errors = error_log.GetMessages(ERROR); } - ASSERT_EQ(1, errors.size()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "A protocol message was rejected because it was too big", - errors[0]); - coded_input.SetTotalBytesLimit(32); EXPECT_EQ(16, coded_input.BytesUntilTotalBytesLimit()); EXPECT_TRUE(coded_input.ReadString(&str, 16)); @@ -1493,11 +1492,11 @@ class ReallyBigInputStream : public ZeroCopyInputStream { void BackUp(int count) override { backup_amount_ = count; } bool Skip(int count) override { - GOOGLE_ABSL_LOG(FATAL) << "Not implemented."; + ABSL_LOG(FATAL) << "Not implemented."; return false; } int64_t ByteCount() const override { - GOOGLE_ABSL_LOG(FATAL) << "Not implemented."; + ABSL_LOG(FATAL) << "Not implemented."; return 0; } @@ -1513,19 +1512,18 @@ TEST_F(CodedStreamTest, InputOver2G) { // input.BackUp() with the correct number of bytes on destruction. ReallyBigInputStream input; - std::vector errors; - { - ScopedMemoryLog error_log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)) + .Times(0); + log.StartCapturingLogs(); CodedInputStream coded_input(&input); std::string str; EXPECT_TRUE(coded_input.ReadString(&str, 512)); EXPECT_TRUE(coded_input.ReadString(&str, 1024)); - errors = error_log.GetMessages(ERROR); } EXPECT_EQ(INT_MAX - 512, input.backup_amount_); - EXPECT_EQ(0, errors.size()); } } // namespace diff --git a/src/google/protobuf/io/gzip_stream.cc b/src/google/protobuf/io/gzip_stream.cc index a10ed099ed51..2e7565924b99 100644 --- a/src/google/protobuf/io/gzip_stream.cc +++ b/src/google/protobuf/io/gzip_stream.cc @@ -38,8 +38,8 @@ #include "google/protobuf/io/gzip_stream.h" #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "google/protobuf/port.h" namespace google { @@ -66,7 +66,7 @@ GzipInputStream::GzipInputStream(ZeroCopyInputStream* sub_stream, Format format, output_buffer_length_ = buffer_size; } output_buffer_ = operator new(output_buffer_length_); - GOOGLE_ABSL_CHECK(output_buffer_ != NULL); + ABSL_CHECK(output_buffer_ != NULL); zcontext_.next_out = static_cast(output_buffer_); zcontext_.avail_out = output_buffer_length_; output_position_ = output_buffer_; @@ -221,7 +221,7 @@ void GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream, input_buffer_length_ = options.buffer_size; input_buffer_ = operator new(input_buffer_length_); - GOOGLE_ABSL_CHECK(input_buffer_ != NULL); + ABSL_CHECK(input_buffer_ != NULL); zcontext_.zalloc = Z_NULL; zcontext_.zfree = Z_NULL; @@ -260,7 +260,7 @@ int GzipOutputStream::Deflate(int flush) { sub_data_size_ = 0; return Z_BUF_ERROR; } - GOOGLE_ABSL_CHECK_GT(sub_data_size_, 0); + ABSL_CHECK_GT(sub_data_size_, 0); zcontext_.next_out = static_cast(sub_data_); zcontext_.avail_out = sub_data_size_; } @@ -295,12 +295,12 @@ bool GzipOutputStream::Next(void** data, int* size) { *size = input_buffer_length_; } else { // The loop in Deflate should consume all avail_in - GOOGLE_ABSL_LOG(DFATAL) << "Deflate left bytes unconsumed"; + ABSL_DLOG(FATAL) << "Deflate left bytes unconsumed"; } return true; } void GzipOutputStream::BackUp(int count) { - GOOGLE_ABSL_CHECK_GE(zcontext_.avail_in, static_cast(count)); + ABSL_CHECK_GE(zcontext_.avail_in, static_cast(count)); zcontext_.avail_in -= count; } int64_t GzipOutputStream::ByteCount() const { diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 2742451b88dd..9dbdc97d7074 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -44,8 +44,8 @@ #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -286,10 +286,10 @@ Printer::Printer(ZeroCopyOutputStream* output, Options options) absl::string_view Printer::LookupVar(absl::string_view var) { auto result = LookupInFrameStack(var, absl::MakeSpan(var_lookups_)); - GOOGLE_ABSL_CHECK(result.has_value()) << "could not find " << var; + ABSL_CHECK(result.has_value()) << "could not find " << var; auto* view = result->AsString(); - GOOGLE_ABSL_CHECK(view != nullptr) + ABSL_CHECK(view != nullptr) << "could not find " << var << "; found callback instead"; return *view; @@ -299,9 +299,9 @@ bool Printer::Validate(bool cond, Printer::PrintOptions opts, absl::FunctionRef message) { if (!cond) { if (opts.checks_are_debug_only) { - GOOGLE_ABSL_LOG(DFATAL) << message(); + ABSL_DLOG(FATAL) << message(); } else { - GOOGLE_ABSL_LOG(FATAL) << message(); + ABSL_LOG(FATAL) << message(); } } return cond; @@ -313,7 +313,7 @@ bool Printer::Validate(bool cond, Printer::PrintOptions opts, } // This function is outlined to isolate the use of -// GOOGLE_ABSL_CHECK into the .cc file. +// ABSL_CHECK into the .cc file. void Printer::Outdent() { PrintOptions opts; opts.checks_are_debug_only = true; @@ -372,7 +372,7 @@ void Printer::Annotate(absl::string_view begin_varname, return; } if (begin->first > end->second) { - GOOGLE_ABSL_LOG(DFATAL) << "annotation has negative length from " << begin_varname + ABSL_DLOG(FATAL) << "annotation has negative length from " << begin_varname << " to " << end_varname; return; } @@ -691,14 +691,14 @@ void Printer::PrintImpl(absl::string_view format, } } else { const ValueView::Callback* fnc = sub->AsCallback(); - GOOGLE_ABSL_CHECK(fnc != nullptr); + ABSL_CHECK(fnc != nullptr); Validate( prefix.empty() && suffix.empty(), opts, "substitution that resolves to callback cannot contain whitespace"); range_start = sink_.bytes_written(); - GOOGLE_ABSL_CHECK((*fnc)()) + ABSL_CHECK((*fnc)()) << "recursive call encountered while evaluating \"" << var << "\""; range_end = sink_.bytes_written(); } diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index 723ec3211296..326785fee079 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -48,7 +48,7 @@ #include "absl/cleanup/cleanup.h" #include "absl/container/flat_hash_map.h" #include "absl/functional/function_ref.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -922,7 +922,7 @@ class Printer::Sub { absl::string_view value() const { const auto* str = value_.AsString(); - GOOGLE_ABSL_CHECK(str != nullptr) + ABSL_CHECK(str != nullptr) << "could not find " << key() << "; found callback instead"; return *str; } @@ -1051,10 +1051,10 @@ inline auto Printer::WithDefs(absl::Span vars, absl::flat_hash_map annotation_map; for (const auto& var : vars) { - GOOGLE_ABSL_CHECK(allow_callbacks || var.value_.AsCallback() == nullptr) + ABSL_CHECK(allow_callbacks || var.value_.AsCallback() == nullptr) << "callback arguments are not permitted in this position"; auto result = var_map.insert({var.key_, var.value_}); - GOOGLE_ABSL_CHECK(result.second) + ABSL_CHECK(result.second) << "repeated variable in Emit() or WithVars() call: \"" << var.key_ << "\""; if (var.annotation_.has_value()) { diff --git a/src/google/protobuf/io/printer_death_test.cc b/src/google/protobuf/io/printer_death_test.cc index f4e4b1fe12ab..7365418273a7 100644 --- a/src/google/protobuf/io/printer_death_test.cc +++ b/src/google/protobuf/io/printer_death_test.cc @@ -42,7 +42,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/printer.h" @@ -53,10 +53,11 @@ namespace google { namespace protobuf { namespace io { -class PrinterTest : public testing::Test { +namespace { +class PrinterDeathTest : public testing::Test { protected: ZeroCopyOutputStream* output() { - GOOGLE_ABSL_CHECK(stream_.has_value()); + ABSL_CHECK(stream_.has_value()); return &*stream_; } absl::string_view written() { @@ -95,8 +96,8 @@ class FakeAnnotationCollector : public AnnotationCollector { } }; -#if PROTOBUF_HAS_DEATH_TEST -TEST_F(PrinterTest, Death) { +#if GTEST_HAS_DEATH_TEST +TEST_F(PrinterDeathTest, Death) { Printer printer(output(), '$'); EXPECT_DEBUG_DEATH(printer.Print("$nosuchvar$"), ""); @@ -104,7 +105,7 @@ TEST_F(PrinterTest, Death) { EXPECT_DEBUG_DEATH(printer.Outdent(), ""); } -TEST_F(PrinterTest, AnnotateMultipleUsesDeath) { +TEST_F(PrinterDeathTest, AnnotateMultipleUsesDeath) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); @@ -113,7 +114,7 @@ TEST_F(PrinterTest, AnnotateMultipleUsesDeath) { EXPECT_DEBUG_DEATH(printer.Annotate("foo", "foo", &descriptor), ""); } -TEST_F(PrinterTest, AnnotateNegativeLengthDeath) { +TEST_F(PrinterDeathTest, AnnotateNegativeLengthDeath) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); @@ -122,7 +123,7 @@ TEST_F(PrinterTest, AnnotateNegativeLengthDeath) { EXPECT_DEBUG_DEATH(printer.Annotate("bar", "foo", &descriptor), ""); } -TEST_F(PrinterTest, AnnotateUndefinedDeath) { +TEST_F(PrinterDeathTest, AnnotateUndefinedDeath) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); @@ -131,42 +132,43 @@ TEST_F(PrinterTest, AnnotateUndefinedDeath) { EXPECT_DEBUG_DEATH(printer.Annotate("bar", "bar", &descriptor), ""); } -TEST_F(PrinterTest, FormatInternalUnusedArgs) { +TEST_F(PrinterDeathTest, FormatInternalUnusedArgs) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); EXPECT_DEATH(printer.FormatInternal({"arg1", "arg2"}, {}, "$1$"), ""); } -TEST_F(PrinterTest, FormatInternalOutOfOrderArgs) { +TEST_F(PrinterDeathTest, FormatInternalOutOfOrderArgs) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); EXPECT_DEATH(printer.FormatInternal({"arg1", "arg2"}, {}, "$2$ $1$"), ""); } -TEST_F(PrinterTest, FormatInternalZeroArg) { +TEST_F(PrinterDeathTest, FormatInternalZeroArg) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); EXPECT_DEATH(printer.FormatInternal({"arg1", "arg2"}, {}, "$0$"), ""); } -TEST_F(PrinterTest, FormatInternalOutOfBounds) { +TEST_F(PrinterDeathTest, FormatInternalOutOfBounds) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); EXPECT_DEATH(printer.FormatInternal({"arg1", "arg2"}, {}, "$1$ $2$ $3$"), ""); } -TEST_F(PrinterTest, FormatInternalUnknownVar) { +TEST_F(PrinterDeathTest, FormatInternalUnknownVar) { FakeAnnotationCollector collector; Printer printer(output(), '$', &collector); EXPECT_DEATH(printer.FormatInternal({}, {}, "$huh$"), ""); EXPECT_DEATH(printer.FormatInternal({}, {}, "$ $"), ""); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST +} // namespace } // namespace io } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc index 4c199a70ea3e..2b7c6ee9886a 100644 --- a/src/google/protobuf/io/printer_unittest.cc +++ b/src/google/protobuf/io/printer_unittest.cc @@ -43,7 +43,7 @@ #include #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -52,6 +52,7 @@ namespace google { namespace protobuf { namespace io { +namespace { using ::testing::AllOf; using ::testing::ElementsAre; using ::testing::Field; @@ -61,7 +62,7 @@ using ::testing::MatchesRegex; class PrinterTest : public testing::Test { protected: ZeroCopyOutputStream* output() { - GOOGLE_ABSL_CHECK(stream_.has_value()); + ABSL_CHECK(stream_.has_value()); return &*stream_; } absl::string_view written() { @@ -846,6 +847,7 @@ TEST_F(PrinterTest, PreserveNewlinesThroughEmits) { "// four\n"); } +} // namespace } // namespace io } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/io/strtod.cc b/src/google/protobuf/io/strtod.cc index 30499ade497a..c2c23a8407f7 100644 --- a/src/google/protobuf/io/strtod.cc +++ b/src/google/protobuf/io/strtod.cc @@ -40,7 +40,7 @@ #include #include // NOLINT(build/c++11) -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/charconv.h" #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" @@ -208,7 +208,7 @@ char *FloatToBuffer(float value, char *buffer) { // The snprintf should never overflow because the buffer is significantly // larger than the precision we asked for. - GOOGLE_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); float parsed_value; if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { @@ -216,7 +216,7 @@ char *FloatToBuffer(float value, char *buffer) { absl::SNPrintF(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value); // Should never overflow; see above. - GOOGLE_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); } DelocalizeRadix(buffer); @@ -246,7 +246,7 @@ char *DoubleToBuffer(double value, char *buffer) { // The snprintf should never overflow because the buffer is significantly // larger than the precision we asked for. - GOOGLE_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); + ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); // We need to make parsed_value volatile in order to force the compiler to // write it out to the stack. Otherwise, it may keep the value in a @@ -260,7 +260,7 @@ char *DoubleToBuffer(double value, char *buffer) { absl::SNPrintF(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG + 2, value); // Should never overflow; see above. - GOOGLE_ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); + ABSL_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); } DelocalizeRadix(buffer); diff --git a/src/google/protobuf/io/test_zero_copy_stream.h b/src/google/protobuf/io/test_zero_copy_stream.h index b03b10b0c766..db2c87ad6be2 100644 --- a/src/google/protobuf/io/test_zero_copy_stream.h +++ b/src/google/protobuf/io/test_zero_copy_stream.h @@ -36,7 +36,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/types/optional.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -64,8 +64,8 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream { byte_count_(other.byte_count_) {} bool Next(const void** data, int* size) override { - GOOGLE_ABSL_CHECK(data) << "data must not be null"; - GOOGLE_ABSL_CHECK(size) << "size must not be null"; + ABSL_CHECK(data) << "data must not be null"; + ABSL_CHECK(size) << "size must not be null"; last_returned_buffer_ = absl::nullopt; // We are done @@ -80,10 +80,10 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream { } void BackUp(int count) override { - GOOGLE_ABSL_CHECK_GE(count, 0) << "count must not be negative"; - GOOGLE_ABSL_CHECK(last_returned_buffer_.has_value()) + ABSL_CHECK_GE(count, 0) << "count must not be negative"; + ABSL_CHECK(last_returned_buffer_.has_value()) << "The last call was not a successful Next()"; - GOOGLE_ABSL_CHECK_LE(count, last_returned_buffer_->size()) + ABSL_CHECK_LE(count, last_returned_buffer_->size()) << "count must be within bounds of last buffer"; buffers_.push_front( last_returned_buffer_->substr(last_returned_buffer_->size() - count)); @@ -92,7 +92,7 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream { } bool Skip(int count) override { - GOOGLE_ABSL_CHECK_GE(count, 0) << "count must not be negative"; + ABSL_CHECK_GE(count, 0) << "count must not be negative"; last_returned_buffer_ = absl::nullopt; while (true) { if (count == 0) return true; diff --git a/src/google/protobuf/io/test_zero_copy_stream_test.cc b/src/google/protobuf/io/test_zero_copy_stream_test.cc index 0e5e59e41c5e..39dbb500c843 100644 --- a/src/google/protobuf/io/test_zero_copy_stream_test.cc +++ b/src/google/protobuf/io/test_zero_copy_stream_test.cc @@ -68,7 +68,7 @@ std::vector ReadLeftoverDoNotConsumeInput( return out; } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, NextChecksPreconditions) { std::unique_ptr stream = std::make_unique(std::vector{}); @@ -77,7 +77,7 @@ TEST(TestZeroCopyInputStreamTest, NextChecksPreconditions) { EXPECT_DEATH(stream->Next(nullptr, &size), "data must not be null"); EXPECT_DEATH(stream->Next(&data, nullptr), "size must not be null"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, NextProvidesTheBuffersCorrectly) { std::vector expected = {"ABC", "D", "EFG", "", "", "HIJKLMN"}; @@ -116,30 +116,34 @@ TEST(TestZeroCopyInputStreamTest, BackUpGivesBackABuffer) { EXPECT_THAT(CallNext(*stream), Eq(absl::nullopt)); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, BackUpChecksPreconditions) { std::vector expected = {"ABC", "D", "EFG", "", "", "HIJKLMN"}; std::unique_ptr stream = std::make_unique(expected); - EXPECT_DEATH(stream->BackUp(0), "The last call was not a successful Next()"); + EXPECT_DEATH(stream->BackUp(0), + "The last call was not a successful Next\\(\\)"); EXPECT_THAT(CallNext(*stream), Optional(Eq("ABC"))); EXPECT_DEATH(stream->BackUp(-1), "count must not be negative"); stream->BackUp(1); - EXPECT_DEATH(stream->BackUp(0), "The last call was not a successful Next()"); + EXPECT_DEATH(stream->BackUp(0), + "The last call was not a successful Next\\(\\)"); EXPECT_THAT(CallNext(*stream), Optional(Eq("C"))); EXPECT_THAT(CallNext(*stream), Optional(Eq("D"))); stream->Skip(1); - EXPECT_DEATH(stream->BackUp(0), "The last call was not a successful Next()"); + EXPECT_DEATH(stream->BackUp(0), + "The last call was not a successful Next\\(\\)"); EXPECT_THAT(CallNext(*stream), Optional(Eq("FG"))); EXPECT_THAT(CallNext(*stream), Optional(Eq(""))); EXPECT_THAT(CallNext(*stream), Optional(Eq(""))); EXPECT_THAT(CallNext(*stream), Optional(Eq("HIJKLMN"))); EXPECT_DEATH(stream->BackUp(8), "count must be within bounds of last buffer"); EXPECT_THAT(CallNext(*stream), Eq(absl::nullopt)); - EXPECT_DEATH(stream->BackUp(0), "The last call was not a successful Next()"); + EXPECT_DEATH(stream->BackUp(0), + "The last call was not a successful Next\\(\\)"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, SkipWorks) { std::vector expected = {"ABC", "D", "EFG", "", "", "HIJKLMN"}; @@ -172,13 +176,13 @@ TEST(TestZeroCopyInputStreamTest, SkipWorks) { EXPECT_FALSE(stream.Skip(1)); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, SkipChecksPreconditions) { std::unique_ptr stream = std::make_unique(std::vector{}); EXPECT_DEATH(stream->Skip(-1), "count must not be negative"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(TestZeroCopyInputStreamTest, ByteCountWorks) { std::vector expected = {"ABC", "D", "EFG", "", "", "HIJKLMN"}; diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc index dd6f51de1de4..53229f8e67e0 100644 --- a/src/google/protobuf/io/tokenizer.cc +++ b/src/google/protobuf/io/tokenizer.cc @@ -91,8 +91,8 @@ #include "google/protobuf/io/tokenizer.h" #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "google/protobuf/io/strtod.h" @@ -1035,7 +1035,7 @@ bool Tokenizer::ParseInteger(const std::string& text, uint64_t max_value, double Tokenizer::ParseFloat(const std::string& text) { double result = 0; if (!TryParseFloat(text, &result)) { - GOOGLE_ABSL_LOG(DFATAL) + ABSL_DLOG(FATAL) << " Tokenizer::ParseFloat() passed text that could not have been" " tokenized as a float: " << absl::CEscape(text); @@ -1130,8 +1130,8 @@ static inline bool IsTrailSurrogate(uint32_t code_point) { // Combine a head and trail surrogate into a single Unicode code point. static uint32_t AssembleUTF16(uint32_t head_surrogate, uint32_t trail_surrogate) { - GOOGLE_ABSL_DCHECK(IsHeadSurrogate(head_surrogate)); - GOOGLE_ABSL_DCHECK(IsTrailSurrogate(trail_surrogate)); + ABSL_DCHECK(IsHeadSurrogate(head_surrogate)); + ABSL_DCHECK(IsTrailSurrogate(trail_surrogate)); return 0x10000 + (((head_surrogate - kMinHeadSurrogate) << 10) | (trail_surrogate - kMinTrailSurrogate)); } @@ -1180,7 +1180,7 @@ void Tokenizer::ParseStringAppend(const std::string& text, // empty, it's invalid, so we'll just return). const size_t text_size = text.size(); if (text_size == 0) { - GOOGLE_ABSL_LOG(DFATAL) + ABSL_DLOG(FATAL) << " Tokenizer::ParseStringAppend() passed text that could not" " have been tokenized as a string: " << absl::CEscape(text); diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h index cc60e3839382..6a31899bf1f8 100644 --- a/src/google/protobuf/io/tokenizer.h +++ b/src/google/protobuf/io/tokenizer.h @@ -41,7 +41,7 @@ #include #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "google/protobuf/port.h" @@ -100,7 +100,7 @@ class PROTOBUF_EXPORT ErrorCollector { ABSL_DEPRECATED("Use RecordError") virtual void AddError(int line, ColumnNumber column, const std::string& message) { - GOOGLE_ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; + ABSL_LOG(FATAL) << "AddError or RecordError must be implemented."; } ABSL_DEPRECATED("Use RecordWarning") virtual void AddWarning(int line, ColumnNumber column, diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index 41713bca927d..80457fa0a9a5 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -1020,7 +1020,7 @@ TEST_F(TokenizerTest, ParseFloat) { EXPECT_EQ(0.0, Tokenizer::ParseFloat("1e-9999999999999999999999999999")); EXPECT_EQ(HUGE_VAL, Tokenizer::ParseFloat("1e+9999999999999999999999999999")); -#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet // Test invalid integers that will never be tokenized as integers. EXPECT_DEBUG_DEATH( Tokenizer::ParseFloat("zxy"), @@ -1031,7 +1031,7 @@ TEST_F(TokenizerTest, ParseFloat) { EXPECT_DEBUG_DEATH( Tokenizer::ParseFloat("-1.0"), "passed text that could not have been tokenized as a float"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST_F(TokenizerTest, ParseString) { @@ -1075,11 +1075,11 @@ TEST_F(TokenizerTest, ParseString) { EXPECT_EQ("\\U00110000\\U00200000\\Uffffffff", output); // Test invalid strings that will never be tokenized as strings. -#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet EXPECT_DEBUG_DEATH( Tokenizer::ParseString("", &output), "passed text that could not have been tokenized as a string"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST_F(TokenizerTest, ParseStringAppend) { diff --git a/src/google/protobuf/io/zero_copy_sink_test.cc b/src/google/protobuf/io/zero_copy_sink_test.cc index 6ea03b471c04..56b4c946b2b9 100644 --- a/src/google/protobuf/io/zero_copy_sink_test.cc +++ b/src/google/protobuf/io/zero_copy_sink_test.cc @@ -37,7 +37,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -133,7 +133,7 @@ class PatternedOutputStream : public io::ZeroCopyOutputStream { } void BackUp(int length) override { - GOOGLE_ABSL_CHECK(length <= static_cast(segment_.size())); + ABSL_CHECK(length <= static_cast(segment_.size())); size_t backup = segment_.size() - static_cast(length); back_up_.push_back(segment_.substr(backup)); diff --git a/src/google/protobuf/io/zero_copy_stream.cc b/src/google/protobuf/io/zero_copy_stream.cc index 1282b9cea394..5c14a57d0265 100644 --- a/src/google/protobuf/io/zero_copy_stream.cc +++ b/src/google/protobuf/io/zero_copy_stream.cc @@ -37,7 +37,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" #include "absl/strings/cord_buffer.h" #include "absl/strings/string_view.h" @@ -133,7 +133,7 @@ bool ZeroCopyOutputStream::WriteCord(const absl::Cord& cord) { bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */, int /* size */) { - GOOGLE_ABSL_LOG(FATAL) << "This ZeroCopyOutputStream doesn't support aliasing. " + ABSL_LOG(FATAL) << "This ZeroCopyOutputStream doesn't support aliasing. " "Reaching here usually means a ZeroCopyOutputStream " "implementation bug."; return false; diff --git a/src/google/protobuf/io/zero_copy_stream.h b/src/google/protobuf/io/zero_copy_stream.h index 3578052683f4..8fac9f126f1e 100644 --- a/src/google/protobuf/io/zero_copy_stream.h +++ b/src/google/protobuf/io/zero_copy_stream.h @@ -256,7 +256,7 @@ class PROTOBUF_EXPORT ZeroCopyOutputStream { // Write a given chunk of data to the output. Some output streams may // implement this in a way that avoids copying. Check AllowsAliasing() before - // calling WriteAliasedRaw(). It will GOOGLE_ABSL_CHECK fail if WriteAliasedRaw() is + // calling WriteAliasedRaw(). It will ABSL_CHECK fail if WriteAliasedRaw() is // called on a stream that does not allow aliasing. // // NOTE: It is caller's responsibility to ensure that the chunk of memory diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc index c80315bd2aca..da0d83739bf2 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl.cc @@ -44,8 +44,8 @@ #include #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "google/protobuf/io/io_win32.h" #include "google/protobuf/io/zero_copy_stream_impl.h" @@ -114,13 +114,13 @@ FileInputStream::CopyingFileInputStream::CopyingFileInputStream( FileInputStream::CopyingFileInputStream::~CopyingFileInputStream() { if (close_on_delete_) { if (!Close()) { - GOOGLE_ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_); + ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_); } } } bool FileInputStream::CopyingFileInputStream::Close() { - GOOGLE_ABSL_CHECK(!is_closed_); + ABSL_CHECK(!is_closed_); is_closed_ = true; if (close_no_eintr(file_) != 0) { @@ -135,7 +135,7 @@ bool FileInputStream::CopyingFileInputStream::Close() { } int FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) { - GOOGLE_ABSL_CHECK(!is_closed_); + ABSL_CHECK(!is_closed_); int result; do { @@ -151,7 +151,7 @@ int FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) { } int FileInputStream::CopyingFileInputStream::Skip(int count) { - GOOGLE_ABSL_CHECK(!is_closed_); + ABSL_CHECK(!is_closed_); if (!previous_seek_failed_ && lseek(file_, count, SEEK_CUR) != (off_t)-1) { // Seek succeeded. @@ -191,13 +191,13 @@ FileOutputStream::~FileOutputStream() { Flush(); } FileOutputStream::CopyingFileOutputStream::~CopyingFileOutputStream() { if (close_on_delete_) { if (!Close()) { - GOOGLE_ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_); + ABSL_LOG(ERROR) << "close() failed: " << strerror(errno_); } } } bool FileOutputStream::CopyingFileOutputStream::Close() { - GOOGLE_ABSL_CHECK(!is_closed_); + ABSL_CHECK(!is_closed_); is_closed_ = true; if (close_no_eintr(file_) != 0) { @@ -213,7 +213,7 @@ bool FileOutputStream::CopyingFileOutputStream::Close() { bool FileOutputStream::CopyingFileOutputStream::Write(const void* buffer, int size) { - GOOGLE_ABSL_CHECK(!is_closed_); + ABSL_CHECK(!is_closed_); int total_written = 0; const uint8_t* buffer_base = reinterpret_cast(buffer); @@ -330,7 +330,7 @@ void ConcatenatingInputStream::BackUp(int count) { if (stream_count_ > 0) { streams_[0]->BackUp(count); } else { - GOOGLE_ABSL_LOG(DFATAL) << "Can't BackUp() after failed Next()."; + ABSL_DLOG(FATAL) << "Can't BackUp() after failed Next()."; } } @@ -344,7 +344,7 @@ bool ConcatenatingInputStream::Skip(int count) { // Hit the end of the stream. Figure out how many more bytes we still have // to skip. int64_t final_byte_count = streams_[0]->ByteCount(); - GOOGLE_ABSL_DCHECK_LT(final_byte_count, target_byte_count); + ABSL_DCHECK_LT(final_byte_count, target_byte_count); count = target_byte_count - final_byte_count; // That stream is done. Advance to the next one. diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/src/google/protobuf/io/zero_copy_stream_impl_lite.cc index 20b948142fb9..4cca9f1d647c 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.cc @@ -40,7 +40,7 @@ #include "google/protobuf/stubs/common.h" #include "absl/base/casts.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/cord.h" #include "absl/strings/internal/resize_uninitialized.h" @@ -82,16 +82,16 @@ bool ArrayInputStream::Next(const void** data, int* size) { } void ArrayInputStream::BackUp(int count) { - GOOGLE_ABSL_CHECK_GT(last_returned_size_, 0) + ABSL_CHECK_GT(last_returned_size_, 0) << "BackUp() can only be called after a successful Next()."; - GOOGLE_ABSL_CHECK_LE(count, last_returned_size_); - GOOGLE_ABSL_CHECK_GE(count, 0); + ABSL_CHECK_LE(count, last_returned_size_); + ABSL_CHECK_GE(count, 0); position_ -= count; last_returned_size_ = 0; // Don't let caller back up further. } bool ArrayInputStream::Skip(int count) { - GOOGLE_ABSL_CHECK_GE(count, 0); + ABSL_CHECK_GE(count, 0); last_returned_size_ = 0; // Don't let caller back up. if (count > size_ - position_) { position_ = size_; @@ -129,9 +129,9 @@ bool ArrayOutputStream::Next(void** data, int* size) { } void ArrayOutputStream::BackUp(int count) { - GOOGLE_ABSL_CHECK_LE(count, last_returned_size_) + ABSL_CHECK_LE(count, last_returned_size_) << "BackUp() can not exceed the size of the last Next() call."; - GOOGLE_ABSL_CHECK_GE(count, 0); + ABSL_CHECK_GE(count, 0); position_ -= count; last_returned_size_ -= count; } @@ -143,7 +143,7 @@ int64_t ArrayOutputStream::ByteCount() const { return position_; } StringOutputStream::StringOutputStream(std::string* target) : target_(target) {} bool StringOutputStream::Next(void** data, int* size) { - GOOGLE_ABSL_CHECK(target_ != NULL); + ABSL_CHECK(target_ != NULL); size_t old_size = target_->size(); // Grow the string. @@ -170,14 +170,14 @@ bool StringOutputStream::Next(void** data, int* size) { } void StringOutputStream::BackUp(int count) { - GOOGLE_ABSL_CHECK_GE(count, 0); - GOOGLE_ABSL_CHECK(target_ != NULL); - GOOGLE_ABSL_CHECK_LE(static_cast(count), target_->size()); + ABSL_CHECK_GE(count, 0); + ABSL_CHECK(target_ != NULL); + ABSL_CHECK_LE(static_cast(count), target_->size()); target_->resize(target_->size() - count); } int64_t StringOutputStream::ByteCount() const { - GOOGLE_ABSL_CHECK(target_ != NULL); + ABSL_CHECK(target_ != NULL); return target_->size(); } @@ -249,18 +249,18 @@ bool CopyingInputStreamAdaptor::Next(const void** data, int* size) { } void CopyingInputStreamAdaptor::BackUp(int count) { - GOOGLE_ABSL_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL) + ABSL_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL) << " BackUp() can only be called after Next()."; - GOOGLE_ABSL_CHECK_LE(count, buffer_used_) + ABSL_CHECK_LE(count, buffer_used_) << " Can't back up over more bytes than were returned by the last call" " to Next()."; - GOOGLE_ABSL_CHECK_GE(count, 0) << " Parameter to BackUp() can't be negative."; + ABSL_CHECK_GE(count, 0) << " Parameter to BackUp() can't be negative."; backup_bytes_ = count; } bool CopyingInputStreamAdaptor::Skip(int count) { - GOOGLE_ABSL_CHECK_GE(count, 0); + ABSL_CHECK_GE(count, 0); if (failed_) { // Already failed on a previous read. @@ -293,7 +293,7 @@ void CopyingInputStreamAdaptor::AllocateBufferIfNeeded() { } void CopyingInputStreamAdaptor::FreeBuffer() { - GOOGLE_ABSL_CHECK_EQ(backup_bytes_, 0); + ABSL_CHECK_EQ(backup_bytes_, 0); buffer_used_ = 0; buffer_.reset(); } @@ -336,10 +336,10 @@ void CopyingOutputStreamAdaptor::BackUp(int count) { Flush(); return; } - GOOGLE_ABSL_CHECK_GE(count, 0); - GOOGLE_ABSL_CHECK_EQ(buffer_used_, buffer_size_) + ABSL_CHECK_GE(count, 0); + ABSL_CHECK_EQ(buffer_used_, buffer_size_) << " BackUp() can only be called after Next()."; - GOOGLE_ABSL_CHECK_LE(count, buffer_used_) + ABSL_CHECK_LE(count, buffer_used_) << " Can't back up over more bytes than were returned by the last call" " to Next()."; @@ -355,7 +355,7 @@ bool CopyingOutputStreamAdaptor::WriteAliasedRaw(const void* data, int size) { if (!Flush() || !copying_stream_->Write(data, size)) { return false; } - GOOGLE_ABSL_DCHECK_EQ(buffer_used_, 0); + ABSL_DCHECK_EQ(buffer_used_, 0); position_ += size; return true; } @@ -533,7 +533,7 @@ bool CordInputStream::Next(const void** data, int* size) { void CordInputStream::BackUp(int count) { // Backup is only allowed on last returned chunk from `Next()`. - GOOGLE_ABSL_CHECK_LE(static_cast(count), size_ - available_); + ABSL_CHECK_LE(static_cast(count), size_ - available_); available_ += count; bytes_remaining_ += count; diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index d2b12fbf6a26..e5ff07af3547 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -70,8 +70,8 @@ #include "google/protobuf/testing/file.h" #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/cord.h" #include "absl/strings/cord_buffer.h" @@ -584,7 +584,7 @@ TEST_F(IoTest, CompressionOptions) { std::string golden_filename = TestUtil::GetTestDataPath("third_party/protobuf/testdata/golden_message"); std::string golden; - GOOGLE_ABSL_CHECK_OK(File::GetContents(golden_filename, &golden, true)); + ABSL_CHECK_OK(File::GetContents(golden_filename, &golden, true)); GzipOutputStream::Options options; std::string gzip_compressed = Compress(golden, options); diff --git a/src/google/protobuf/json/BUILD.bazel b/src/google/protobuf/json/BUILD.bazel index e2b8baf2c905..f2194a987b63 100644 --- a/src/google/protobuf/json/BUILD.bazel +++ b/src/google/protobuf/json/BUILD.bazel @@ -2,8 +2,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("//build_defs:cpp_opts.bzl", "COPTS") package(default_visibility = [ - "//src/google/protobuf/json:__pkg__", "//pkg:__pkg__", + "//src/google/protobuf/json:__pkg__", ]) licenses(["notice"]) @@ -25,6 +25,7 @@ cc_library( "//src/google/protobuf/util:type_resolver_util", "@com_google_absl//absl/base", "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", ], @@ -217,6 +218,8 @@ cc_library( "@com_google_absl//absl/base:core_headers", "@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/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", @@ -248,6 +251,8 @@ cc_library( "//src/google/protobuf/io", "//src/google/protobuf/util:type_resolver_util", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", diff --git a/src/google/protobuf/json/internal/descriptor_traits.h b/src/google/protobuf/json/internal/descriptor_traits.h index 7835e51f8bcd..277c16571e0a 100644 --- a/src/google/protobuf/json/internal/descriptor_traits.h +++ b/src/google/protobuf/json/internal/descriptor_traits.h @@ -45,7 +45,7 @@ #include "google/protobuf/dynamic_message.h" #include "google/protobuf/message.h" #include "absl/algorithm/container.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" @@ -179,7 +179,7 @@ struct Proto2Descriptor { JsonLocation::SourceLocation::current()) { auto f = FieldByNumber(d, number); if (!f.has_value()) { - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << absl::StrFormat( "%s has, by definition, a field numbered %d, but it could not " "be " @@ -360,7 +360,7 @@ struct Proto3Type { JsonLocation::SourceLocation::current()) { auto f = FieldByNumber(d, number); if (!f.has_value()) { - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << absl::StrFormat( "%s has, by definition, a field numbered %d, but it could not " "be " diff --git a/src/google/protobuf/json/internal/lexer.cc b/src/google/protobuf/json/internal/lexer.cc index eae2b1634fc9..2452a46ebb6b 100644 --- a/src/google/protobuf/json/internal/lexer.cc +++ b/src/google/protobuf/json/internal/lexer.cc @@ -43,7 +43,7 @@ #include #include "absl/algorithm/container.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/bits.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -184,7 +184,7 @@ absl::Status JsonLexer::SkipValue() { // Some compilers seem to fail to realize this is a basic block // terminator and incorrectly believe this function is missing // a return. - GOOGLE_ABSL_CHECK(false) << "unreachable"; + ABSL_CHECK(false) << "unreachable"; return absl::OkStatus(); } diff --git a/src/google/protobuf/json/internal/parser.cc b/src/google/protobuf/json/internal/parser.cc index 2ddf182f2fe5..8975e10d32bc 100644 --- a/src/google/protobuf/json/internal/parser.cc +++ b/src/google/protobuf/json/internal/parser.cc @@ -419,7 +419,7 @@ absl::Status ParseSingular(JsonLexer& lex, Field field, field, msg, [&](const Desc& type, Msg& msg) -> absl::Status { auto field = Traits::FieldByNumber(type, 1); - GOOGLE_ABSL_DCHECK(field.has_value()); + ABSL_DCHECK(field.has_value()); RETURN_IF_ERROR(lex.Expect("null")); Traits::SetEnum(Traits::MustHaveField(type, 1), msg, 0); return absl::OkStatus(); @@ -744,7 +744,7 @@ absl::Status ParseMap(JsonLexer& lex, Field field, Msg& msg) { absl::optional TakeTimeDigitsWithSuffixAndAdvance( absl::string_view& data, int max_digits, absl::string_view end) { - GOOGLE_ABSL_DCHECK_LE(max_digits, 9); + ABSL_DCHECK_LE(max_digits, 9); uint32_t val = 0; int limit = max_digits; @@ -1040,7 +1040,7 @@ absl::Status ParseAny(JsonLexer& lex, const Desc& desc, }); } else { // Empty {} is accepted in legacy mode. - GOOGLE_ABSL_DCHECK(lex.options().allow_legacy_syntax); + ABSL_DCHECK(lex.options().allow_legacy_syntax); RETURN_IF_ERROR(any_lex.VisitObject([&](auto&) { return mark.loc.Invalid( "in legacy mode, missing @type in Any is only allowed for an empty " @@ -1327,11 +1327,11 @@ absl::Status JsonToBinaryStream(google::protobuf::util::TypeResolver* resolver, io::ZeroCopyOutputStream* binary_output, json_internal::ParseOptions options) { // NOTE: Most of the contortions in this function are to allow for capture of - // input and output of the parser in GOOGLE_ABSL_DLOG mode. Destruction order is very + // input and output of the parser in ABSL_DLOG mode. Destruction order is very // critical in this function, because io::ZeroCopy*Stream types usually only // flush on destruction. - // For GOOGLE_ABSL_DLOG, we would like to print out the input and output, which + // For ABSL_DLOG, we would like to print out the input and output, which // requires buffering both instead of doing "zero copy". This block, and the // one at the end of the function, set up and tear down interception of the // input and output streams. diff --git a/src/google/protobuf/json/internal/test_input_stream.h b/src/google/protobuf/json/internal/test_input_stream.h index 3f9412e3be2f..6a1eb3f3c142 100644 --- a/src/google/protobuf/json/internal/test_input_stream.h +++ b/src/google/protobuf/json/internal/test_input_stream.h @@ -36,7 +36,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/zero_copy_stream.h" #include "google/protobuf/stubs/status_macros.h" @@ -73,13 +73,13 @@ class TestInputStream final : public io::ZeroCopyInputStream { } // TestInputStream currently does not support these members. - void BackUp(int) override { GOOGLE_ABSL_CHECK(false); } + void BackUp(int) override { ABSL_CHECK(false); } bool Skip(int) override { - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); return false; } int64_t ByteCount() const override { - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); return 0; } diff --git a/src/google/protobuf/json/internal/unparser.cc b/src/google/protobuf/json/internal/unparser.cc index 85fa40366552..4fa6df653184 100644 --- a/src/google/protobuf/json/internal/unparser.cc +++ b/src/google/protobuf/json/internal/unparser.cc @@ -43,7 +43,7 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/message.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/status/status.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" @@ -417,7 +417,7 @@ absl::Status WriteField(JsonWriter& writer, const Msg& msg, return WriteRepeated(writer, msg, field); } else if (Traits::GetSize(field, msg) == 0) { // We can only get here if always_print_primitive_fields is true. - GOOGLE_ABSL_DCHECK(writer.options().always_print_primitive_fields); + ABSL_DCHECK(writer.options().always_print_primitive_fields); if (Traits::FieldType(field) == FieldDescriptor::TYPE_GROUP) { // We do not yet have full group support, but this is required so that we @@ -539,7 +539,7 @@ absl::Status WriteValue(JsonWriter& writer, const Msg& msg, }); } - GOOGLE_ABSL_CHECK(is_top_level) + ABSL_CHECK(is_top_level) << "empty, non-top-level Value must be handled one layer " "up, since it prints an empty string; reaching this " "statement is always a bug"; @@ -834,11 +834,11 @@ absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver, io::ZeroCopyOutputStream* json_output, json_internal::WriterOptions options) { // NOTE: Most of the contortions in this function are to allow for capture of - // input and output of the parser in GOOGLE_ABSL_DLOG mode. Destruction order is very + // input and output of the parser in ABSL_DLOG mode. Destruction order is very // critical in this function, because io::ZeroCopy*Stream types usually only // flush on destruction. - // For GOOGLE_ABSL_DLOG, we would like to print out the input and output, which + // For ABSL_DLOG, we would like to print out the input and output, which // requires buffering both instead of doing "zero copy". This block, and the // one at the end of the function, set up and tear down interception of the // input and output streams. diff --git a/src/google/protobuf/json/internal/untyped_message.cc b/src/google/protobuf/json/internal/untyped_message.cc index cfec168f2d16..805d0d831007 100644 --- a/src/google/protobuf/json/internal/untyped_message.cc +++ b/src/google/protobuf/json/internal/untyped_message.cc @@ -45,7 +45,7 @@ #include "google/protobuf/dynamic_message.h" #include "google/protobuf/message.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -71,7 +71,7 @@ using ::google::protobuf::internal::WireFormatLite; absl::StatusOr ResolverPool::Field::MessageType() const { - GOOGLE_ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_MESSAGE || + ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_MESSAGE || proto().kind() == google::protobuf::Field::TYPE_GROUP) << proto().kind(); if (type_ == nullptr) { @@ -84,7 +84,7 @@ absl::StatusOr ResolverPool::Field::MessageType() absl::StatusOr ResolverPool::Field::EnumType() const { - GOOGLE_ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_ENUM) + ABSL_CHECK(proto().kind() == google::protobuf::Field::TYPE_ENUM) << proto().kind(); if (type_ == nullptr) { auto type = pool_->FindEnum(proto().type_url()); @@ -295,7 +295,7 @@ absl::Status UntypedMessage::Decode(io::CodedInputStream& stream, break; } case WireFormatLite::WIRETYPE_END_GROUP: - GOOGLE_ABSL_CHECK(false) << "unreachable"; + ABSL_CHECK(false) << "unreachable"; break; default: return absl::InvalidArgumentError( diff --git a/src/google/protobuf/json/internal/untyped_message.h b/src/google/protobuf/json/internal/untyped_message.h index a94389dba0d4..327fb80d8569 100644 --- a/src/google/protobuf/json/internal/untyped_message.h +++ b/src/google/protobuf/json/internal/untyped_message.h @@ -1,4 +1,4 @@ -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ @@ -221,7 +221,7 @@ class UntypedMessage final { } else if (auto* vec = absl::get_if>(&it->second)) { return *vec; } else { - GOOGLE_ABSL_CHECK(false) << "wrong type for UntypedMessage::Get(" << field_number + ABSL_CHECK(false) << "wrong type for UntypedMessage::Get(" << field_number << ")"; return {}; // avoid compiler warning. } diff --git a/src/google/protobuf/json/internal/writer.cc b/src/google/protobuf/json/internal/writer.cc index 881263f04db8..1f6d5e4ae767 100644 --- a/src/google/protobuf/json/internal/writer.cc +++ b/src/google/protobuf/json/internal/writer.cc @@ -36,7 +36,7 @@ #include #include "absl/algorithm/container.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" // Must be included last. #include "google/protobuf/port_def.inc" @@ -148,7 +148,7 @@ struct Utf8Scalar { // Returns U+FFFD on failure, and consumes an unspecified number of bytes in // doing so. static Utf8Scalar ConsumeUtf8Scalar(absl::string_view& str) { - GOOGLE_ABSL_DCHECK(!str.empty()); + ABSL_DCHECK(!str.empty()); uint32_t scalar = static_cast(str[0]); const char* start = str.data(); size_t len = 1; diff --git a/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc b/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc index 9d8349ecd9f7..e8859d1d1f70 100644 --- a/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc +++ b/src/google/protobuf/json/internal/zero_copy_buffered_stream.cc @@ -57,9 +57,9 @@ absl::Status ZeroCopyBufferedStream::Advance(size_t bytes) { } if (using_buf_) { - GOOGLE_ABSL_DCHECK_LE(cursor_, buffer_start_ + buf_.size()); + ABSL_DCHECK_LE(cursor_, buffer_start_ + buf_.size()); } else { - GOOGLE_ABSL_DCHECK_LE(cursor_, last_chunk_.size()); + ABSL_DCHECK_LE(cursor_, last_chunk_.size()); } return absl::OkStatus(); @@ -85,12 +85,12 @@ absl::StatusOr ZeroCopyBufferedStream::BufferAtLeast( } guard = BufferingGuard(this); } - GOOGLE_ABSL_DCHECK_GE(Unread().size(), bytes); + ABSL_DCHECK_GE(Unread().size(), bytes); return BufferingGuard(this); } void ZeroCopyBufferedStream::DownRefBuffer() { - GOOGLE_ABSL_DCHECK_GT(outstanding_buffer_borrows_, 0); + ABSL_DCHECK_GT(outstanding_buffer_borrows_, 0); --outstanding_buffer_borrows_; if (outstanding_buffer_borrows_ > 0 || !using_buf_) { @@ -103,7 +103,7 @@ void ZeroCopyBufferedStream::DownRefBuffer() { size_t last_chunk_in_buf = virtual_buf_len - last_chunk_.size(); // If we are inside of `last_chunk_`, set the cursor there; otherwise, we have // a dangling reference somewhere. - GOOGLE_ABSL_DCHECK_LE(last_chunk_in_buf, virtual_buf_len) << absl::StrFormat( + ABSL_DCHECK_LE(last_chunk_in_buf, virtual_buf_len) << absl::StrFormat( "%d, %d, %d", buf_.size(), last_chunk_.size(), buffer_start_); if (cursor_ <= last_chunk_in_buf) { cursor_ = 0; diff --git a/src/google/protobuf/json/internal/zero_copy_buffered_stream.h b/src/google/protobuf/json/internal/zero_copy_buffered_stream.h index b0dbc932a9d8..96d88b67d8fa 100644 --- a/src/google/protobuf/json/internal/zero_copy_buffered_stream.h +++ b/src/google/protobuf/json/internal/zero_copy_buffered_stream.h @@ -38,8 +38,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" @@ -200,7 +200,7 @@ class ZeroCopyBufferedStream { // end of the buffer if at EOF; BufferAtLeast() should be called before // calling this function. char PeekChar() { - GOOGLE_ABSL_DCHECK(!Unread().empty()); + ABSL_DCHECK(!Unread().empty()); return Unread()[0]; } @@ -327,24 +327,24 @@ inline absl::string_view ZeroCopyBufferedStream::RawBuffer(size_t start, size_t len) const { absl::string_view view = last_chunk_; if (using_buf_) { - GOOGLE_ABSL_DCHECK_LE(buffer_start_, start); + ABSL_DCHECK_LE(buffer_start_, start); start -= buffer_start_; view = absl::string_view(buf_.data(), buf_.size()); } #if 0 // This print statement is especially useful for trouble-shooting low-level // bugs in the buffering logic. - GOOGLE_ABSL_LOG(INFO) << absl::StreamFormat("%s(\"%s\")[%d:%d]/%d:%d @ %p", + ABSL_LOG(INFO) << absl::StreamFormat("%s(\"%s\")[%d:%d]/%d:%d @ %p", using_buf_ ? "buf_" : "last_chunk_", view, start, static_cast(len), buffer_start_, cursor_, this); #endif - GOOGLE_ABSL_DCHECK_LE(start, view.size()); + ABSL_DCHECK_LE(start, view.size()); if (len == absl::string_view::npos) { return view.substr(start); } - GOOGLE_ABSL_DCHECK_LE(start + len, view.size()); + ABSL_DCHECK_LE(start + len, view.size()); return view.substr(start, len); } } // namespace json_internal diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index 8287a6d416c3..7693a497c8b6 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc @@ -37,7 +37,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 78ad72c4dd9f..0b335e9dec4b 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -300,7 +300,7 @@ inline bool TableEntryIsTooLong(NodeBase* node) { node = node->next; } while (node != nullptr); // Invariant: no linked list ever is more than kMaxLength in length. - GOOGLE_ABSL_DCHECK_LE(count, kMaxLength); + ABSL_DCHECK_LE(count, kMaxLength); return count >= kMaxLength; } @@ -339,21 +339,21 @@ inline bool TableEntryIsNonEmptyList(TableEntryPtr entry) { return !TableEntryIsEmpty(entry) && TableEntryIsList(entry); } inline NodeBase* TableEntryToNode(TableEntryPtr entry) { - GOOGLE_ABSL_DCHECK(TableEntryIsList(entry)); + ABSL_DCHECK(TableEntryIsList(entry)); return reinterpret_cast(static_cast(entry)); } inline TableEntryPtr NodeToTableEntry(NodeBase* node) { - GOOGLE_ABSL_DCHECK((reinterpret_cast(node) & 1) == 0); + ABSL_DCHECK((reinterpret_cast(node) & 1) == 0); return static_cast(reinterpret_cast(node)); } template Tree* TableEntryToTree(TableEntryPtr entry) { - GOOGLE_ABSL_DCHECK(TableEntryIsTree(entry)); + ABSL_DCHECK(TableEntryIsTree(entry)); return reinterpret_cast(static_cast(entry) - 1); } template TableEntryPtr TreeToTableEntry(Tree* node) { - GOOGLE_ABSL_DCHECK((reinterpret_cast(node) & 1) == 0); + ABSL_DCHECK((reinterpret_cast(node) & 1) == 0); return static_cast(reinterpret_cast(node) | 1); } @@ -538,8 +538,8 @@ class PROTOBUF_EXPORT UntypedMapBase { } TableEntryPtr* CreateEmptyTable(size_type n) { - GOOGLE_ABSL_DCHECK_GE(n, size_type{kMinTableSize}); - GOOGLE_ABSL_DCHECK_EQ(n & (n - 1), 0u); + ABSL_DCHECK_GE(n, size_type{kMinTableSize}); + ABSL_DCHECK_EQ(n & (n - 1), 0u); TableEntryPtr* result = AllocFor(alloc_).allocate(n); memset(result, 0, n * sizeof(result[0])); return result; @@ -668,7 +668,7 @@ class KeyMapBase : public UntypedMapBase { // Advance through buckets, looking for the first that isn't empty. // If nothing non-empty is found then leave node_ == nullptr. void SearchFrom(size_type start_bucket) { - GOOGLE_ABSL_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ || + ABSL_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ || !m_->TableEntryIsEmpty(m_->index_of_first_non_null_)); for (size_type i = start_bucket; i < m_->num_buckets_; ++i) { TableEntryPtr entry = m_->table_[i]; @@ -678,7 +678,7 @@ class KeyMapBase : public UntypedMapBase { node_ = static_cast(TableEntryToNode(entry)); } else { Tree* tree = TableEntryToTree(entry); - GOOGLE_ABSL_DCHECK(!tree->empty()); + ABSL_DCHECK(!tree->empty()); node_ = static_cast(tree->begin()->second); } return; @@ -717,12 +717,12 @@ class KeyMapBase : public UntypedMapBase { TreeIterator tree_it; const bool is_list = revalidate_if_necessary(b, node, &tree_it); if (is_list) { - GOOGLE_ABSL_DCHECK(TableEntryIsNonEmptyList(b)); + ABSL_DCHECK(TableEntryIsNonEmptyList(b)); auto* head = TableEntryToNode(table_[b]); head = EraseFromLinkedList(node, head); table_[b] = NodeToTableEntry(head); } else { - GOOGLE_ABSL_DCHECK(this->TableEntryIsTree(b)); + ABSL_DCHECK(this->TableEntryIsTree(b)); Tree* tree = internal::TableEntryToTree(this->table_[b]); if (tree_it != tree->begin()) { auto* prev = std::prev(tree_it)->second; @@ -775,13 +775,13 @@ class KeyMapBase : public UntypedMapBase { // Requires count(*KeyPtrFromNodePtr(node)) == 0 and that b is the correct // bucket. num_elements_ is not modified. void InsertUnique(size_type b, KeyNode* node) { - GOOGLE_ABSL_DCHECK(index_of_first_non_null_ == num_buckets_ || + ABSL_DCHECK(index_of_first_non_null_ == num_buckets_ || !TableEntryIsEmpty(index_of_first_non_null_)); // In practice, the code that led to this point may have already // determined whether we are inserting into an empty list, a short list, // or whatever. But it's probably cheap enough to recompute that here; // it's likely that we're inserting into an empty or short list. - GOOGLE_ABSL_DCHECK(FindHelper(node->key()).node == nullptr); + ABSL_DCHECK(FindHelper(node->key()).node == nullptr); if (TableEntryIsEmpty(b)) { InsertUniqueInList(b, node); index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b); @@ -791,7 +791,7 @@ class KeyMapBase : public UntypedMapBase { if (TableEntryIsNonEmptyList(b)) { TreeConvert(b); } - GOOGLE_ABSL_DCHECK(TableEntryIsTree(b)) + ABSL_DCHECK(TableEntryIsTree(b)) << (void*)table_[b] << " " << (uintptr_t)table_[b]; InsertUniqueInTree(b, node); index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b); @@ -864,7 +864,7 @@ class KeyMapBase : public UntypedMapBase { return; } - GOOGLE_ABSL_DCHECK_GE(new_num_buckets, kMinTableSize); + ABSL_DCHECK_GE(new_num_buckets, kMinTableSize); const auto old_table = table_; const size_type old_table_size = num_buckets_; num_buckets_ = new_num_buckets; @@ -898,12 +898,12 @@ class KeyMapBase : public UntypedMapBase { } void TreeConvert(size_type b) { - GOOGLE_ABSL_DCHECK(!TableEntryIsTree(b)); + ABSL_DCHECK(!TableEntryIsTree(b)); Tree* tree = Arena::Create(alloc_.arena(), typename Tree::key_compare(), typename Tree::allocator_type(alloc_)); size_type count = CopyListToTree(b, tree); - GOOGLE_ABSL_DCHECK_EQ(count, tree->size()); + ABSL_DCHECK_EQ(count, tree->size()); table_[b] = TreeToTableEntry(tree); // Relink the nodes. NodeBase* next = nullptr; @@ -1217,14 +1217,14 @@ class Map : private internal::KeyMapBase> { template const T& at(const key_arg& key) const { const_iterator it = find(key); - GOOGLE_ABSL_CHECK(it != end()) << "key not found: " << static_cast(key); + ABSL_CHECK(it != end()) << "key not found: " << static_cast(key); return it->second; } template T& at(const key_arg& key) { iterator it = find(key); - GOOGLE_ABSL_CHECK(it != end()) << "key not found: " << static_cast(key); + ABSL_CHECK(it != end()) << "key not found: " << static_cast(key); return it->second; } @@ -1328,7 +1328,7 @@ class Map : private internal::KeyMapBase> { iterator erase(iterator pos) { auto next = std::next(pos); - GOOGLE_ABSL_DCHECK_EQ(pos.m_, static_cast(this)); + ABSL_DCHECK_EQ(pos.m_, static_cast(this)); auto* node = static_cast(pos.node_); this->erase_no_destroy(pos.bucket_index_, node); DestroyNode(node); diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc index c15222f52589..ec60fd892ffe 100644 --- a/src/google/protobuf/map_field.cc +++ b/src/google/protobuf/map_field.cc @@ -74,8 +74,8 @@ void MapFieldBase::SwapState(MapFieldBase* other) { void SwapRepeatedPtrToNull(RepeatedPtrField** from, RepeatedPtrField** to, Arena* from_arena, Arena* to_arena) { - GOOGLE_ABSL_DCHECK(*from != nullptr); - GOOGLE_ABSL_DCHECK(*to == nullptr); + ABSL_DCHECK(*from != nullptr); + ABSL_DCHECK(*to == nullptr); *to = Arena::CreateMessage >(to_arena); **to = std::move(**from); if (from_arena == nullptr) { @@ -104,7 +104,7 @@ void MapFieldBase::Swap(MapFieldBase* other) { } void MapFieldBase::UnsafeShallowSwap(MapFieldBase* other) { - GOOGLE_ABSL_DCHECK_EQ(arena_, other->arena_); + ABSL_DCHECK_EQ(arena_, other->arena_); InternalSwap(other); } @@ -363,7 +363,7 @@ void DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const { } void DynamicMapField::MergeFrom(const MapFieldBase& other) { - GOOGLE_ABSL_DCHECK(IsMapValid() && other.IsMapValid()); + ABSL_DCHECK(IsMapValid() && other.IsMapValid()); Map* map = MutableMap(); const DynamicMapField& other_field = reinterpret_cast(other); @@ -478,7 +478,7 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const { case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; break; } const MapValueRef& map_val = it->second; @@ -561,7 +561,7 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const { case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; break; } diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 4c8c1add6420..4529b0e52b24 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -70,7 +70,7 @@ class MapIterator; #define TYPE_CHECK(EXPECTEDTYPE, METHOD) \ if (type() != EXPECTEDTYPE) { \ - GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" \ + ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" \ << METHOD << " type does not match\n" \ << " Expected : " \ << FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \ @@ -98,7 +98,7 @@ class PROTOBUF_EXPORT MapKey { FieldDescriptor::CppType type() const { if (type_ == FieldDescriptor::CppType()) { - GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" + ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" << "MapKey::type MapKey is not initialized. " << "Call set methods to initialize MapKey."; } @@ -159,14 +159,14 @@ class PROTOBUF_EXPORT MapKey { if (type_ != other.type_) { // We could define a total order that handles this case, but // there currently no need. So, for now, fail. - GOOGLE_ABSL_LOG(FATAL) << "Unsupported: type mismatch"; + ABSL_LOG(FATAL) << "Unsupported: type mismatch"; } switch (type()) { case FieldDescriptor::CPPTYPE_DOUBLE: case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; return false; case FieldDescriptor::CPPTYPE_STRING: return val_.string_value_.get() < other.val_.string_value_.get(); @@ -187,14 +187,14 @@ class PROTOBUF_EXPORT MapKey { bool operator==(const MapKey& other) const { if (type_ != other.type_) { // To be consistent with operator<, we don't allow this either. - GOOGLE_ABSL_LOG(FATAL) << "Unsupported: type mismatch"; + ABSL_LOG(FATAL) << "Unsupported: type mismatch"; } switch (type()) { case FieldDescriptor::CPPTYPE_DOUBLE: case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; break; case FieldDescriptor::CPPTYPE_STRING: return val_.string_value_.get() == other.val_.string_value_.get(); @@ -209,7 +209,7 @@ class PROTOBUF_EXPORT MapKey { case FieldDescriptor::CPPTYPE_BOOL: return val_.bool_value_ == other.val_.bool_value_; } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return false; } @@ -220,7 +220,7 @@ class PROTOBUF_EXPORT MapKey { case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; break; case FieldDescriptor::CPPTYPE_STRING: *val_.string_value_.get_mutable() = other.val_.string_value_.get(); @@ -291,7 +291,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> { case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT: case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM: case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; break; case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING: return hash()(map_key.GetStringValue()); @@ -315,7 +315,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> { return hash()(map_key.GetBoolValue()); } } - GOOGLE_ABSL_LOG(FATAL) << "Can't get here."; + ABSL_LOG(FATAL) << "Can't get here."; return 0; } bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key1, @@ -358,7 +358,7 @@ class PROTOBUF_EXPORT MapFieldBase { protected: ~MapFieldBase() { // "protected" stops users from deleting a `MapFieldBase *` - GOOGLE_ABSL_DCHECK(repeated_field_ == nullptr); + ABSL_DCHECK(repeated_field_ == nullptr); } void Destruct(); @@ -434,7 +434,7 @@ class PROTOBUF_EXPORT MapFieldBase { // MapFieldBase-derived object, and there is no synchronization going // on between them, tsan will alert. #if defined(__SANITIZE_THREAD__) || defined(THREAD_SANITIZER) - void ConstAccess() const { GOOGLE_ABSL_CHECK_EQ(seq1_, seq2_); } + void ConstAccess() const { ABSL_CHECK_EQ(seq1_, seq2_); } void MutableAccess() { if (seq1_ & 1) { seq2_ = ++seq1_; @@ -774,7 +774,7 @@ class PROTOBUF_EXPORT MapValueConstRef { FieldDescriptor::CppType type() const { if (type_ == FieldDescriptor::CppType() || data_ == nullptr) { - GOOGLE_ABSL_LOG(FATAL) + ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" << "MapValueConstRef::type MapValueConstRef is not initialized."; } diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index 17f728c242b8..677ccc9bc42e 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h @@ -142,7 +142,7 @@ template void TypeDefinedMapFieldBase::InitializeIterator( MapIterator* map_iter) const { map_iter->iter_ = new typename Map::const_iterator; - GOOGLE_ABSL_CHECK(map_iter->iter_ != nullptr); + ABSL_CHECK(map_iter->iter_ != nullptr); } template @@ -345,7 +345,7 @@ void MapField* repeated_field = reinterpret_cast*>( this->MapFieldBase::repeated_field_); - GOOGLE_ABSL_CHECK(this->MapFieldBase::repeated_field_ != nullptr); + ABSL_CHECK(this->MapFieldBase::repeated_field_ != nullptr); map->clear(); for (typename RepeatedPtrField::iterator it = repeated_field->begin(); diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index 799b621cf966..dd41c183e724 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h @@ -193,7 +193,7 @@ struct MapEntryToMapField< #ifndef NDEBUG inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) { bool proper_destruct = false; - GOOGLE_ABSL_CHECK(proper_destruct) << map_field_lite; + ABSL_CHECK(proper_destruct) << map_field_lite; } #endif diff --git a/src/google/protobuf/map_field_test.cc b/src/google/protobuf/map_field_test.cc index 222ccc4b5be3..f988d6bdca5f 100644 --- a/src/google/protobuf/map_field_test.cc +++ b/src/google/protobuf/map_field_test.cc @@ -37,7 +37,7 @@ #include "google/protobuf/repeated_field.h" #include #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_format.h" #include "google/protobuf/arena_test_util.h" #include "google/protobuf/map_test_util.h" diff --git a/src/google/protobuf/map_test.inc b/src/google/protobuf/map_test.inc index 6d1a70cd2b88..98c297f96b8e 100644 --- a/src/google/protobuf/map_test.inc +++ b/src/google/protobuf/map_test.inc @@ -51,8 +51,8 @@ #include "absl/container/btree_set.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/substitute.h" #include "google/protobuf/arena_test_util.h" #include "google/protobuf/descriptor.h" @@ -330,7 +330,7 @@ TEST_F(MapImplTest, MutableAt) { ExpectSingleElement(key, value2); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST_F(MapImplTest, MutableAtNonExistDeathTest) { EXPECT_DEATH(map_.at(0), ""); @@ -352,11 +352,16 @@ TEST_F(MapImplTest, UsageErrors) { MapValueRef value; EXPECT_DEATH( value.SetFloatValue(0.1), - "Protocol Buffer map usage error:\n" - "MapValue[Const]*Ref::type MapValue[Const]*Ref is not initialized."); + testing::AnyOf( + testing::HasSubstr( + "Protocol Buffer map usage error:\n" + "MapValueRef::type MapValueRef is not initialized."), + testing::HasSubstr( + "Protocol Buffer map usage error:\n" + "MapValueConstRef::type MapValueConstRef is not initialized."))); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST_F(MapImplTest, MapKeyAssignment) { MapKey from, to; @@ -529,7 +534,7 @@ static void TestOldVersusNewIterator(int skip, Map* m) { } if (it == m->end()) return; const IteratorType old = it; - GOOGLE_ABSL_LOG(INFO) << "skip=" << skip << ", old->first=" << old->first; + ABSL_LOG(INFO) << "skip=" << skip << ", old->first=" << old->first; const int target_size = initial_size < 100 ? initial_size * 5 : initial_size * 5 / 4; for (int i = 0; m->size() <= target_size; i++) { @@ -557,8 +562,8 @@ static void TestOldVersusNewIterator(int skip, Map* m) { // Create and test an n-element Map, with emphasis on iterator correctness. static void StressTestIterators(int n) { - GOOGLE_ABSL_LOG(INFO) << "StressTestIterators " << n; - GOOGLE_ABSL_CHECK_GT(n, 0); + ABSL_LOG(INFO) << "StressTestIterators " << n; + ABSL_CHECK_GT(n, 0); // Create a random-looking map of size n. Use non-negative integer keys. Map m; uint32_t frog = 123987 + n; @@ -570,7 +575,7 @@ static void StressTestIterators(int n) { frog += counter++; last_key = static_cast(frog) >= 0 ? static_cast(frog) : last_key ^ 1; - GOOGLE_ABSL_DCHECK_GE(last_key, 0); + ABSL_DCHECK_GE(last_key, 0); m[last_key] = last_key ^ 1; } // Test it. @@ -1363,10 +1368,10 @@ void TestTransparent(const Key& key, const Key& miss_key) { EXPECT_EQ(m.at(key), 1); EXPECT_EQ(cm.at(key), 1); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEATH(m.at(miss_key), ""); EXPECT_DEATH(cm.at(miss_key), ""); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST EXPECT_EQ(m.count(key), 1); EXPECT_EQ(cm.count(key), 1); @@ -2293,8 +2298,8 @@ class MyMapEntry internal::WireFormatLite::TYPE_INT32> { public: constexpr MyMapEntry() {} - MyMapEntry(Arena*) { std::abort(); } - Metadata GetMetadata() const override { std::abort(); } + MyMapEntry(Arena*) { ABSL_CHECK(false); } + Metadata GetMetadata() const override { ABSL_CHECK(false); } static bool ValidateKey(void*) { return true; } static bool ValidateValue(void*) { return true; } }; @@ -2305,7 +2310,7 @@ class MyMapEntryLite internal::WireFormatLite::TYPE_INT32> { public: constexpr MyMapEntryLite() {} - explicit MyMapEntryLite(Arena*) { std::abort(); } + explicit MyMapEntryLite(Arena*) { ABSL_CHECK(false); } static bool ValidateKey(void*) { return true; } static bool ValidateValue(void*) { return true; } }; @@ -3782,7 +3787,7 @@ TEST(MapSerializationTest, DeterministicSubmessage) { UNITTEST::TestMaps t; const std::string filename = "golden_message_maps"; std::string golden; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(TestUtil::GetTestDataPath(absl::StrCat( "third_party/protobuf/testdata/", filename)), &golden, true)); @@ -3825,7 +3830,7 @@ TEST(TextFormatMapTest, DynamicMessage) { tester.SetMapFieldsViaReflection(message.get()); std::string expected_text; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(TestUtil::GetTestDataPath("third_party/protobuf/" "testdata/map_test_data.txt"), &expected_text, true)); @@ -3841,7 +3846,7 @@ TEST(TextFormatMapTest, Sorted) { tester.SetMapFieldsViaReflection(&message); std::string expected_text; - GOOGLE_ABSL_CHECK_OK( + ABSL_CHECK_OK( File::GetContents(TestUtil::GetTestDataPath("third_party/protobuf/" "testdata/map_test_data.txt"), &expected_text, true)); @@ -3861,12 +3866,12 @@ TEST(TextFormatMapTest, Sorted) { TEST(TextFormatMapTest, ParseCorruptedString) { std::string serialized_message; - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( TestUtil::GetTestDataPath( "third_party/protobuf/testdata/golden_message_maps"), &serialized_message, true)); UNITTEST::TestMaps message; - GOOGLE_ABSL_CHECK(message.ParseFromString(serialized_message)); + ABSL_CHECK(message.ParseFromString(serialized_message)); TestParseCorruptedString(message); TestParseCorruptedString(message); } @@ -3928,7 +3933,7 @@ TEST(TextFormatMapTest, NoDisableReflectionIterator) { const Reflection* map_entry_reflection = iter->GetReflection(); const FieldDescriptor* value_field_desc = iter->GetDescriptor()->map_value(); map_entry_reflection->SetInt32(&(*iter), value_field_desc, 2); - GOOGLE_ABSL_LOG(INFO) << iter->DebugString(); + ABSL_LOG(INFO) << iter->DebugString(); // In previous implementation, the new change won't be reflected in text // format, because the previous iterator has been invalidated. diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 7191ba5fd688..fc474dd7c1f8 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -40,8 +40,8 @@ #include "absl/base/casts.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" @@ -106,7 +106,7 @@ void Message::CopyFrom(const Message& from) { if (class_to == nullptr || class_to != class_from) { const Descriptor* descriptor = GetDescriptor(); - GOOGLE_ABSL_CHECK_EQ(from.GetDescriptor(), descriptor) + ABSL_CHECK_EQ(from.GetDescriptor(), descriptor) << ": Tried to copy from a message with a different type. " "to: " << descriptor->full_name() @@ -122,7 +122,7 @@ void Message::CopyFrom(const Message& from) { void Message::CopyWithSourceCheck(Message& to, const Message& from) { // Fail if "from" is a descendant of "to" as such copy is not allowed. - GOOGLE_ABSL_DCHECK(!internal::IsDescendant(to, from)) + ABSL_DCHECK(!internal::IsDescendant(to, from)) << "Source of CopyFrom cannot be a descendant of the target."; to.Clear(); @@ -150,7 +150,7 @@ std::string Message::InitializationErrorString() const { } void Message::CheckInitialized() const { - GOOGLE_ABSL_CHECK(IsInitialized()) + ABSL_CHECK(IsInitialized()) << "Message of type \"" << GetDescriptor()->full_name() << "\" is missing required fields: " << InitializationErrorString(); } @@ -184,7 +184,7 @@ size_t Message::ByteSizeLong() const { } void Message::SetCachedSize(int /* size */) const { - GOOGLE_ABSL_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name() + ABSL_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name() << "\" implements neither SetCachedSize() nor ByteSize(). " "Must implement one or the other."; } @@ -219,7 +219,7 @@ namespace internal { void* CreateSplitMessageGeneric(Arena* arena, const void* default_split, size_t size, const void* message, const void* default_message) { - GOOGLE_ABSL_DCHECK_NE(message, default_message); + ABSL_DCHECK_NE(message, default_message); void* split = (arena == nullptr) ? ::operator new(size) : arena->AllocateAligned(size); memcpy(split, default_split, size); @@ -308,13 +308,13 @@ GeneratedMessageFactory* GeneratedMessageFactory::singleton() { void GeneratedMessageFactory::RegisterFile( const google::protobuf::internal::DescriptorTable* table) { if (!files_.insert(table).second) { - GOOGLE_ABSL_LOG(FATAL) << "File is already registered: " << table->filename; + ABSL_LOG(FATAL) << "File is already registered: " << table->filename; } } void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor, const Message* prototype) { - GOOGLE_ABSL_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool()) + ABSL_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool()) << "Tried to register a non-generated type with the generated " "type registry."; @@ -323,7 +323,7 @@ void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor, // the mutex. mutex_.AssertHeld(); if (!type_map_.try_emplace(descriptor, prototype).second) { - GOOGLE_ABSL_LOG(DFATAL) << "Type is already registered: " + ABSL_DLOG(FATAL) << "Type is already registered: " << descriptor->full_name(); } } @@ -344,7 +344,7 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) { const internal::DescriptorTable* registration_data = FindInFileMap(type->file()->name()); if (registration_data == nullptr) { - GOOGLE_ABSL_LOG(DFATAL) << "File appears to be in generated pool but wasn't " + ABSL_DLOG(FATAL) << "File appears to be in generated pool but wasn't " "registered: " << type->file()->name(); return nullptr; @@ -362,7 +362,7 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) { } if (result == nullptr) { - GOOGLE_ABSL_LOG(DFATAL) << "Type appears to be in generated pool but wasn't " + ABSL_DLOG(FATAL) << "Type appears to be in generated pool but wasn't " << "registered: " << type->full_name(); } @@ -396,7 +396,7 @@ T* GetSingleton() { const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor( const FieldDescriptor* field) const { - GOOGLE_ABSL_CHECK(field->is_repeated()); + ABSL_CHECK(field->is_repeated()); switch (field->cpp_type()) { #define HANDLE_PRIMITIVE_TYPE(TYPE, type) \ case FieldDescriptor::CPPTYPE_##TYPE: \ @@ -424,7 +424,7 @@ const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor( return GetSingleton(); } } - GOOGLE_ABSL_LOG(FATAL) << "Should not reach here."; + ABSL_LOG(FATAL) << "Should not reach here."; return nullptr; } diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index eb6123732cf6..ffd639ed04df 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -275,7 +275,7 @@ class PROTOBUF_EXPORT Message : public MessageLite { // exact same class). virtual void MergeFrom(const Message& from); - // Verifies that IsInitialized() returns true. GOOGLE_ABSL_CHECK-fails otherwise, + // Verifies that IsInitialized() returns true. ABSL_CHECK-fails otherwise, // with a nice error message. void CheckInitialized() const; @@ -937,7 +937,7 @@ class PROTOBUF_EXPORT Reflection final { // take arbitrary integer values, and the legacy GetEnum() getter will // dynamically create an EnumValueDescriptor for any integer value without // one. If |false|, setting an unknown enum value via the integer-based - // setters results in undefined behavior (in practice, GOOGLE_ABSL_DCHECK-fails). + // setters results in undefined behavior (in practice, ABSL_DCHECK-fails). // // Generic code that uses reflection to handle messages with enum fields // should check this flag before using the integer-based setter, and either @@ -1526,7 +1526,7 @@ const Type& Reflection::DefaultRaw(const FieldDescriptor* field) const { uint32_t Reflection::GetOneofCase( const Message& message, const OneofDescriptor* oneof_descriptor) const { - GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic()); + ABSL_DCHECK(!oneof_descriptor->is_synthetic()); return internal::GetConstRefAtOffset( message, schema_.GetOneofCaseOffset(oneof_descriptor)); } @@ -1538,20 +1538,20 @@ bool Reflection::HasOneofField(const Message& message, } const void* Reflection::GetSplitField(const Message* message) const { - GOOGLE_ABSL_DCHECK(schema_.IsSplit()); + ABSL_DCHECK(schema_.IsSplit()); return *internal::GetConstPointerAtOffset(message, schema_.SplitOffset()); } void** Reflection::MutableSplitField(Message* message) const { - GOOGLE_ABSL_DCHECK(schema_.IsSplit()); + ABSL_DCHECK(schema_.IsSplit()); return internal::GetPointerAtOffset(message, schema_.SplitOffset()); } template const Type& Reflection::GetRaw(const Message& message, const FieldDescriptor* field) const { - GOOGLE_ABSL_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field)) + ABSL_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field)) << "Field = " << field->full_name(); if (schema_.IsSplit(field)) { return *internal::GetConstPointerAtOffset( diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index b920234e406b..ce5b4efe3258 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -45,8 +45,8 @@ #include "google/protobuf/arena.h" #include "absl/base/dynamic_annotations.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" #include "absl/strings/cord_buffer.h" #include "absl/strings/internal/resize_uninitialized.h" @@ -87,15 +87,15 @@ void ByteSizeConsistencyError(size_t byte_size_before_serialization, size_t byte_size_after_serialization, size_t bytes_produced_by_serialization, const MessageLite& message) { - GOOGLE_ABSL_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization) + ABSL_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization) << message.GetTypeName() << " was modified concurrently during serialization."; - GOOGLE_ABSL_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization) + ABSL_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization) << "Byte size calculation and serialization were inconsistent. This " "may indicate a bug in protocol buffers or it may be caused by " "concurrent modification of " << message.GetTypeName() << "."; - GOOGLE_ABSL_LOG(FATAL) << "This shouldn't be called if all the sizes are equal."; + ABSL_LOG(FATAL) << "This shouldn't be called if all the sizes are equal."; } std::string InitializationErrorMessage(absl::string_view action, @@ -124,7 +124,7 @@ inline bool CheckFieldPresence(const internal::ParseContext& ctx, } // namespace void MessageLite::LogInitializationErrorMessage() const { - GOOGLE_ABSL_LOG(ERROR) << InitializationErrorMessage("parse", *this); + ABSL_LOG(ERROR) << InitializationErrorMessage("parse", *this); } namespace internal { @@ -233,7 +233,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input, if (PROTOBUF_PREDICT_FALSE(!ptr)) return false; ctx.BackUp(ptr); if (!ctx.EndedAtEndOfStream()) { - GOOGLE_ABSL_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit. + ABSL_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit. if (ctx.IsExceedingLimit(ptr)) return false; input->SetLastTag(ctx.LastTag()); } else { @@ -383,14 +383,14 @@ inline uint8_t* SerializeToArrayImpl(const MessageLite& msg, uint8_t* target, &ptr); ptr = msg._InternalSerialize(ptr, &out); out.Trim(ptr); - GOOGLE_ABSL_DCHECK(!out.HadError() && stream.ByteCount() == size); + ABSL_DCHECK(!out.HadError() && stream.ByteCount() == size); return target + size; } else { io::EpsCopyOutputStream out( target, size, io::CodedOutputStream::IsDefaultSerializationDeterministic()); uint8_t* res = msg._InternalSerialize(target, &out); - GOOGLE_ABSL_DCHECK(target + size == res); + ABSL_DCHECK(target + size == res); return res; } } @@ -402,7 +402,7 @@ uint8_t* MessageLite::SerializeWithCachedSizesToArray(uint8_t* target) const { } bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { - GOOGLE_ABSL_DCHECK(IsInitialized()) + ABSL_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return SerializePartialToCodedStream(output); } @@ -411,7 +411,7 @@ bool MessageLite::SerializePartialToCodedStream( io::CodedOutputStream* output) const { const size_t size = ByteSizeLong(); // Force size to be cached. if (size > INT_MAX) { - GOOGLE_ABSL_LOG(ERROR) << GetTypeName() + ABSL_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: " << size; return false; } @@ -433,7 +433,7 @@ bool MessageLite::SerializePartialToCodedStream( bool MessageLite::SerializeToZeroCopyStream( io::ZeroCopyOutputStream* output) const { - GOOGLE_ABSL_DCHECK(IsInitialized()) + ABSL_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return SerializePartialToZeroCopyStream(output); } @@ -442,7 +442,7 @@ bool MessageLite::SerializePartialToZeroCopyStream( io::ZeroCopyOutputStream* output) const { const size_t size = ByteSizeLong(); // Force size to be cached. if (size > INT_MAX) { - GOOGLE_ABSL_LOG(ERROR) << GetTypeName() + ABSL_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: " << size; return false; } @@ -481,7 +481,7 @@ bool MessageLite::SerializePartialToOstream(std::ostream* output) const { } bool MessageLite::AppendToString(std::string* output) const { - GOOGLE_ABSL_DCHECK(IsInitialized()) + ABSL_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return AppendPartialToString(output); } @@ -490,7 +490,7 @@ bool MessageLite::AppendPartialToString(std::string* output) const { size_t old_size = output->size(); size_t byte_size = ByteSizeLong(); if (byte_size > INT_MAX) { - GOOGLE_ABSL_LOG(ERROR) << GetTypeName() + ABSL_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: " << byte_size; return false; } @@ -514,7 +514,7 @@ bool MessageLite::SerializePartialToString(std::string* output) const { } bool MessageLite::SerializeToArray(void* data, int size) const { - GOOGLE_ABSL_DCHECK(IsInitialized()) + ABSL_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return SerializePartialToArray(data, size); } @@ -522,7 +522,7 @@ bool MessageLite::SerializeToArray(void* data, int size) const { bool MessageLite::SerializePartialToArray(void* data, int size) const { const size_t byte_size = ByteSizeLong(); if (byte_size > INT_MAX) { - GOOGLE_ABSL_LOG(ERROR) << GetTypeName() + ABSL_LOG(ERROR) << GetTypeName() << " exceeded maximum protobuf size of 2GB: " << byte_size; return false; } @@ -549,7 +549,7 @@ std::string MessageLite::SerializePartialAsString() const { } bool MessageLite::AppendToCord(absl::Cord* output) const { - GOOGLE_ABSL_DCHECK(IsInitialized()) + ABSL_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return AppendPartialToCord(output); } @@ -560,7 +560,7 @@ bool MessageLite::AppendPartialToCord(absl::Cord* output) const { const size_t size = ByteSizeLong(); const size_t total_size = size + output->size(); if (size > INT_MAX) { - GOOGLE_ABSL_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; + ABSL_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; return false; } @@ -576,10 +576,10 @@ bool MessageLite::AppendPartialToCord(absl::Cord* output) const { target, static_cast(available.size()), io::CodedOutputStream::IsDefaultSerializationDeterministic()); auto res = _InternalSerialize(target, &out); - GOOGLE_ABSL_DCHECK_EQ(res, target + size); + ABSL_DCHECK_EQ(res, target + size); buffer.IncreaseLengthBy(size); output->Append(std::move(buffer)); - GOOGLE_ABSL_DCHECK_EQ(output->size(), total_size); + ABSL_DCHECK_EQ(output->size(), total_size); return true; } @@ -595,7 +595,7 @@ bool MessageLite::AppendPartialToCord(absl::Cord* output) const { out.Trim(target); if (out.HadError()) return false; *output = output_stream.Consume(); - GOOGLE_ABSL_DCHECK_EQ(output->size(), total_size); + ABSL_DCHECK_EQ(output->size(), total_size); return true; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index ced6d86bb855..97a9e832cbd1 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -47,7 +47,7 @@ #include "google/protobuf/arena.h" #include "google/protobuf/port.h" #include "absl/base/call_once.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "google/protobuf/explicitly_constructed.h" @@ -103,7 +103,7 @@ class GenericTypeHandler; // defined in repeated_field.h // computed size to a cached size. Since we don't proceed with serialization // if the total size was > INT_MAX, it is not important what this function // returns for inputs > INT_MAX. However this case should not error or -// GOOGLE_ABSL_CHECK-fail, because the full size_t resolution is still returned from +// ABSL_CHECK-fail, because the full size_t resolution is still returned from // ByteSizeLong() and checked against INT_MAX; we can catch the overflow // there. inline int ToCachedSize(size_t size) { return static_cast(size); } @@ -118,11 +118,11 @@ inline size_t FromIntSize(int size) { return static_cast(size); } -// For cases where a legacy function returns an integer size. We GOOGLE_ABSL_DCHECK() +// For cases where a legacy function returns an integer size. We ABSL_DCHECK() // that the conversion will fit within an integer; if this is false then we // are losing information. inline int ToIntSize(size_t size) { - GOOGLE_ABSL_DCHECK_LE(size, static_cast(INT_MAX)); + ABSL_DCHECK_LE(size, static_cast(INT_MAX)); return static_cast(size); } @@ -331,7 +331,7 @@ class PROTOBUF_EXPORT MessageLite { // Write a protocol buffer of this message to the given output. Returns // false on a write error. If the message is missing required fields, - // this may GOOGLE_ABSL_CHECK-fail. + // this may ABSL_CHECK-fail. bool SerializeToCodedStream(io::CodedOutputStream* output) const; // Like SerializeToCodedStream(), but allows missing required fields. bool SerializePartialToCodedStream(io::CodedOutputStream* output) const; diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc index b69a50b940cf..de6028eacab8 100644 --- a/src/google/protobuf/message_unittest.inc +++ b/src/google/protobuf/message_unittest.inc @@ -54,7 +54,8 @@ #include #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/scoped_mock_log.h" #include "absl/strings/cord.h" #include "absl/strings/substitute.h" #include "google/protobuf/arena.h" @@ -199,20 +200,15 @@ TEST(MESSAGE_TEST_NAME, ParseHelpers) { TEST(MESSAGE_TEST_NAME, ParseFailsIfNotInitialized) { UNITTEST::TestRequired message; - std::vector errors; { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, absl::StrCat( + "Can't parse message of type \"", UNITTEST_PACKAGE_NAME, + ".TestRequired\" because it is missing required fields: a, b, c"))); + log.StartCapturingLogs(); EXPECT_FALSE(message.ParseFromString("")); - errors = log.GetMessages(ERROR); } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ( - absl::StrCat( - "Can't parse message of type \"", UNITTEST_PACKAGE_NAME, - ".TestRequired\" because it is missing required fields: a, b, c"), - errors[0]); } TEST(MESSAGE_TEST_NAME, ParseFailsIfSubmessageNotInitialized) { @@ -223,19 +219,15 @@ TEST(MESSAGE_TEST_NAME, ParseFailsIfSubmessageNotInitialized) { EXPECT_TRUE(message.ParsePartialFromString(serialized)); EXPECT_FALSE(message.IsInitialized()); - std::vector errors; { - ScopedMemoryLog log; - EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString())); - errors = log.GetMessages(ERROR); - } - - EXPECT_THAT( - errors, - testing::ElementsAre(absl::StrCat( + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, absl::StrCat( "Can't parse message of type \"", UNITTEST_PACKAGE_NAME, ".TestRequiredForeign\" because it is missing required fields: " "optional_message.a, optional_message.b, optional_message.c"))); + log.StartCapturingLogs(); + EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString())); + } } TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionNotInitialized) { @@ -248,21 +240,18 @@ TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionNotInitialized) { EXPECT_TRUE(message.ParsePartialFromString(serialized)); EXPECT_FALSE(message.IsInitialized()); - std::vector errors; - { - ScopedMemoryLog log; - EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString())); - errors = log.GetMessages(ERROR); - } - - EXPECT_THAT(errors, - testing::ElementsAre(absl::Substitute( +{ + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, absl::Substitute( "Can't parse message of type \"$0.TestChildExtension\" " "because it is missing required fields: " "optional_extension.($0.TestRequired.single).a, " "optional_extension.($0.TestRequired.single).b, " "optional_extension.($0.TestRequired.single).c", UNITTEST_PACKAGE_NAME))); + log.StartCapturingLogs(); + EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString())); + } } TEST(MESSAGE_TEST_NAME, MergeFromUninitialized) { @@ -689,7 +678,7 @@ TEST(MESSAGE_TEST_NAME, DynamicCastToGenerated) { test_all_types_pointer_nullptr)); } -#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. +#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet. TEST(MESSAGE_TEST_NAME, SerializeFailsIfNotInitialized) { UNITTEST::TestRequired message; @@ -709,7 +698,7 @@ TEST(MESSAGE_TEST_NAME, CheckInitialized) { "fields: a, b, c")); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST namespace { // An input stream that repeats a std::string's content for a number of times. @@ -1285,7 +1274,7 @@ TEST(MESSAGE_TEST_NAME, TestEnumParsers) { continue; } SCOPED_TRACE(value_desc->number()); - GOOGLE_ABSL_CHECK_NE(value_desc->number(), kInvalidValue) + ABSL_CHECK_NE(value_desc->number(), kInvalidValue) << "Invalid value is a real label."; auto encoded = EncodeEnumValue(field->number(), value_desc->number(), @@ -1595,13 +1584,13 @@ class TestInputStream final : public io::ZeroCopyInputStream { return true; } - void BackUp(int) override { GOOGLE_ABSL_CHECK(false); } + void BackUp(int) override { ABSL_CHECK(false); } bool Skip(int) override { - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); return false; } int64_t ByteCount() const override { - GOOGLE_ABSL_CHECK(false); + ABSL_CHECK(false); return 0; } diff --git a/src/google/protobuf/no_field_presence_test.cc b/src/google/protobuf/no_field_presence_test.cc index 067f4082db84..58e88b59a967 100644 --- a/src/google/protobuf/no_field_presence_test.cc +++ b/src/google/protobuf/no_field_presence_test.cc @@ -392,9 +392,9 @@ TEST(NoFieldPresenceTest, HasFieldOneofsTest) { desc->FindFieldByName("oneof_nested_message"); const FieldDescriptor* desc_oneof_string = desc->FindFieldByName("oneof_string"); - GOOGLE_ABSL_CHECK(desc_oneof_uint32 != nullptr); - GOOGLE_ABSL_CHECK(desc_oneof_nested_message != nullptr); - GOOGLE_ABSL_CHECK(desc_oneof_string != nullptr); + ABSL_CHECK(desc_oneof_uint32 != nullptr); + ABSL_CHECK(desc_oneof_nested_message != nullptr); + ABSL_CHECK(desc_oneof_string != nullptr); EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32)); EXPECT_EQ(false, r->HasField(message, desc_oneof_nested_message)); @@ -500,7 +500,7 @@ TEST(NoFieldPresenceTest, LazyMessageFieldHasBit) { const Reflection* r = message.GetReflection(); const Descriptor* desc = message.GetDescriptor(); const FieldDescriptor* field = desc->FindFieldByName("optional_lazy_message"); - GOOGLE_ABSL_CHECK(field != nullptr); + ABSL_CHECK(field != nullptr); EXPECT_EQ(false, message.has_optional_lazy_message()); EXPECT_EQ(false, r->HasField(message, field)); diff --git a/src/google/protobuf/parse_context.cc b/src/google/protobuf/parse_context.cc index c3ce427fb524..e6b6d4166e59 100644 --- a/src/google/protobuf/parse_context.cc +++ b/src/google/protobuf/parse_context.cc @@ -52,8 +52,8 @@ namespace internal { bool EpsCopyInputStream::ParseEndsInSlopRegion(const char* begin, int overrun, int depth) { constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes; - GOOGLE_ABSL_DCHECK_GE(overrun, 0); - GOOGLE_ABSL_DCHECK_LE(overrun, kSlopBytes); + ABSL_DCHECK_GE(overrun, 0); + ABSL_DCHECK_LE(overrun, kSlopBytes); auto ptr = begin + overrun; auto end = begin + kSlopBytes; while (ptr < end) { @@ -102,7 +102,7 @@ bool EpsCopyInputStream::ParseEndsInSlopRegion(const char* begin, int overrun, const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) { if (next_chunk_ == nullptr) return nullptr; // We've reached end of stream. if (next_chunk_ != patch_buffer_) { - GOOGLE_ABSL_DCHECK(size_ > kSlopBytes); + ABSL_DCHECK(size_ > kSlopBytes); // The chunk is large enough to be used directly buffer_end_ = next_chunk_ + size_ - kSlopBytes; auto res = next_chunk_; @@ -134,7 +134,7 @@ const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) { if (aliasing_ >= kNoDelta) aliasing_ = kOnPatch; return patch_buffer_; } - GOOGLE_ABSL_DCHECK(size_ == 0) << size_; + ABSL_DCHECK(size_ == 0) << size_; } overall_limit_ = 0; // Next failed, no more needs for next } @@ -155,7 +155,7 @@ const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) { } const char* EpsCopyInputStream::Next() { - GOOGLE_ABSL_DCHECK(limit_ > kSlopBytes); + ABSL_DCHECK(limit_ > kSlopBytes); auto p = NextBuffer(0 /* immaterial */, -1); if (p == nullptr) { limit_end_ = buffer_end_; @@ -172,25 +172,25 @@ std::pair EpsCopyInputStream::DoneFallback(int overrun, int depth) { // Did we exceeded the limit (parse error). if (PROTOBUF_PREDICT_FALSE(overrun > limit_)) return {nullptr, true}; - GOOGLE_ABSL_DCHECK(overrun != limit_); // Guaranteed by caller. - GOOGLE_ABSL_DCHECK(overrun < limit_); // Follows from above + ABSL_DCHECK(overrun != limit_); // Guaranteed by caller. + ABSL_DCHECK(overrun < limit_); // Follows from above // TODO(gerbens) Instead of this dcheck we could just assign, and remove // updating the limit_end from PopLimit, ie. // limit_end_ = buffer_end_ + (std::min)(0, limit_); // if (ptr < limit_end_) return {ptr, false}; - GOOGLE_ABSL_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_)); + ABSL_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_)); // At this point we know the following assertion holds. - GOOGLE_ABSL_DCHECK_GT(limit_, 0); - GOOGLE_ABSL_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0 + ABSL_DCHECK_GT(limit_, 0); + ABSL_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0 const char* p; do { // We are past the end of buffer_end_, in the slop region. - GOOGLE_ABSL_DCHECK_GE(overrun, 0); + ABSL_DCHECK_GE(overrun, 0); p = NextBuffer(overrun, depth); if (p == nullptr) { // We are at the end of the stream if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true}; - GOOGLE_ABSL_DCHECK_GT(limit_, 0); + ABSL_DCHECK_GT(limit_, 0); limit_end_ = buffer_end_; // Distinguish ending on a pushed limit or ending on end-of-stream. SetEndOfStream(); @@ -264,7 +264,7 @@ const char* EpsCopyInputStream::ReadCordFallback(const char* ptr, int size, StreamBackUp(size_); } else { size -= bytes_from_buffer; - GOOGLE_ABSL_DCHECK_GT(size, 0); + ABSL_DCHECK_GT(size, 0); *cord = absl::string_view(ptr, bytes_from_buffer); if (next_chunk_ == patch_buffer_) { // We have read to end of the last buffer returned by @@ -275,7 +275,7 @@ const char* EpsCopyInputStream::ReadCordFallback(const char* ptr, int size, return nullptr; } else { // Next chunk is already loaded - GOOGLE_ABSL_DCHECK(size_ > kSlopBytes); + ABSL_DCHECK(size_ > kSlopBytes); StreamBackUp(size_ - kSlopBytes); } } @@ -336,7 +336,7 @@ const char* ParseContext::ParseMessage(MessageLite* msg, const char* ptr) { if (ptr == nullptr) return ptr; auto old_depth = depth_; ptr = msg->_InternalParse(ptr, this); - if (ptr != nullptr) GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_); + if (ptr != nullptr) ABSL_DCHECK_EQ(old_depth, depth_); depth_++; if (!PopLimit(old)) return nullptr; return ptr; @@ -674,7 +674,7 @@ const char* UnknownFieldParse(uint32_t tag, std::string* unknown, // result = // num_bits = ValueBarrier(num_bits, result); // if (num_bits == 63) { -// GOOGLE_ABSL_LOG(FATAL) << "Invalid num_bits value"; +// ABSL_LOG(FATAL) << "Invalid num_bits value"; // } // ``` template @@ -694,7 +694,7 @@ PROTOBUF_ALWAYS_INLINE inline V1Type ValueBarrier(V1Type value1) { PROTOBUF_ALWAYS_INLINE inline uint64_t ExtractAndMergeTwoChunks( uint64_t data, uint64_t first_byte) { - GOOGLE_ABSL_DCHECK_LE(first_byte, 6); + ABSL_DCHECK_LE(first_byte, 6); uint64_t first = Ubfx7(data, first_byte * 8); uint64_t second = Ubfx7(data, (first_byte + 1) * 8); return ForceToRegister(first | (second << 7)); diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index d708683a3d92..0568efeca0ad 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -36,8 +36,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" #include "absl/strings/internal/resize_uninitialized.h" #include "absl/strings/string_view.h" @@ -121,7 +121,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { : aliasing_(enable_aliasing ? kOnPatch : kNoAliasing) {} void BackUp(const char* ptr) { - GOOGLE_ABSL_DCHECK(ptr <= buffer_end_ + kSlopBytes); + ABSL_DCHECK(ptr <= buffer_end_ + kSlopBytes); int count; if (next_chunk_ == patch_buffer_) { count = static_cast(buffer_end_ + kSlopBytes - ptr); @@ -133,7 +133,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { // If return value is negative it's an error PROTOBUF_NODISCARD int PushLimit(const char* ptr, int limit) { - GOOGLE_ABSL_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes); + ABSL_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes); // This add is safe due to the invariant above, because // ptr - buffer_end_ <= kSlopBytes. limit += static_cast(ptr - buffer_end_); @@ -238,10 +238,10 @@ class PROTOBUF_EXPORT EpsCopyInputStream { // reached. It aligns *ptr across buffer seams. // If limit is exceeded it returns true and ptr is set to null. bool DoneWithCheck(const char** ptr, int d) { - GOOGLE_ABSL_DCHECK(*ptr); + ABSL_DCHECK(*ptr); if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false; int overrun = static_cast(*ptr - buffer_end_); - GOOGLE_ABSL_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop. + ABSL_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop. if (overrun == limit_) { // No need to flip buffers if we ended on a limit. // If we actually overrun the buffer and next_chunk_ is null. It means @@ -362,7 +362,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { const char* AppendSize(const char* ptr, int size, const A& append) { int chunk_size = static_cast(buffer_end_ + kSlopBytes - ptr); do { - GOOGLE_ABSL_DCHECK(size > chunk_size); + ABSL_DCHECK(size > chunk_size); if (next_chunk_ == nullptr) return nullptr; append(ptr, chunk_size); ptr += chunk_size; @@ -396,7 +396,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { ptr += kSlopBytes; } auto end = buffer_end_ + limit_; - GOOGLE_ABSL_DCHECK(end >= ptr); + ABSL_DCHECK(end >= ptr); append(ptr, end - ptr); return end; } @@ -474,7 +474,7 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { ptr = ReadSizeAndPushLimitAndDepthInlined(ptr, &old); auto old_depth = depth_; ptr = ptr ? TcParser::ParseLoop(msg, ptr, this, table) : nullptr; - if (ptr != nullptr) GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_); + if (ptr != nullptr) ABSL_DCHECK_EQ(old_depth, depth_); depth_++; if (!PopLimit(old)) return nullptr; return ptr; @@ -489,8 +489,8 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { auto old_group_depth = group_depth_; ptr = msg->_InternalParse(ptr, this); if (ptr != nullptr) { - GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_); - GOOGLE_ABSL_DCHECK_EQ(old_group_depth, group_depth_); + ABSL_DCHECK_EQ(old_depth, depth_); + ABSL_DCHECK_EQ(old_group_depth, group_depth_); } group_depth_--; depth_++; @@ -507,8 +507,8 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { auto old_group_depth = group_depth_; ptr = TcParser::ParseLoop(msg, ptr, this, table); if (ptr != nullptr) { - GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_); - GOOGLE_ABSL_DCHECK_EQ(old_group_depth, group_depth_); + ABSL_DCHECK_EQ(old_depth, depth_); + ABSL_DCHECK_EQ(old_group_depth, group_depth_); } group_depth_--; depth_++; @@ -878,7 +878,7 @@ PROTOBUF_NODISCARD const char* ParseContext::ParseMessage(T* msg, if (ptr == nullptr) return ptr; auto old_depth = depth_; ptr = msg->_InternalParse(ptr, this); - if (ptr != nullptr) GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_); + if (ptr != nullptr) ABSL_DCHECK_EQ(old_depth, depth_); depth_++; if (!PopLimit(old)) return nullptr; return ptr; @@ -914,7 +914,7 @@ const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr, #define GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, ret) \ if (!(predicate)) { \ /* ::raise(SIGINT); */ \ - /* GOOGLE_ABSL_LOG(ERROR) << "Parse failure"; */ \ + /* ABSL_LOG(ERROR) << "Parse failure"; */ \ return ret; \ } @@ -952,7 +952,7 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, out->Reserve(old_entries + num); auto dst = out->AddNAlreadyReserved(num); #ifdef PROTOBUF_LITTLE_ENDIAN - GOOGLE_ABSL_CHECK(dst != nullptr) << out << "," << num; + ABSL_CHECK(dst != nullptr) << out << "," << num; std::memcpy(dst, ptr, block_size); #else for (int i = 0; i < num; i++) dst[i] = UnalignedLoad(ptr + i * sizeof(T)); @@ -982,21 +982,21 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { ptr = ReadPackedVarintArray(ptr, buffer_end_, add); if (ptr == nullptr) return nullptr; int overrun = static_cast(ptr - buffer_end_); - GOOGLE_ABSL_DCHECK(overrun >= 0 && overrun <= kSlopBytes); + ABSL_DCHECK(overrun >= 0 && overrun <= kSlopBytes); if (size - chunk_size <= kSlopBytes) { // The current buffer contains all the information needed, we don't need // to flip buffers. However we must parse from a buffer with enough space // so we are not prone to a buffer overflow. char buf[kSlopBytes + 10] = {}; std::memcpy(buf, buffer_end_, kSlopBytes); - GOOGLE_ABSL_CHECK_LE(size - chunk_size, kSlopBytes); + ABSL_CHECK_LE(size - chunk_size, kSlopBytes); auto end = buf + (size - chunk_size); auto res = ReadPackedVarintArray(buf + overrun, end, add); if (res == nullptr || res != end) return nullptr; return buffer_end_ + (res - buf); } size -= overrun + chunk_size; - GOOGLE_ABSL_DCHECK_GT(size, 0); + ABSL_DCHECK_GT(size, 0); // We must flip buffers if (limit_ <= kSlopBytes) return nullptr; ptr = Next(); @@ -1053,7 +1053,7 @@ PROTOBUF_NODISCARD const char* FieldParser(uint64_t tag, T& field_parser, break; } case WireType::WIRETYPE_END_GROUP: { - GOOGLE_ABSL_LOG(FATAL) << "Can't happen"; + ABSL_LOG(FATAL) << "Can't happen"; break; } case WireType::WIRETYPE_FIXED32: { diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 964196fddf86..a8a75766ecb6 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -600,7 +600,7 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and #endif // PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To -// be safe, we also validate the assumption with a GOOGLE_ABSL_DCHECK in unoptimized +// be safe, we also validate the assumption with a ABSL_DCHECK in unoptimized // builds. The macro does not do anything useful if the compiler does not // support __builtin_assume. #ifdef PROTOBUF_ASSUME @@ -608,10 +608,10 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and #endif #if __has_builtin(__builtin_assume) #define PROTOBUF_ASSUME(pred) \ - GOOGLE_ABSL_DCHECK(pred); \ + ABSL_DCHECK(pred); \ __builtin_assume(pred) #else -#define PROTOBUF_ASSUME(pred) GOOGLE_ABSL_DCHECK(pred) +#define PROTOBUF_ASSUME(pred) ABSL_DCHECK(pred) #endif // Specify memory alignment for structs, classes, etc. @@ -1029,14 +1029,14 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and #define PROTOBUF_DEBUG false #endif -// This `for` allows us to condition the `GOOGLE_ABSL_LOG` on the define above, so that +// This `for` allows us to condition the `ABSL_LOG` on the define above, so that // code can write `PROTOBUF_DLOG(INFO) << ...;` and have it turned off when // debug logging is off. // // This is a `for`, not and `if`, to avoid it accidentally chaining with an // `else` below it. #define PROTOBUF_DLOG(x) \ - for (bool b = PROTOBUF_DEBUG; b; b = false) GOOGLE_ABSL_LOG(x) + for (bool b = PROTOBUF_DEBUG; b; b = false) ABSL_LOG(x) #define PROTO2_IS_OSS true diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index a79dfb686736..db1bf2f1871a 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -314,8 +314,8 @@ TEST(Proto3OptionalTest, Extensions) { "protobuf_unittest.Proto3OptionalExtensions.ext_no_optional"); const FieldDescriptor* with_optional = p->FindExtensionByName( "protobuf_unittest.Proto3OptionalExtensions.ext_with_optional"); - GOOGLE_ABSL_CHECK(no_optional); - GOOGLE_ABSL_CHECK(with_optional); + ABSL_CHECK(no_optional); + ABSL_CHECK(with_optional); EXPECT_FALSE(no_optional->has_optional_keyword()); EXPECT_TRUE(with_optional->has_optional_keyword()); @@ -363,8 +363,8 @@ TEST(Proto3OptionalTest, OptionalFieldReflection) { const google::protobuf::Reflection* r = msg.GetReflection(); const google::protobuf::FieldDescriptor* f = d->FindFieldByName("optional_int32"); const google::protobuf::OneofDescriptor* o = d->FindOneofByName("_optional_int32"); - GOOGLE_ABSL_CHECK(f); - GOOGLE_ABSL_CHECK(o); + ABSL_CHECK(f); + ABSL_CHECK(o); EXPECT_TRUE(o->is_synthetic()); EXPECT_FALSE(r->HasField(msg, f)); diff --git a/src/google/protobuf/reflection_internal.h b/src/google/protobuf/reflection_internal.h index 99e9c30633aa..acdfb9696ba6 100644 --- a/src/google/protobuf/reflection_internal.h +++ b/src/google/protobuf/reflection_internal.h @@ -234,7 +234,7 @@ class MapFieldAccessor final : public RandomAccessRepeatedFieldAccessor { } void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator, Field* other_data) const override { - GOOGLE_ABSL_CHECK(this == other_mutator); + ABSL_CHECK(this == other_mutator); MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data)); } @@ -278,7 +278,7 @@ class RepeatedFieldPrimitiveAccessor final : public RepeatedFieldWrapper { // Currently RepeatedFieldPrimitiveAccessor is the only implementation of // RepeatedFieldAccessor for primitive types. As we are using singletons // for these accessors, here "other_mutator" must be "this". - GOOGLE_ABSL_CHECK(this == other_mutator); + ABSL_CHECK(this == other_mutator); MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data)); } @@ -342,7 +342,7 @@ class RepeatedPtrFieldMessageAccessor final RepeatedPtrFieldMessageAccessor() {} void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator, Field* other_data) const override { - GOOGLE_ABSL_CHECK(this == other_mutator); + ABSL_CHECK(this == other_mutator); MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data)); } diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 59c476b4991c..59d4c9342afa 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -36,8 +36,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" @@ -58,7 +58,7 @@ static const Reflection* GetReflectionOrDie(const Message& m) { const Descriptor* d = m.GetDescriptor(); const std::string& mtype = d ? d->name() : "unknown"; // RawMessage is one known type for which GetReflection() returns nullptr. - GOOGLE_ABSL_LOG(FATAL) << "Message does not support reflection (type " << mtype + ABSL_LOG(FATAL) << "Message does not support reflection (type " << mtype << ")."; } return r; @@ -71,10 +71,10 @@ void ReflectionOps::Copy(const Message& from, Message* to) { } void ReflectionOps::Merge(const Message& from, Message* to) { - GOOGLE_ABSL_CHECK_NE(&from, to); + ABSL_CHECK_NE(&from, to); const Descriptor* descriptor = from.GetDescriptor(); - GOOGLE_ABSL_CHECK_EQ(to->GetDescriptor(), descriptor) + ABSL_CHECK_EQ(to->GetDescriptor(), descriptor) << "Tried to merge messages of different types " << "(merge " << descriptor->full_name() << " to " << to->GetDescriptor()->full_name() << ")"; @@ -199,7 +199,7 @@ bool ReflectionOps::IsInitialized(const Message& message, bool check_fields, if (const int field_count = descriptor->field_count()) { const FieldDescriptor* begin = descriptor->field(0); const FieldDescriptor* end = begin + field_count; - GOOGLE_ABSL_DCHECK_EQ(descriptor->field(field_count - 1), end - 1); + ABSL_DCHECK_EQ(descriptor->field(field_count - 1), end - 1); if (check_fields) { // Check required fields of this message. @@ -427,9 +427,9 @@ void ReflectionOps::FindInitializationErrors(const Message& message, void GenericSwap(Message* lhs, Message* rhs) { #ifndef PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != + ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != Arena::InternalGetOwningArena(rhs)); - GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr || + ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr || Arena::InternalGetOwningArena(rhs) != nullptr); #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // At least one of these must have an arena, so make `rhs` point to it. diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index 6f4b50118600..0e1dcb5b13cc 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -184,7 +184,7 @@ TEST(ReflectionOpsTest, MergeOneof) { TestUtil::ExpectOneofSet2(message2); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST TEST(ReflectionOpsTest, MergeFromSelf) { // Note: Copy is implemented in terms of Merge() so technically the Copy @@ -195,7 +195,7 @@ TEST(ReflectionOpsTest, MergeFromSelf) { EXPECT_DEATH(ReflectionOps::Merge(message, &message), "&from"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(ReflectionOpsTest, Clear) { unittest::TestAllTypes message; diff --git a/src/google/protobuf/reflection_tester.cc b/src/google/protobuf/reflection_tester.cc index 5c35f40435f2..a26addfa8670 100644 --- a/src/google/protobuf/reflection_tester.cc +++ b/src/google/protobuf/reflection_tester.cc @@ -198,7 +198,7 @@ MapReflectionTester::MapReflectionTester(const Descriptor* base_descriptor) map_int32_foreign_message_key_, map_int32_foreign_message_val_}; for (const FieldDescriptor* fdesc : all_map_descriptors) { - GOOGLE_ABSL_CHECK(fdesc->containing_type() != nullptr) << fdesc->name(); + ABSL_CHECK(fdesc->containing_type() != nullptr) << fdesc->name(); if (fdesc->name() == "key") { EXPECT_EQ(fdesc->containing_type()->map_key(), fdesc); } else { @@ -212,7 +212,7 @@ MapReflectionTester::MapReflectionTester(const Descriptor* base_descriptor) const FieldDescriptor* MapReflectionTester::F(const std::string& name) { const FieldDescriptor* result = nullptr; result = base_descriptor_->FindFieldByName(name); - GOOGLE_ABSL_CHECK(result != nullptr); + ABSL_CHECK(result != nullptr); return result; } diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index 6327de815489..afdb5bfb8622 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -37,8 +37,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" // Must be included last. diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index e90ba4f623e2..432990d6f602 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -55,7 +55,7 @@ #include "google/protobuf/arena.h" #include "google/protobuf/port.h" #include "absl/base/dynamic_annotations.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/meta/type_traits.h" #include "absl/strings/cord.h" #include "google/protobuf/generated_enum_util.h" @@ -335,7 +335,7 @@ class RepeatedField final { // Swaps entire contents with "other". Should be called only if the caller can // guarantee that both repeated fields are on the same arena or are on the // heap. Swapping between different arenas is disallowed and caught by a - // GOOGLE_ABSL_DCHECK (see API docs for details). + // ABSL_DCHECK (see API docs for details). void UnsafeArenaSwap(RepeatedField* other); // Copy constructs `n` instances in place into the array `dst`. @@ -432,7 +432,7 @@ class RepeatedField final { // Returns a pointer to elements array. // pre-condition: the array must have been allocated. Element* elements() const { - GOOGLE_ABSL_DCHECK_GT(total_size_, 0); + ABSL_DCHECK_GT(total_size_, 0); // Because of above pre-condition this cast is safe. return unsafe_elements(); } @@ -584,14 +584,14 @@ inline int RepeatedField::Capacity() const { template inline void RepeatedField::AddAlreadyReserved(Element value) { - GOOGLE_ABSL_DCHECK_LT(current_size_, total_size_); + ABSL_DCHECK_LT(current_size_, total_size_); void* p = elements() + ExchangeCurrentSize(current_size_ + 1); ::new (p) Element(std::move(value)); } template inline Element* RepeatedField::AddAlreadyReserved() { - GOOGLE_ABSL_DCHECK_LT(current_size_, total_size_); + ABSL_DCHECK_LT(current_size_, total_size_); // new (p) compiles into nothing: this is intentional as this // function is documented to return uninitialized data for trivial types. void* p = elements() + ExchangeCurrentSize(current_size_ + 1); @@ -600,7 +600,7 @@ inline Element* RepeatedField::AddAlreadyReserved() { template inline Element* RepeatedField::AddNAlreadyReserved(int n) { - GOOGLE_ABSL_DCHECK_GE(total_size_ - current_size_, n) + ABSL_DCHECK_GE(total_size_ - current_size_, n) << total_size_ << ", " << current_size_; Element* p = unsafe_elements() + ExchangeCurrentSize(current_size_ + n); for (Element *begin = p, *end = p + n; begin != end; ++begin) { @@ -611,7 +611,7 @@ inline Element* RepeatedField::AddNAlreadyReserved(int n) { template inline void RepeatedField::Resize(int new_size, const Element& value) { - GOOGLE_ABSL_DCHECK_GE(new_size, 0); + ABSL_DCHECK_GE(new_size, 0); if (new_size > current_size_) { if (new_size > total_size_) Grow(current_size_, new_size); Element* first = elements() + ExchangeCurrentSize(new_size); @@ -624,36 +624,36 @@ inline void RepeatedField::Resize(int new_size, const Element& value) { template inline const Element& RepeatedField::Get(int index) const { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); return elements()[index]; } template inline const Element& RepeatedField::at(int index) const { - GOOGLE_ABSL_CHECK_GE(index, 0); - GOOGLE_ABSL_CHECK_LT(index, current_size_); + ABSL_CHECK_GE(index, 0); + ABSL_CHECK_LT(index, current_size_); return elements()[index]; } template inline Element& RepeatedField::at(int index) { - GOOGLE_ABSL_CHECK_GE(index, 0); - GOOGLE_ABSL_CHECK_LT(index, current_size_); + ABSL_CHECK_GE(index, 0); + ABSL_CHECK_LT(index, current_size_); return elements()[index]; } template inline Element* RepeatedField::Mutable(int index) { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); return &elements()[index]; } template inline void RepeatedField::Set(int index, const Element& value) { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); elements()[index] = value; } @@ -741,7 +741,7 @@ inline void RepeatedField::Add(Iter begin, Iter end) { template inline void RepeatedField::RemoveLast() { - GOOGLE_ABSL_DCHECK_GT(current_size_, 0); + ABSL_DCHECK_GT(current_size_, 0); elements()[current_size_ - 1].~Element(); ExchangeCurrentSize(current_size_ - 1); } @@ -749,9 +749,9 @@ inline void RepeatedField::RemoveLast() { template void RepeatedField::ExtractSubrange(int start, int num, Element* elements) { - GOOGLE_ABSL_DCHECK_GE(start, 0); - GOOGLE_ABSL_DCHECK_GE(num, 0); - GOOGLE_ABSL_DCHECK_LE(start + num, this->current_size_); + ABSL_DCHECK_GE(start, 0); + ABSL_DCHECK_GE(num, 0); + ABSL_DCHECK_LE(start + num, this->current_size_); // Save the values of the removed elements if requested. if (elements != nullptr) { @@ -774,7 +774,7 @@ inline void RepeatedField::Clear() { template inline void RepeatedField::MergeFrom(const RepeatedField& rhs) { - GOOGLE_ABSL_DCHECK_NE(&rhs, this); + ABSL_DCHECK_NE(&rhs, this); if (size_t size = rhs.current_size_) { Reserve(current_size_ + size); Element* dst = elements() + ExchangeCurrentSize(current_size_ + size); @@ -824,7 +824,7 @@ inline const Element* RepeatedField::data() const { template inline void RepeatedField::InternalSwap(RepeatedField* other) { - GOOGLE_ABSL_DCHECK(this != other); + ABSL_DCHECK(this != other); // Swap all fields at once. static_assert(std::is_standard_layout>::value, @@ -857,7 +857,7 @@ void RepeatedField::Swap(RepeatedField* other) { template void RepeatedField::UnsafeArenaSwap(RepeatedField* other) { if (this == other) return; - GOOGLE_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); + ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); InternalSwap(other); } @@ -943,14 +943,14 @@ void RepeatedField::Reserve(int new_size) { template PROTOBUF_NOINLINE void RepeatedField::GrowNoAnnotate(int current_size, int new_size) { - GOOGLE_ABSL_DCHECK_GT(new_size, total_size_); + ABSL_DCHECK_GT(new_size, total_size_); Rep* new_rep; Arena* arena = GetOwningArena(); new_size = internal::CalculateReserveSize( total_size_, new_size); - GOOGLE_ABSL_DCHECK_LE( + ABSL_DCHECK_LE( static_cast(new_size), (std::numeric_limits::max() - kRepHeaderSize) / sizeof(Element)) << "Requested size is too large to fit into size_t."; @@ -997,7 +997,7 @@ PROTOBUF_NOINLINE void RepeatedField::Grow(int current_size, template inline void RepeatedField::Truncate(int new_size) { - GOOGLE_ABSL_DCHECK_LE(new_size, current_size_); + ABSL_DCHECK_LE(new_size, current_size_); if (new_size < current_size_) { Destroy(unsafe_elements() + new_size, unsafe_elements() + current_size_); ExchangeCurrentSize(new_size); diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index 4d4f39e184b3..616fbc53dd87 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -139,7 +139,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7)); } -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = desc->FindFieldByName("optional_int32"); @@ -150,7 +150,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { EXPECT_DEATH(refl->GetRepeatedPtrField( message, fd_repeated_foreign_message), "wrong submessage type"); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } @@ -166,7 +166,7 @@ TEST(RepeatedFieldReflectionTest, ExtensionFields) { const FieldDescriptor* fd_repeated_int64_extension = desc->file()->FindExtensionByName("repeated_int64_extension"); - GOOGLE_ABSL_CHECK(fd_repeated_int64_extension != nullptr); + ABSL_CHECK(fd_repeated_int64_extension != nullptr); const RepeatedField& rf_int64_extension = refl->GetRepeatedField(extended_message, @@ -421,7 +421,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { EXPECT_TRUE(rf_message.empty()); EXPECT_TRUE(mrf_message.empty()); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = @@ -434,7 +434,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { message, fd_repeated_foreign_message), ""); -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForEnums) { @@ -539,7 +539,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForExtensionFields) { const FieldDescriptor* fd_repeated_int64_extension = desc->file()->FindExtensionByName("repeated_int64_extension"); - GOOGLE_ABSL_CHECK(fd_repeated_int64_extension != nullptr); + ABSL_CHECK(fd_repeated_int64_extension != nullptr); const RepeatedFieldRef rf_int64_extension = refl->GetRepeatedFieldRef(extended_message, diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 67253caf46f8..248f01e6be18 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -49,7 +49,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/bits.h" #include "absl/strings/cord.h" #include "absl/strings/str_cat.h" @@ -195,7 +195,7 @@ TEST(RepeatedField, ArenaAllocationSizesMatchExpectedValues) { // This is important to avoid a branch in the reallocation path. // This is also important because allocating anything less would be wasting // memory. - // If the allocation size is wrong, ReturnArrayMemory will GOOGLE_ABSL_DCHECK. + // If the allocation size is wrong, ReturnArrayMemory will ABSL_DCHECK. CheckAllocationSizes>(false); CheckAllocationSizes>(false); CheckAllocationSizes>(false); @@ -984,7 +984,7 @@ TEST(RepeatedField, Truncate) { // Truncations that don't change the size are allowed, but growing is not // allowed. field.Truncate(field.size()); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), "new_size"); #endif } @@ -1060,7 +1060,7 @@ TEST(RepeatedField, TruncateCords) { // Truncating to the current size should be fine (no-op), but truncating // to a larger size should crash. field.Truncate(field.size()); -#if defined(PROTOBUF_HAS_DEATH_TEST) && !defined(NDEBUG) +#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG) EXPECT_DEATH(field.Truncate(field.size() + 1), "new_size"); #endif } @@ -1127,7 +1127,7 @@ TEST(RepeatedField, HardenAgainstBadTruncate) { RepeatedField field; for (int size = 0; size < 10; ++size) { field.Truncate(size); -#if PROTOBUF_HAS_DEATH_TEST +#if GTEST_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(field.Truncate(size + 1), "new_size <= current_size_"); EXPECT_DEBUG_DEATH(field.Truncate(size + 2), "new_size <= current_size_"); #elif defined(NDEBUG) @@ -1139,7 +1139,7 @@ TEST(RepeatedField, HardenAgainstBadTruncate) { } } -#if defined(PROTOBUF_HAS_DEATH_TEST) && (defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ +#if defined(GTEST_HAS_DEATH_TEST) && (defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ defined(ABSL_HAVE_MEMORY_SANITIZER)) // This function verifies that the code dies under ASAN or MSAN trying to both @@ -2370,7 +2370,7 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { std::lower_bound(proto_array_.pointer_begin(), proto_array_.pointer_end(), &v, StringLessThan()); - GOOGLE_ABSL_CHECK(*it != nullptr); + ABSL_CHECK(*it != nullptr); EXPECT_EQ(**it, "n"); EXPECT_TRUE(it == proto_array_.pointer_begin() + 3); @@ -2381,7 +2381,7 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { const_proto_array_->pointer_begin(), const_proto_array_->pointer_end(), &v, StringLessThan()); - GOOGLE_ABSL_CHECK(*it != nullptr); + ABSL_CHECK(*it != nullptr); EXPECT_EQ(**it, "n"); EXPECT_TRUE(it == const_proto_array_->pointer_begin() + 3); diff --git a/src/google/protobuf/repeated_ptr_field.cc b/src/google/protobuf/repeated_ptr_field.cc index 025b0875773b..39001555b581 100644 --- a/src/google/protobuf/repeated_ptr_field.cc +++ b/src/google/protobuf/repeated_ptr_field.cc @@ -34,7 +34,7 @@ #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/implicit_weak_message.h" #include "google/protobuf/port.h" #include "google/protobuf/repeated_field.h" @@ -58,7 +58,7 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { Arena* arena = GetOwningArena(); new_size = internal::CalculateReserveSize(total_size_, new_size); - GOOGLE_ABSL_CHECK_LE(static_cast(new_size), + ABSL_CHECK_LE(static_cast(new_size), static_cast( (std::numeric_limits::max() - kRepHeaderSize) / sizeof(old_rep->elements[0]))) @@ -98,8 +98,8 @@ void RepeatedPtrFieldBase::Reserve(int new_size) { } void RepeatedPtrFieldBase::DestroyProtos() { - GOOGLE_ABSL_DCHECK(rep_); - GOOGLE_ABSL_DCHECK(arena_ == nullptr); + ABSL_DCHECK(rep_); + ABSL_DCHECK(arena_ == nullptr); int n = rep_->allocated_size; void* const* elements = rep_->elements; for (int i = 0; i < n; i++) { diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h index f39b712abf76..90534e90cfae 100644 --- a/src/google/protobuf/repeated_ptr_field.h +++ b/src/google/protobuf/repeated_ptr_field.h @@ -58,7 +58,7 @@ #include "google/protobuf/arena.h" #include "google/protobuf/port.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/message_lite.h" #include "google/protobuf/port.h" @@ -185,22 +185,22 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template const typename TypeHandler::Type& at(int index) const { - GOOGLE_ABSL_CHECK_GE(index, 0); - GOOGLE_ABSL_CHECK_LT(index, current_size_); + ABSL_CHECK_GE(index, 0); + ABSL_CHECK_LT(index, current_size_); return *cast(rep_->elements[index]); } template typename TypeHandler::Type& at(int index) { - GOOGLE_ABSL_CHECK_GE(index, 0); - GOOGLE_ABSL_CHECK_LT(index, current_size_); + ABSL_CHECK_GE(index, 0); + ABSL_CHECK_LT(index, current_size_); return *cast(rep_->elements[index]); } template typename TypeHandler::Type* Mutable(int index) { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); return cast(rep_->elements[index]); } @@ -238,8 +238,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template void Delete(int index) { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); TypeHandler::Delete(cast(rep_->elements[index]), arena_); } @@ -268,8 +268,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template const typename TypeHandler::Type& Get(int index) const { - GOOGLE_ABSL_DCHECK_GE(index, 0); - GOOGLE_ABSL_DCHECK_LT(index, current_size_); + ABSL_DCHECK_GE(index, 0); + ABSL_DCHECK_LT(index, current_size_); return *cast(rep_->elements[index]); } @@ -282,7 +282,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template void Clear() { const int n = current_size_; - GOOGLE_ABSL_DCHECK_GE(n, 0); + ABSL_DCHECK_GE(n, 0); if (n > 0) { ClearNonEmpty(); } @@ -296,14 +296,14 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // binary. This calls a shared implementation with most of the logic, // passing a function pointer to another type-specific piece of code that // calls the object-allocate and merge handlers. - GOOGLE_ABSL_DCHECK_NE(&other, this); + ABSL_DCHECK_NE(&other, this); if (other.current_size_ == 0) return; MergeFromInternal(other, &RepeatedPtrFieldBase::MergeFromInnerLoop); } inline void InternalSwap(RepeatedPtrFieldBase* rhs) { - GOOGLE_ABSL_DCHECK(this != rhs); + ABSL_DCHECK(this != rhs); // Swap all fields at once. auto temp = std::make_tuple(rhs->arena_, rhs->current_size_, @@ -344,7 +344,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { protected: template void RemoveLast() { - GOOGLE_ABSL_DCHECK_GT(current_size_, 0); + ABSL_DCHECK_GT(current_size_, 0); ExchangeCurrentSize(current_size_ - 1); TypeHandler::Clear(cast(rep_->elements[current_size_])); } @@ -479,7 +479,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // arena. template typename TypeHandler::Type* UnsafeArenaReleaseLast() { - GOOGLE_ABSL_DCHECK_GT(current_size_, 0); + ABSL_DCHECK_GT(current_size_, 0); ExchangeCurrentSize(current_size_ - 1); typename TypeHandler::Type* result = cast(rep_->elements[current_size_]); @@ -498,10 +498,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template void AddCleared(typename TypeHandler::Type* value) { - GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "AddCleared() can only be used on a " "RepeatedPtrField not on an arena."; - GOOGLE_ABSL_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) + ABSL_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) << "AddCleared() can only accept values not on an arena."; if (!rep_ || rep_->allocated_size == total_size_) { Reserve(total_size_ + 1); @@ -511,11 +511,11 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared() { - GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ReleaseCleared() can only be used on a RepeatedPtrField not on " << "an arena."; - GOOGLE_ABSL_DCHECK(rep_ != nullptr); - GOOGLE_ABSL_DCHECK_GT(rep_->allocated_size, current_size_); + ABSL_DCHECK(rep_ != nullptr); + ABSL_DCHECK_GT(rep_->allocated_size, current_size_); return cast(rep_->elements[--rep_->allocated_size]); } @@ -608,9 +608,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { typename TypeHandler::Type* ReleaseLastInternal(std::false_type) { // ReleaseLast() for types that *do not* implement merge/copy behavior -- // this is the same as UnsafeArenaReleaseLast(). Note that we - // GOOGLE_ABSL_DCHECK-fail if we're on an arena, since the user really should + // ABSL_DCHECK-fail if we're on an arena, since the user really should // implement the copy operation in this case. - GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ReleaseLast() called on a RepeatedPtrField that is on an arena, " << "with a type that does not implement MergeFrom. This is unsafe; " << "please implement MergeFrom for your type."; @@ -620,10 +620,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { template PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) { #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr || + ABSL_DCHECK(GetOwningArena() == nullptr || other->GetOwningArena() != GetOwningArena()); #else // PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_ABSL_DCHECK(other->GetOwningArena() != GetOwningArena()); + ABSL_DCHECK(other->GetOwningArena() != GetOwningArena()); #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // Copy semantics in this case. We try to improve efficiency by placing the @@ -697,7 +697,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { const int n = current_size_; void* const* elements = rep_->elements; int i = 0; - GOOGLE_ABSL_DCHECK_GT( + ABSL_DCHECK_GT( n, 0); // do/while loop to avoid initial test because we know n > 0 do { @@ -1010,7 +1010,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Swaps entire contents with "other". Caller should guarantee that either // both fields are on the same arena or both are on the heap. Swapping between // different arenas with this function is disallowed and is caught via - // GOOGLE_ABSL_DCHECK. + // ABSL_DCHECK. void UnsafeArenaSwap(RepeatedPtrField* other); // Swaps two elements. @@ -1153,7 +1153,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // this method. // // This method cannot be called when either the repeated field or |value| is - // on an arena; both cases will trigger a GOOGLE_ABSL_DCHECK-failure. + // on an arena; both cases will trigger a ABSL_DCHECK-failure. ABSL_DEPRECATED("This will be removed in a future release") void AddCleared(Element* value); // Removes and returns a single element from the cleared pool, passing @@ -1161,7 +1161,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Requires: ClearedCount() > 0 // // This method cannot be called when the repeated field is on an arena; doing - // so will trigger a GOOGLE_ABSL_DCHECK-failure. + // so will trigger a ABSL_DCHECK-failure. PROTOBUF_NODISCARD ABSL_DEPRECATED("This will be removed in a future release") Element* ReleaseCleared(); @@ -1379,9 +1379,9 @@ inline void RepeatedPtrField::RemoveLast() { template inline void RepeatedPtrField::DeleteSubrange(int start, int num) { - GOOGLE_ABSL_DCHECK_GE(start, 0); - GOOGLE_ABSL_DCHECK_GE(num, 0); - GOOGLE_ABSL_DCHECK_LE(start + num, size()); + ABSL_DCHECK_GE(start, 0); + ABSL_DCHECK_GE(num, 0); + ABSL_DCHECK_LE(start + num, size()); for (int i = 0; i < num; ++i) { RepeatedPtrFieldBase::Delete(start + i); } @@ -1401,13 +1401,13 @@ inline void RepeatedPtrField::ExtractSubrange(int start, int num, template inline void RepeatedPtrField::ExtractSubrangeInternal( int start, int num, Element** elements, std::true_type) { - GOOGLE_ABSL_DCHECK_GE(start, 0); - GOOGLE_ABSL_DCHECK_GE(num, 0); - GOOGLE_ABSL_DCHECK_LE(start + num, size()); + ABSL_DCHECK_GE(start, 0); + ABSL_DCHECK_GE(num, 0); + ABSL_DCHECK_LE(start + num, size()); if (num == 0) return; - GOOGLE_ABSL_DCHECK_NE(elements, nullptr) + ABSL_DCHECK_NE(elements, nullptr) << "Releasing elements without transferring ownership is an unsafe " "operation. Use UnsafeArenaExtractSubrange."; if (elements == nullptr) { @@ -1451,9 +1451,9 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( int start, int num, Element** elements, std::false_type) { // This case is identical to UnsafeArenaExtractSubrange(). However, since // ExtractSubrange() must return heap-allocated objects by contract, and we - // cannot fulfill this contract if we are an on arena, we must GOOGLE_ABSL_DCHECK() + // cannot fulfill this contract if we are an on arena, we must ABSL_DCHECK() // that we are not on an arena. - GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr) + ABSL_DCHECK(GetOwningArena() == nullptr) << "ExtractSubrange() when arena is non-nullptr is only supported when " << "the Element type supplies a MergeFrom() operation to make copies."; UnsafeArenaExtractSubrange(start, num, elements); @@ -1462,9 +1462,9 @@ inline void RepeatedPtrField::ExtractSubrangeInternal( template inline void RepeatedPtrField::UnsafeArenaExtractSubrange( int start, int num, Element** elements) { - GOOGLE_ABSL_DCHECK_GE(start, 0); - GOOGLE_ABSL_DCHECK_GE(num, 0); - GOOGLE_ABSL_DCHECK_LE(start + num, size()); + ABSL_DCHECK_GE(start, 0); + ABSL_DCHECK_GE(num, 0); + ABSL_DCHECK_LE(start + num, size()); if (num > 0) { // Save the values of the removed elements if requested. @@ -1535,7 +1535,7 @@ template inline void RepeatedPtrField::UnsafeArenaSwap( RepeatedPtrField* other) { if (this == other) return; - GOOGLE_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); + ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); RepeatedPtrFieldBase::InternalSwap(other); } diff --git a/src/google/protobuf/serial_arena.h b/src/google/protobuf/serial_arena.h index 19d0e70dd160..67fb2d82c809 100644 --- a/src/google/protobuf/serial_arena.h +++ b/src/google/protobuf/serial_arena.h @@ -40,7 +40,7 @@ #include #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/bits.h" #include "google/protobuf/arena_align.h" #include "google/protobuf/arena_cleanup.h" @@ -66,11 +66,11 @@ struct ArenaBlock { ArenaBlock(ArenaBlock* next, size_t size) : next(next), cleanup_nodes(nullptr), size(size) { - GOOGLE_ABSL_DCHECK_GT(size, sizeof(ArenaBlock)); + ABSL_DCHECK_GT(size, sizeof(ArenaBlock)); } char* Pointer(size_t n) { - GOOGLE_ABSL_DCHECK_LE(n, size); + ABSL_DCHECK_LE(n, size); return reinterpret_cast(this) + n; } char* Limit() { return Pointer(size & static_cast(-8)); } @@ -146,8 +146,8 @@ class PROTOBUF_EXPORT SerialArena { // from it. template void* AllocateAligned(size_t n) { - GOOGLE_ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n)); - GOOGLE_ABSL_DCHECK_GE(limit_, ptr()); + ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n)); + ABSL_DCHECK_GE(limit_, ptr()); if (alloc_client == AllocationClient::kArray) { if (void* res = TryAllocateFromCachedBlock(n)) { @@ -238,8 +238,8 @@ class PROTOBUF_EXPORT SerialArena { public: // Allocate space if the current region provides enough space. bool MaybeAllocateAligned(size_t n, void** out) { - GOOGLE_ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n)); - GOOGLE_ABSL_DCHECK_GE(limit_, ptr()); + ABSL_DCHECK(internal::ArenaAlignDefault::IsAligned(n)); + ABSL_DCHECK_GE(limit_, ptr()); if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) return false; *out = AllocateFromExisting(n); return true; @@ -250,7 +250,7 @@ class PROTOBUF_EXPORT SerialArena { // and the memory returned is uninitialized. template PROTOBUF_ALWAYS_INLINE void* MaybeAllocateWithCleanup() { - GOOGLE_ABSL_DCHECK_GE(limit_, ptr()); + ABSL_DCHECK_GE(limit_, ptr()); static_assert(!std::is_trivially_destructible::value, "This function is only for non-trivial types."); @@ -292,7 +292,7 @@ class PROTOBUF_EXPORT SerialArena { PROTOBUF_UNPOISON_MEMORY_REGION(ptr(), n); void* ret = ArenaAlignAs(align).CeilDefaultAligned(ptr()); set_ptr(ptr() + n); - GOOGLE_ABSL_DCHECK_GE(limit_, ptr()); + ABSL_DCHECK_GE(limit_, ptr()); AddCleanupFromExisting(ret, destructor); return ret; } @@ -304,7 +304,7 @@ class PROTOBUF_EXPORT SerialArena { PROTOBUF_UNPOISON_MEMORY_REGION(limit_ - n, n); limit_ -= n; - GOOGLE_ABSL_DCHECK_GE(limit_, ptr()); + ABSL_DCHECK_GE(limit_, ptr()); cleanup::CreateNode(tag, limit_, elem, destructor); } diff --git a/src/google/protobuf/string_member_robber.h b/src/google/protobuf/string_member_robber.h index 58104ebac085..aff7d581d0a4 100644 --- a/src/google/protobuf/string_member_robber.h +++ b/src/google/protobuf/string_member_robber.h @@ -34,7 +34,7 @@ #include #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #endif // GOOGLE_PROTOBUF_STRING_MEMBER_ROBBER_H__ diff --git a/src/google/protobuf/stubs/BUILD.bazel b/src/google/protobuf/stubs/BUILD.bazel index b685e8f48e82..8452a24b258a 100644 --- a/src/google/protobuf/stubs/BUILD.bazel +++ b/src/google/protobuf/stubs/BUILD.bazel @@ -17,7 +17,6 @@ cc_library( hdrs = [ "callback.h", "common.h", - "logging.h", "platform_macros.h", "port.h", "status_macros.h", @@ -27,7 +26,9 @@ cc_library( linkopts = LINK_OPTS, deps = [ "//src/google/protobuf:port_def", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", ], ) @@ -43,7 +44,6 @@ cc_library( textual_hdrs = [ "callback.h", "common.h", - "logging.h", "platform_macros.h", "port.h", "status_macros.h", @@ -73,6 +73,7 @@ cc_test( ":lite", ":stubs", "//src/google/protobuf/testing", + "@com_google_absl//absl/log:absl_log", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", ], diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index b029e099a0d5..56803959a3d6 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -50,11 +50,11 @@ #include #endif +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/stubs/callback.h" -#include "google/protobuf/stubs/logging.h" // Must be last. #include "google/protobuf/port_def.inc" // NOLINT @@ -69,26 +69,32 @@ void VerifyVersion(int headerVersion, const char* filename) { if (GOOGLE_PROTOBUF_VERSION < minLibraryVersion) { // Library is too old for headers. - GOOGLE_LOG(FATAL) - << "This program requires version " << VersionString(minLibraryVersion) - << " of the Protocol Buffer runtime library, but the installed version " - "is " << VersionString(GOOGLE_PROTOBUF_VERSION) << ". Please update " - "your library. If you compiled the program yourself, make sure that " - "your headers are from the same version of Protocol Buffers as your " - "link-time library. (Version verification failed in \"" - << filename << "\".)"; + ABSL_LOG(FATAL) + << "This program requires version " << VersionString(minLibraryVersion) + << " of the Protocol Buffer runtime library, but the installed version " + "is " + << VersionString(GOOGLE_PROTOBUF_VERSION) + << ". Please update " + "your library. If you compiled the program yourself, make sure " + "that " + "your headers are from the same version of Protocol Buffers as your " + "link-time library. (Version verification failed in \"" + << filename << "\".)"; } if (headerVersion < kMinHeaderVersionForLibrary) { // Headers are too old for library. - GOOGLE_LOG(FATAL) - << "This program was compiled against version " - << VersionString(headerVersion) << " of the Protocol Buffer runtime " - "library, which is not compatible with the installed version (" - << VersionString(GOOGLE_PROTOBUF_VERSION) << "). Contact the program " - "author for an update. If you compiled the program yourself, make " - "sure that your headers are from the same version of Protocol Buffers " - "as your link-time library. (Version verification failed in \"" - << filename << "\".)"; + ABSL_LOG(FATAL) + << "This program was compiled against version " + << VersionString(headerVersion) + << " of the Protocol Buffer runtime " + "library, which is not compatible with the installed version (" + << VersionString(GOOGLE_PROTOBUF_VERSION) + << "). Contact the program " + "author for an update. If you compiled the program yourself, make " + "sure that your headers are from the same version of Protocol " + "Buffers " + "as your link-time library. (Version verification failed in \"" + << filename << "\".)"; } } @@ -125,171 +131,6 @@ std::string ProtocVersionString(int version) { } // namespace internal -// =================================================================== -// emulates google3/base/logging.cc - -// If the minimum logging level is not set, we default to logging messages for -// all levels. -#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL -#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO -#endif - -namespace internal { - -#if defined(__ANDROID__) -inline void DefaultLogHandler(LogLevel level, const char* filename, int line, - const std::string& message) { - if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { - return; - } - static const char* level_names[] = {"INFO", "WARNING", "ERROR", "FATAL"}; - - static const int android_log_levels[] = { - ANDROID_LOG_INFO, // LOG(INFO), - ANDROID_LOG_WARN, // LOG(WARNING) - ANDROID_LOG_ERROR, // LOG(ERROR) - ANDROID_LOG_FATAL, // LOG(FATAL) - }; - - // Bound the logging level. - const int android_log_level = android_log_levels[level]; - ::std::ostringstream ostr; - ostr << "[libprotobuf " << level_names[level] << " " << filename << ":" - << line << "] " << message.c_str(); - - // Output the log string the Android log at the appropriate level. - __android_log_write(android_log_level, "libprotobuf-native", - ostr.str().c_str()); - // Also output to std::cerr. - fprintf(stderr, "%s", ostr.str().c_str()); - fflush(stderr); - - // Indicate termination if needed. - if (android_log_level == ANDROID_LOG_FATAL) { - __android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native", - "terminating.\n"); - } -} - -#else -void DefaultLogHandler(LogLevel level, const char* filename, int line, - const std::string& message) { - if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { - return; - } - static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; - - // We use fprintf() instead of cerr because we want this to work at static - // initialization time. - fprintf(stderr, "[libprotobuf %s %s:%d] %s\n", - level_names[level], filename, line, message.c_str()); - fflush(stderr); // Needed on MSVC. -} -#endif - -void NullLogHandler(LogLevel /* level */, const char* /* filename */, - int /* line */, const std::string& /* message */) { - // Nothing. -} - -static LogHandler* log_handler_ = &DefaultLogHandler; -static std::atomic log_silencer_count_{0}; - -LogMessage& LogMessage::operator<<(const std::string& value) { - message_ += value; - return *this; -} - -LogMessage& LogMessage::operator<<(const char* value) { - message_ += value; - return *this; -} - -LogMessage& LogMessage::operator<<(absl::string_view value) { - absl::StrAppend(&message_, value); - return *this; -} - -LogMessage& LogMessage::operator<<(const absl::Status& status) { - message_ += status.ToString(); - return *this; -} - -LogMessage& LogMessage::operator<<(char value) { - return *this << absl::string_view(&value, 1); -} - -LogMessage& LogMessage::operator<<(void* value) { - absl::StrAppend(&message_, absl::Hex(reinterpret_cast(value))); - return *this; -} - -#undef DECLARE_STREAM_OPERATOR -#define DECLARE_STREAM_OPERATOR(TYPE) \ - LogMessage& LogMessage::operator<<(TYPE value) { \ - absl::StrAppend(&message_, value); \ - return *this; \ - } - -DECLARE_STREAM_OPERATOR(int) -DECLARE_STREAM_OPERATOR(unsigned int) -DECLARE_STREAM_OPERATOR(long) // NOLINT(runtime/int) -DECLARE_STREAM_OPERATOR(unsigned long) // NOLINT(runtime/int) -DECLARE_STREAM_OPERATOR(double) -DECLARE_STREAM_OPERATOR(long long) // NOLINT(runtime/int) -DECLARE_STREAM_OPERATOR(unsigned long long) // NOLINT(runtime/int) -#undef DECLARE_STREAM_OPERATOR - -LogMessage::LogMessage(LogLevel level, const char* filename, int line) - : level_(level), filename_(filename), line_(line) {} -LogMessage::~LogMessage() {} - -void LogMessage::Finish() { - bool suppress = false; - - if (level_ != LOGLEVEL_FATAL) { - suppress = log_silencer_count_ > 0; - } - - if (!suppress) { - log_handler_(level_, filename_, line_, message_); - } - - if (level_ == LOGLEVEL_FATAL) { -#if PROTOBUF_USE_EXCEPTIONS - throw FatalException(filename_, line_, message_); -#else - abort(); -#endif - } -} - -void LogFinisher::operator=(LogMessage& other) { - other.Finish(); -} - -} // namespace internal - -LogHandler* SetLogHandler(LogHandler* new_func) { - LogHandler* old = internal::log_handler_; - if (old == &internal::NullLogHandler) { - old = nullptr; - } - if (new_func == nullptr) { - internal::log_handler_ = &internal::NullLogHandler; - } else { - internal::log_handler_ = new_func; - } - return old; -} - -LogSilencer::LogSilencer() { - ++internal::log_silencer_count_; -}; - -LogSilencer::~LogSilencer() { - --internal::log_silencer_count_; -}; // =================================================================== // emulates google3/base/callback.cc @@ -318,14 +159,6 @@ uint32_t ghtonl(uint32_t x) { return result; } -#if PROTOBUF_USE_EXCEPTIONS -FatalException::~FatalException() throw() {} - -const char* FatalException::what() const throw() { - return message_.c_str(); -} -#endif - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index c75a7c9d334d..a3b0c6918049 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -45,19 +45,6 @@ #include "google/protobuf/stubs/platform_macros.h" #include "google/protobuf/stubs/port.h" -#ifndef PROTOBUF_USE_EXCEPTIONS -#if defined(_MSC_VER) && defined(_CPPUNWIND) - #define PROTOBUF_USE_EXCEPTIONS 1 -#elif defined(__EXCEPTIONS) - #define PROTOBUF_USE_EXCEPTIONS 1 -#else - #define PROTOBUF_USE_EXCEPTIONS 0 -#endif -#endif - -#if PROTOBUF_USE_EXCEPTIONS -#include -#endif #if defined(__APPLE__) #include // for TARGET_OS_IPHONE #endif @@ -137,27 +124,6 @@ void StrongReference(const T& var) { } } // namespace internal - -#if PROTOBUF_USE_EXCEPTIONS -class FatalException : public std::exception { - public: - FatalException(const char* filename, int line, const std::string& message) - : filename_(filename), line_(line), message_(message) {} - virtual ~FatalException() throw(); - - const char* what() const throw() override; - - const char* filename() const { return filename_; } - int line() const { return line_; } - const std::string& message() const { return message_; } - - private: - const char* filename_; - const int line_; - const std::string message_; -}; -#endif - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index 71058c05697b..6f97ecc5681d 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -36,10 +36,10 @@ #include +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/substitute.h" #include "google/protobuf/stubs/callback.h" -#include "google/protobuf/stubs/logging.h" #include "google/protobuf/testing/googletest.h" namespace google { @@ -78,88 +78,6 @@ TEST(CommonTest, IntMinMaxConstants) { EXPECT_EQ(0, kuint64max + 1); } -std::vector captured_messages_; - -void CaptureLog(LogLevel level, const char* filename, int line, - const std::string& message) { - captured_messages_.push_back(absl::Substitute( - "$0 $1:$2: $3", static_cast(level), filename, line, message)); -} - -TEST(LoggingTest, DefaultLogging) { - CaptureTestStderr(); - int line = __LINE__; - GOOGLE_LOG(INFO ) << "A message."; - GOOGLE_LOG(WARNING) << "A warning."; - GOOGLE_LOG(ERROR ) << "An error."; - - std::string text = GetCapturedTestStderr(); - EXPECT_EQ(absl::StrCat("[libprotobuf INFO " __FILE__ ":", line + 1, - "] A message.\n" - "[libprotobuf WARNING " __FILE__ ":", - line + 2, - "] A warning.\n" - "[libprotobuf ERROR " __FILE__ ":", - line + 3, "] An error.\n"), - text); -} - -TEST(LoggingTest, NullLogging) { - LogHandler* old_handler = SetLogHandler(nullptr); - - CaptureTestStderr(); - GOOGLE_LOG(INFO ) << "A message."; - GOOGLE_LOG(WARNING) << "A warning."; - GOOGLE_LOG(ERROR ) << "An error."; - - EXPECT_TRUE(SetLogHandler(old_handler) == nullptr); - - std::string text = GetCapturedTestStderr(); - EXPECT_EQ("", text); -} - -TEST(LoggingTest, CaptureLogging) { - captured_messages_.clear(); - - LogHandler* old_handler = SetLogHandler(&CaptureLog); - - int start_line = __LINE__; - GOOGLE_LOG(ERROR) << "An error."; - GOOGLE_LOG(WARNING) << "A warning."; - - EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); - - ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ(absl::StrCat("2 " __FILE__ ":", start_line + 1, ": An error."), - captured_messages_[0]); - EXPECT_EQ(absl::StrCat("1 " __FILE__ ":", start_line + 2, ": A warning."), - captured_messages_[1]); -} - -TEST(LoggingTest, SilenceLogging) { - captured_messages_.clear(); - - LogHandler* old_handler = SetLogHandler(&CaptureLog); - - int line1 = __LINE__; GOOGLE_LOG(INFO) << "Visible1"; - LogSilencer* silencer1 = new LogSilencer; - GOOGLE_LOG(INFO) << "Not visible."; - LogSilencer* silencer2 = new LogSilencer; - GOOGLE_LOG(INFO) << "Not visible."; - delete silencer1; - GOOGLE_LOG(INFO) << "Not visible."; - delete silencer2; - int line2 = __LINE__; GOOGLE_LOG(INFO) << "Visible2"; - - EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); - - ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line1, ": Visible1"), - captured_messages_[0]); - EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line2, ": Visible2"), - captured_messages_[1]); -} - class ClosureTest : public testing::Test { public: void SetA123Method() { a_ = 123; } diff --git a/src/google/protobuf/stubs/logging.h b/src/google/protobuf/stubs/logging.h deleted file mode 100644 index f1af273839f2..000000000000 --- a/src/google/protobuf/stubs/logging.h +++ /dev/null @@ -1,266 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_STUBS_LOGGING_H_ -#define GOOGLE_PROTOBUF_STUBS_LOGGING_H_ - -#include "absl/status/status.h" -#include "absl/strings/string_view.h" -#include "google/protobuf/stubs/port.h" - -// Must be last. -#include "google/protobuf/port_def.inc" // NOLINT - -// =================================================================== -// emulates google3/base/logging.h - -namespace google { -namespace protobuf { - -enum LogLevel { - LOGLEVEL_INFO, // Informational. This is never actually used by - // libprotobuf. - LOGLEVEL_WARNING, // Warns about issues that, although not technically a - // problem now, could cause problems in the future. For - // example, a // warning will be printed when parsing a - // message that is near the message size limit. - LOGLEVEL_ERROR, // An error occurred which should never happen during - // normal use. - LOGLEVEL_FATAL, // An error occurred from which the library cannot - // recover. This usually indicates a programming error - // in the code which calls the library, especially when - // compiled in debug mode. - -#ifdef NDEBUG - LOGLEVEL_DFATAL = LOGLEVEL_ERROR -#else - LOGLEVEL_DFATAL = LOGLEVEL_FATAL -#endif -}; - -class uint128; -namespace internal { - -class LogFinisher; - -class PROTOBUF_EXPORT LogMessage { - public: - LogMessage(LogLevel level, const char* filename, int line); - ~LogMessage(); - - LogMessage& operator<<(const std::string& value); - LogMessage& operator<<(const char* value); - LogMessage& operator<<(char value); - LogMessage& operator<<(int value); - LogMessage& operator<<(uint value); - LogMessage& operator<<(long value); - LogMessage& operator<<(unsigned long value); - LogMessage& operator<<(long long value); - LogMessage& operator<<(unsigned long long value); - LogMessage& operator<<(double value); - LogMessage& operator<<(void* value); - LogMessage& operator<<(absl::string_view value); - LogMessage& operator<<(const absl::Status& status); - LogMessage& operator<<(const uint128& value); - - private: - friend class LogFinisher; - void Finish(); - - LogLevel level_; - const char* filename_; - int line_; - std::string message_; -}; - -// Used to make the entire "LOG(BLAH) << etc." expression have a void return -// type and print a newline after each message. -class PROTOBUF_EXPORT LogFinisher { - public: - void operator=(LogMessage& other); -}; - -template -bool IsOk(T status) { return status.ok(); } -template<> -inline bool IsOk(bool status) { return status; } - -} // namespace internal - -// Undef everything in case we're being mixed with some other Google library -// which already defined them itself. Presumably all Google libraries will -// support the same syntax for these so it should not be a big deal if they -// end up using our definitions instead. -#undef GOOGLE_LOG -#undef GOOGLE_LOG_IF - -#undef GOOGLE_CHECK -#undef GOOGLE_CHECK_OK -#undef GOOGLE_CHECK_EQ -#undef GOOGLE_CHECK_NE -#undef GOOGLE_CHECK_LT -#undef GOOGLE_CHECK_LE -#undef GOOGLE_CHECK_GT -#undef GOOGLE_CHECK_GE -#undef GOOGLE_CHECK_NOTNULL - -#undef GOOGLE_DLOG -#undef GOOGLE_DCHECK -#undef GOOGLE_DCHECK_OK -#undef GOOGLE_DCHECK_EQ -#undef GOOGLE_DCHECK_NE -#undef GOOGLE_DCHECK_LT -#undef GOOGLE_DCHECK_LE -#undef GOOGLE_DCHECK_GT -#undef GOOGLE_DCHECK_GE - -#define GOOGLE_LOG(LEVEL) \ - ::google::protobuf::internal::LogFinisher() = \ - ::google::protobuf::internal::LogMessage( \ - ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__) -#define GOOGLE_ABSL_LOG(LEVEL) \ - ::google::protobuf::internal::LogFinisher() = \ - ::google::protobuf::internal::LogMessage( \ - ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__) -#define GOOGLE_LOG_IF(LEVEL, CONDITION) \ - !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) -#define GOOGLE_ABSL_LOG_IF(LEVEL, CONDITION) \ - !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) - -#define GOOGLE_CHECK(EXPRESSION) \ - GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " -#define GOOGLE_ABSL_CHECK(EXPRESSION) \ - GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " - -#define GOOGLE_CHECK_OK(A) GOOGLE_CHECK(::google::protobuf::internal::IsOk(A)) -#define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B)) -#define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B)) -#define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B)) -#define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B)) -#define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B)) -#define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) - -#define GOOGLE_ABSL_CHECK_OK GOOGLE_CHECK_OK -#define GOOGLE_ABSL_CHECK_EQ GOOGLE_CHECK_EQ -#define GOOGLE_ABSL_CHECK_NE GOOGLE_CHECK_NE -#define GOOGLE_ABSL_CHECK_LT GOOGLE_CHECK_LT -#define GOOGLE_ABSL_CHECK_LE GOOGLE_CHECK_LE -#define GOOGLE_ABSL_CHECK_GT GOOGLE_CHECK_GT -#define GOOGLE_ABSL_CHECK_GE GOOGLE_CHECK_GE - -namespace internal { -template -T* CheckNotNull(const char* /* file */, int /* line */, - const char* name, T* val) { - if (val == nullptr) { - GOOGLE_LOG(FATAL) << name; - } - return val; -} -} // namespace internal -#define GOOGLE_CHECK_NOTNULL(A) \ - ::google::protobuf::internal::CheckNotNull( \ - __FILE__, __LINE__, "'" #A "' must not be nullptr", (A)) - -#ifdef NDEBUG - -#define GOOGLE_DLOG(LEVEL) GOOGLE_LOG_IF(LEVEL, false) - -#define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION) -#define GOOGLE_DCHECK_OK(E) GOOGLE_DCHECK(::google::protobuf::internal::IsOk(E)) -#define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B)) -#define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B)) -#define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B)) -#define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B)) -#define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B)) -#define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B)) - -#else // NDEBUG - -#define GOOGLE_DLOG GOOGLE_LOG - -#define GOOGLE_DCHECK GOOGLE_CHECK -#define GOOGLE_DCHECK_OK GOOGLE_CHECK_OK -#define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ -#define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE -#define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT -#define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE -#define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT -#define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE - -#endif // !NDEBUG - -#define GOOGLE_ABSL_DLOG GOOGLE_DLOG -#define GOOGLE_ABSL_DCHECK GOOGLE_DCHECK -#define GOOGLE_ABSL_DCHECK_OK GOOGLE_DCHECK_OK -#define GOOGLE_ABSL_DCHECK_EQ GOOGLE_DCHECK_EQ -#define GOOGLE_ABSL_DCHECK_NE GOOGLE_DCHECK_NE -#define GOOGLE_ABSL_DCHECK_LT GOOGLE_DCHECK_LT -#define GOOGLE_ABSL_DCHECK_LE GOOGLE_DCHECK_LE -#define GOOGLE_ABSL_DCHECK_GT GOOGLE_DCHECK_GT -#define GOOGLE_ABSL_DCHECK_GE GOOGLE_DCHECK_GE - -typedef void LogHandler(LogLevel level, const char* filename, int line, - const std::string& message); - -// The protobuf library sometimes writes warning and error messages to -// stderr. These messages are primarily useful for developers, but may -// also help end users figure out a problem. If you would prefer that -// these messages be sent somewhere other than stderr, call SetLogHandler() -// to set your own handler. This returns the old handler. Set the handler -// to nullptr to ignore log messages (but see also LogSilencer, below). -// -// Obviously, SetLogHandler is not thread-safe. You should only call it -// at initialization time, and probably not from library code. If you -// simply want to suppress log messages temporarily (e.g. because you -// have some code that tends to trigger them frequently and you know -// the warnings are not important to you), use the LogSilencer class -// below. -PROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func); - -// Create a LogSilencer if you want to temporarily suppress all log -// messages. As long as any LogSilencer objects exist, non-fatal -// log messages will be discarded (the current LogHandler will *not* -// be called). Constructing a LogSilencer is thread-safe. You may -// accidentally suppress log messages occurring in another thread, but -// since messages are generally for debugging purposes only, this isn't -// a big deal. If you want to intercept log messages, use SetLogHandler(). -class PROTOBUF_EXPORT LogSilencer { - public: - LogSilencer(); - ~LogSilencer(); -}; - -} // namespace protobuf -} // namespace google - -#include "google/protobuf/port_undef.inc" // NOLINT - -#endif // GOOGLE_PROTOBUF_STUBS_LOGGING_H_ diff --git a/src/google/protobuf/test_util.h b/src/google/protobuf/test_util.h index b15b39563c4e..45bffea1c661 100644 --- a/src/google/protobuf/test_util.h +++ b/src/google/protobuf/test_util.h @@ -201,7 +201,7 @@ inline const FieldDescriptor* TestUtil::ReflectionTester::F( } else { result = base_descriptor_->FindFieldByName(name); } - GOOGLE_ABSL_CHECK(result != nullptr); + ABSL_CHECK(result != nullptr); return result; } diff --git a/src/google/protobuf/test_util.inc b/src/google/protobuf/test_util.inc index df62d415c61c..4374f4f1fb65 100644 --- a/src/google/protobuf/test_util.inc +++ b/src/google/protobuf/test_util.inc @@ -38,7 +38,7 @@ // out of this file. #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/message.h" @@ -1113,7 +1113,7 @@ inline void TestUtil::SetOneofFields(UNITTEST::TestAllExtensions* message) { inline void TestUtil::SetAllFieldsAndExtensions( UNITTEST::TestFieldOrderings* message) { - GOOGLE_ABSL_CHECK(message); + ABSL_CHECK(message); message->set_my_int(1); message->set_my_string("foo"); message->set_my_float(1.0); diff --git a/src/google/protobuf/test_util2.h b/src/google/protobuf/test_util2.h index 6d3685c545ab..9cc1456ce842 100644 --- a/src/google/protobuf/test_util2.h +++ b/src/google/protobuf/test_util2.h @@ -50,7 +50,7 @@ inline std::string TranslatePathToOpensource(absl::string_view google3_path) { constexpr absl::string_view net_proto2 = "net/proto2/"; constexpr absl::string_view third_party_protobuf = "third_party/protobuf/"; if (!absl::ConsumePrefix(&google3_path, net_proto2)) { - GOOGLE_ABSL_CHECK(absl::ConsumePrefix(&google3_path, third_party_protobuf)) + ABSL_CHECK(absl::ConsumePrefix(&google3_path, third_party_protobuf)) << google3_path; } @@ -92,7 +92,7 @@ class BoundedArrayInputStream : public io::ZeroCopyInputStream { ~BoundedArrayInputStream() override {} bool Next(const void** data, int* size) override { - GOOGLE_ABSL_CHECK_LT(stream_.ByteCount(), bound_); + ABSL_CHECK_LT(stream_.ByteCount(), bound_); return stream_.Next(data, size); } void BackUp(int count) override { stream_.BackUp(count); } diff --git a/src/google/protobuf/testing/BUILD.bazel b/src/google/protobuf/testing/BUILD.bazel index 399ae0c83626..572c1f9f4613 100644 --- a/src/google/protobuf/testing/BUILD.bazel +++ b/src/google/protobuf/testing/BUILD.bazel @@ -25,7 +25,12 @@ cc_library( "//:protobuf_lite", # for ShutdownProtobufLibrary "//src/google/protobuf/io", "//src/google/protobuf/stubs:lite", + "@com_google_absl//absl/base:log_severity", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/log:log_sink", + "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_googletest//:gtest", ], diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc index d75aa8a2d131..ce948597cc71 100644 --- a/src/google/protobuf/testing/file.cc +++ b/src/google/protobuf/testing/file.cc @@ -46,10 +46,15 @@ #endif #include +#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 "google/protobuf/io/io_win32.h" -#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/status_macros.h" + +// Needs to be last. +#include "google/protobuf/port_def.inc" // NOLINT namespace google { namespace protobuf { @@ -73,11 +78,11 @@ bool File::Exists(const std::string& name) { return access(name.c_str(), F_OK) == 0; } -bool File::ReadFileToString(const std::string& name, std::string* output, - bool text_mode) { +absl::Status File::ReadFileToString(const std::string& name, + std::string* output, bool text_mode) { char buffer[1024]; FILE* file = fopen(name.c_str(), text_mode ? "rt" : "rb"); - if (file == NULL) return false; + if (file == NULL) return absl::NotFoundError("Could not open file"); while (true) { size_t n = fread(buffer, 1, sizeof(buffer), file); @@ -86,67 +91,70 @@ bool File::ReadFileToString(const std::string& name, std::string* output, } int error = ferror(file); - if (fclose(file) != 0) return false; - return error == 0; + if (fclose(file) != 0) return absl::InternalError("Failed to close file"); + if (error != 0) return absl::InternalError("Error parsing file"); + return absl::OkStatus(); } void File::ReadFileToStringOrDie(const std::string& name, std::string* output) { - GOOGLE_CHECK(ReadFileToString(name, output)) << "Could not read: " << name; + ABSL_CHECK_OK(ReadFileToString(name, output)) << "Could not read: " << name; } -bool File::WriteStringToFile(absl::string_view contents, - const std::string& name) { +absl::Status File::WriteStringToFile(absl::string_view contents, + const std::string& name) { FILE* file = fopen(name.c_str(), "wb"); if (file == NULL) { - GOOGLE_LOG(ERROR) << "fopen(" << name << ", \"wb\"): " << strerror(errno); - return false; + return absl::InternalError( + absl::StrCat("fopen(", name, ", \"wb\"): ", strerror(errno))); } if (fwrite(contents.data(), 1, contents.size(), file) != contents.size()) { - GOOGLE_LOG(ERROR) << "fwrite(" << name << "): " << strerror(errno); fclose(file); - return false; + return absl::InternalError( + absl::StrCat("fwrite(", name, "): ", strerror(errno))); } if (fclose(file) != 0) { - return false; + return absl::InternalError("Failed to close file"); } - return true; + return absl::OkStatus(); } void File::WriteStringToFileOrDie(absl::string_view contents, const std::string& name) { FILE* file = fopen(name.c_str(), "wb"); - GOOGLE_CHECK(file != NULL) - << "fopen(" << name << ", \"wb\"): " << strerror(errno); - GOOGLE_CHECK_EQ(fwrite(contents.data(), 1, contents.size(), file), - contents.size()) + ABSL_CHECK(file != NULL) << "fopen(" << name + << ", \"wb\"): " << strerror(errno); + ABSL_CHECK_EQ(fwrite(contents.data(), 1, contents.size(), file), + contents.size()) << "fwrite(" << name << "): " << strerror(errno); - GOOGLE_CHECK(fclose(file) == 0) + ABSL_CHECK(fclose(file) == 0) << "fclose(" << name << "): " << strerror(errno); } -bool File::CreateDir(const std::string& name, int mode) { +absl::Status File::CreateDir(const std::string& name, int mode) { if (!name.empty()) { - GOOGLE_CHECK_OK(name[name.size() - 1] != '.'); + ABSL_CHECK(name[name.size() - 1] != '.'); + } + if (mkdir(name.c_str(), mode) != 0) { + return absl::InternalError("Failed to create directory"); } - return mkdir(name.c_str(), mode) == 0; + return absl::OkStatus(); } -bool File::RecursivelyCreateDir(const std::string& path, int mode) { - if (CreateDir(path, mode)) return true; +absl::Status File::RecursivelyCreateDir(const std::string& path, int mode) { + if (CreateDir(path, mode).ok()) return absl::OkStatus(); - if (Exists(path)) return false; + if (Exists(path)) return absl::AlreadyExistsError("Path already exists"); // Try creating the parent. std::string::size_type slashpos = path.find_last_of('/'); if (slashpos == std::string::npos) { - // No parent given. - return false; + return absl::FailedPreconditionError("No parent given"); } - return RecursivelyCreateDir(path.substr(0, slashpos), mode) && - CreateDir(path, mode); + RETURN_IF_ERROR(RecursivelyCreateDir(path.substr(0, slashpos), mode)); + return CreateDir(path, mode); } void File::DeleteRecursively(const std::string& name, void* dummy1, @@ -217,3 +225,5 @@ bool File::ChangeWorkingDirectory(const std::string& new_working_directory) { } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" // NOLINT diff --git a/src/google/protobuf/testing/file.h b/src/google/protobuf/testing/file.h index b6d2a4aa53b0..de8fc01d4aea 100644 --- a/src/google/protobuf/testing/file.h +++ b/src/google/protobuf/testing/file.h @@ -34,6 +34,7 @@ #ifndef GOOGLE_PROTOBUF_TESTING_FILE_H__ #define GOOGLE_PROTOBUF_TESTING_FILE_H__ +#include "absl/status/status.h" #include "absl/strings/string_view.h" #include "google/protobuf/stubs/common.h" @@ -54,26 +55,27 @@ class File { // Read an entire file to a string. Return true if successful, false // otherwise. - static bool ReadFileToString(const std::string& name, std::string* output, - bool text_mode = false); + static absl::Status ReadFileToString(const std::string& name, + std::string* output, + bool text_mode = false); // Same as above, but crash on failure. static void ReadFileToStringOrDie(const std::string& name, std::string* output); // Create a file and write a string to it. - static bool WriteStringToFile(absl::string_view contents, - const std::string& name); + static absl::Status WriteStringToFile(absl::string_view contents, + const std::string& name); // Same as above, but crash on failure. static void WriteStringToFileOrDie(absl::string_view contents, const std::string& name); // Create a directory. - static bool CreateDir(const std::string& name, int mode); + static absl::Status CreateDir(const std::string& name, int mode); // Create a directory and all parent directories if necessary. - static bool RecursivelyCreateDir(const std::string& path, int mode); + static absl::Status RecursivelyCreateDir(const std::string& path, int mode); // If "name" is a file, we delete it. If it is a directory, we // call DeleteRecursively() for each file or directory (other than @@ -86,18 +88,20 @@ class File { // Change working directory to given directory. static bool ChangeWorkingDirectory(const std::string& new_working_directory); - static bool GetContents(const std::string& name, std::string* output, - bool /*is_default*/) { + static absl::Status GetContents(const std::string& name, std::string* output, + bool /*is_default*/) { return ReadFileToString(name, output); } - static bool GetContentsAsText(const std::string& name, std::string* output, - bool /*is_default*/) { + static absl::Status GetContentsAsText(const std::string& name, + std::string* output, + bool /*is_default*/) { return ReadFileToString(name, output, true); } - static bool SetContents(const std::string& name, absl::string_view contents, - bool /*is_default*/) { + static absl::Status SetContents(const std::string& name, + absl::string_view contents, + bool /*is_default*/) { return WriteStringToFile(contents, name); } }; diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index ab415618c8ea..85775997122a 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -38,6 +38,8 @@ #include #include +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_replace.h" @@ -97,9 +99,9 @@ std::string TestSourceDir() { while (!File::Exists( absl::StrCat(prefix, "/src/google/protobuf/descriptor.cc"))) { if (!File::Exists(prefix)) { - GOOGLE_LOG(FATAL) - << "Could not find protobuf source code. Please run tests from " - "somewhere within the protobuf source package."; + ABSL_LOG(FATAL) + << "Could not find protobuf source code. Please run tests from " + "somewhere within the protobuf source package."; } absl::StrAppend(&prefix, "/.."); } @@ -175,7 +177,7 @@ class TempDirDeleter { std::string GetTempDir() { if (name_.empty()) { name_ = GetTemporaryDirectoryName(); - GOOGLE_CHECK(mkdir(name_.c_str(), 0777) == 0) << strerror(errno); + ABSL_CHECK(mkdir(name_.c_str(), 0777) == 0) << strerror(errno); // Stick a file in the directory that tells people what this is, in case // we abort and don't get a chance to delete it. @@ -203,13 +205,13 @@ static int original_stdout_ = -1; static int original_stderr_ = -1; void CaptureTestStdout() { - GOOGLE_CHECK_EQ(original_stdout_, -1) << "Already capturing."; + ABSL_CHECK_EQ(original_stdout_, -1) << "Already capturing."; stdout_capture_filename_ = absl::StrCat(TestTempDir(), "/captured_stdout"); int fd = open(stdout_capture_filename_.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777); - GOOGLE_CHECK(fd >= 0) << "open: " << strerror(errno); + ABSL_CHECK(fd >= 0) << "open: " << strerror(errno); original_stdout_ = dup(1); close(1); @@ -218,13 +220,13 @@ void CaptureTestStdout() { } void CaptureTestStderr() { - GOOGLE_CHECK_EQ(original_stderr_, -1) << "Already capturing."; + ABSL_CHECK_EQ(original_stderr_, -1) << "Already capturing."; stderr_capture_filename_ = absl::StrCat(TestTempDir(), "/captured_stderr"); int fd = open(stderr_capture_filename_.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777); - GOOGLE_CHECK(fd >= 0) << "open: " << strerror(errno); + ABSL_CHECK(fd >= 0) << "open: " << strerror(errno); original_stderr_ = dup(2); close(2); @@ -233,7 +235,7 @@ void CaptureTestStderr() { } std::string GetCapturedTestStdout() { - GOOGLE_CHECK_NE(original_stdout_, -1) << "Not capturing."; + ABSL_CHECK_NE(original_stdout_, -1) << "Not capturing."; close(1); dup2(original_stdout_, 1); @@ -248,7 +250,7 @@ std::string GetCapturedTestStdout() { } std::string GetCapturedTestStderr() { - GOOGLE_CHECK_NE(original_stderr_, -1) << "Not capturing."; + ABSL_CHECK_NE(original_stderr_, -1) << "Not capturing."; close(2); dup2(original_stderr_, 2); @@ -262,33 +264,6 @@ std::string GetCapturedTestStderr() { return result; } -ScopedMemoryLog* ScopedMemoryLog::active_log_ = NULL; - -ScopedMemoryLog::ScopedMemoryLog() { - GOOGLE_CHECK(active_log_ == NULL); - active_log_ = this; - old_handler_ = SetLogHandler(&HandleLog); -} - -ScopedMemoryLog::~ScopedMemoryLog() { - SetLogHandler(old_handler_); - active_log_ = NULL; -} - -const std::vector& ScopedMemoryLog::GetMessages(LogLevel level) { - GOOGLE_CHECK(level == ERROR || - level == WARNING); - return messages_[level]; -} - -void ScopedMemoryLog::HandleLog(LogLevel level, const char* filename, int line, - const std::string& message) { - GOOGLE_CHECK(active_log_ != NULL); - if (level == ERROR || level == WARNING) { - active_log_->messages_[level].push_back(message); - } -} - namespace { // Force shutdown at process exit so that we can test for memory leaks. To diff --git a/src/google/protobuf/testing/googletest.h b/src/google/protobuf/testing/googletest.h index 487124b0928f..0f69c0f456d0 100644 --- a/src/google/protobuf/testing/googletest.h +++ b/src/google/protobuf/testing/googletest.h @@ -36,18 +36,9 @@ #include +#include #include -#include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/logging.h" - -// Disable death tests if we use exceptions in CHECK(). -#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) && \ - !GTEST_OS_WINDOWS -#define PROTOBUF_HAS_DEATH_TEST -#endif - namespace google { namespace protobuf { @@ -66,41 +57,6 @@ void CaptureTestStderr(); std::string GetCapturedTestStdout(); std::string GetCapturedTestStderr(); -// For use with ScopedMemoryLog::GetMessages(). Inside Google the LogLevel -// constants don't have the LOGLEVEL_ prefix, so the code that used -// ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR. -#undef ERROR // defend against promiscuous windows.h -static const LogLevel ERROR = LOGLEVEL_ERROR; -static const LogLevel WARNING = LOGLEVEL_WARNING; - -// Receives copies of all LOG(ERROR) messages while in scope. Sample usage: -// { -// ScopedMemoryLog log; // constructor registers object as a log sink -// SomeRoutineThatMayLogMessages(); -// const vector& warnings = log.GetMessages(ERROR); -// } // destructor unregisters object as a log sink -// This is a dummy implementation which covers only what is used by protocol -// buffer unit tests. -class ScopedMemoryLog { - public: - ScopedMemoryLog(); - ScopedMemoryLog(const ScopedMemoryLog&) = delete; - ScopedMemoryLog& operator=(const ScopedMemoryLog&) = delete; - virtual ~ScopedMemoryLog(); - - // Fetches all messages with the given severity level. - const std::vector& GetMessages(LogLevel error); - - private: - absl::flat_hash_map > messages_; - LogHandler* old_handler_; - - static void HandleLog(LogLevel level, const char* filename, int line, - const std::string& message); - - static ScopedMemoryLog* active_log_; -}; - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 9eeb3a67002e..39d67bd95692 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -205,10 +205,10 @@ void CheckFieldIndex(const FieldDescriptor* field, int index) { } if (field->is_repeated() && index == -1) { - GOOGLE_ABSL_LOG(DFATAL) << "Index must be in range of repeated field values. " + ABSL_DLOG(FATAL) << "Index must be in range of repeated field values. " << "Field: " << field->name(); } else if (!field->is_repeated() && index != -1) { - GOOGLE_ABSL_LOG(DFATAL) << "Index must be -1 for singular fields." + ABSL_DLOG(FATAL) << "Index must be -1 for singular fields." << "Field: " << field->name(); } } @@ -345,7 +345,7 @@ class TextFormat::Parser::ParserImpl { // Parses the ASCII representation specified in input and saves the // information into the output pointer (a Message). Returns // false if an error occurs (an error will also be logged to - // GOOGLE_ABSL_LOG(ERROR)). + // ABSL_LOG(ERROR)). bool Parse(Message* output) { // Consume fields until we cannot do so anymore. while (true) { @@ -353,7 +353,7 @@ class TextFormat::Parser::ParserImpl { // Ensures recursion limit properly unwinded, but only for success // cases. This implicitly avoids the check when `Parse` returns false // via `DO(...)`. - GOOGLE_ABSL_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_) + ABSL_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_) << "Recursion limit at end of parse should be " << initial_recursion_limit_ << ", but was " << recursion_limit_ << ". Difference of " << initial_recursion_limit_ - recursion_limit_ @@ -380,11 +380,11 @@ class TextFormat::Parser::ParserImpl { had_errors_ = true; if (error_collector_ == nullptr) { if (line >= 0) { - GOOGLE_ABSL_LOG(ERROR) << "Error parsing text-format " + ABSL_LOG(ERROR) << "Error parsing text-format " << root_message_type_->full_name() << ": " << (line + 1) << ":" << (col + 1) << ": " << message; } else { - GOOGLE_ABSL_LOG(ERROR) << "Error parsing text-format " + ABSL_LOG(ERROR) << "Error parsing text-format " << root_message_type_->full_name() << ": " << message; } } else { @@ -395,11 +395,11 @@ class TextFormat::Parser::ParserImpl { void ReportWarning(int line, int col, const std::string& message) { if (error_collector_ == nullptr) { if (line >= 0) { - GOOGLE_ABSL_LOG(WARNING) << "Warning parsing text-format " + ABSL_LOG(WARNING) << "Warning parsing text-format " << root_message_type_->full_name() << ": " << (line + 1) << ":" << (col + 1) << ": " << message; } else { - GOOGLE_ABSL_LOG(WARNING) << "Warning parsing text-format " + ABSL_LOG(WARNING) << "Warning parsing text-format " << root_message_type_->full_name() << ": " << message; } } else { @@ -594,7 +594,7 @@ class TextFormat::Parser::ParserImpl { // Skips unknown or reserved fields. if (field == nullptr) { - GOOGLE_ABSL_CHECK(allow_unknown_field_ || allow_unknown_extension_ || + ABSL_CHECK(allow_unknown_field_ || allow_unknown_extension_ || reserved_field); // Try to guess the type of this field. @@ -927,7 +927,7 @@ class TextFormat::Parser::ParserImpl { case FieldDescriptor::CPPTYPE_MESSAGE: { // We should never get here. Put here instead of a default // so that if new types are added, we get a nice compiler warning. - GOOGLE_ABSL_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; + ABSL_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; break; } } @@ -1437,7 +1437,7 @@ class TextFormat::Printer::TextGenerator // level is zero. void Outdent() override { if (indent_level_ == 0 || indent_level_ < initial_indent_level_) { - GOOGLE_ABSL_LOG(DFATAL) << " Outdent() without matching Indent()."; + ABSL_DLOG(FATAL) << " Outdent() without matching Indent()."; return; } @@ -1531,7 +1531,7 @@ class TextFormat::Printer::TextGenerator if (indent_level_ == 0) { return; } - GOOGLE_ABSL_DCHECK(!failed_); + ABSL_DCHECK(!failed_); int size = GetCurrentIndentationSize(); while (size > buffer_size_) { @@ -2106,7 +2106,7 @@ bool TextFormat::Printer::RegisterMessagePrinter( bool TextFormat::Printer::PrintToString(const Message& message, std::string* output) const { - GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr"; + ABSL_DCHECK(output) << "output specified is nullptr"; output->clear(); io::StringOutputStream output_stream(output); @@ -2116,7 +2116,7 @@ bool TextFormat::Printer::PrintToString(const Message& message, bool TextFormat::Printer::PrintUnknownFieldsToString( const UnknownFieldSet& unknown_fields, std::string* output) const { - GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr"; + ABSL_DCHECK(output) << "output specified is nullptr"; output->clear(); io::StringOutputStream output_stream(output); @@ -2193,7 +2193,7 @@ bool TextFormat::Printer::PrintAny(const Message& message, finder_ ? finder_->FindAnyType(message, url_prefix, full_type_name) : DefaultFinderFindAnyType(message, url_prefix, full_type_name); if (value_descriptor == nullptr) { - GOOGLE_ABSL_LOG(WARNING) << "Can't print proto content: proto type " << type_url + ABSL_LOG(WARNING) << "Can't print proto content: proto type " << type_url << " not found"; return false; } @@ -2202,7 +2202,7 @@ bool TextFormat::Printer::PrintAny(const Message& message, factory.GetPrototype(value_descriptor)->New()); std::string serialized_value = reflection->GetString(message, value_field); if (!value_message->ParseFromString(serialized_value)) { - GOOGLE_ABSL_LOG(WARNING) << type_url << ": failed to parse contents"; + ABSL_LOG(WARNING) << type_url << ": failed to parse contents"; return false; } generator->PrintLiteral("["); @@ -2276,7 +2276,7 @@ void TextFormat::Printer::PrintFieldValueToString(const Message& message, const FieldDescriptor* field, int index, std::string* output) const { - GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr"; + ABSL_DCHECK(output) << "output specified is nullptr"; output->clear(); io::StringOutputStream output_stream(output); @@ -2324,7 +2324,7 @@ class MapEntryMessageComparator { return first < second; } default: - GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field."; + ABSL_DLOG(FATAL) << "Invalid key for map field."; return true; } } @@ -2395,7 +2395,7 @@ void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message, case FieldDescriptor::CPPTYPE_FLOAT: case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(ERROR) << "Not supported."; + ABSL_LOG(ERROR) << "Not supported."; break; case FieldDescriptor::CPPTYPE_STRING: reflection->SetString(message, field_desc, key.GetStringValue()); @@ -2570,7 +2570,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, const FieldDescriptor* field, int index, BaseTextGenerator* generator) const { - GOOGLE_ABSL_DCHECK(field->is_repeated() || (index == -1)) + ABSL_DCHECK(field->is_repeated() || (index == -1)) << "Index must be -1 for non-repeated fields"; const FastFieldValuePrinter* printer = GetFieldPrinter(field); @@ -2618,7 +2618,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, if (field->type() == FieldDescriptor::TYPE_STRING) { printer->PrintString(*value_to_print, generator); } else { - GOOGLE_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES); + ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES); printer->PrintBytes(*value_to_print, generator); } break; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 4070728436a0..df257e7bb8f4 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -48,7 +48,9 @@ #include #include "google/protobuf/testing/googletest.h" #include -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/die_if_null.h" +#include "absl/log/scoped_mock_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -91,7 +93,7 @@ constexpr absl::string_view kEscapeTestStringEscaped = class TextFormatTest : public testing::Test { public: static void SetUpTestSuite() { - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( TestUtil::GetTestDataPath( "third_party/protobuf/" "testdata/text_format_unittest_data_oneof_implemented.txt"), @@ -113,7 +115,7 @@ std::string TextFormatTest::static_proto_text_format_; class TextFormatExtensionsTest : public testing::Test { public: static void SetUpTestSuite() { - GOOGLE_ABSL_CHECK_OK(File::GetContents( + ABSL_CHECK_OK(File::GetContents( TestUtil::GetTestDataPath("third_party/protobuf/testdata/" "text_format_unittest_extensions_data.txt"), &static_proto_text_format_, true)); @@ -1881,38 +1883,33 @@ TEST_F(TextFormatParserTest, ExplicitDelimiters) { } TEST_F(TextFormatParserTest, PrintErrorsToStderr) { - std::vector errors; - { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL( + log, + Log(absl::LogSeverity::kError, testing::_, + "Error parsing text-format protobuf_unittest.TestAllTypes: " + "1:14: Message type \"protobuf_unittest.TestAllTypes\" has no field " + "named \"no_such_field\".")) + .Times(1); + log.StartCapturingLogs(); unittest::TestAllTypes proto; EXPECT_FALSE(TextFormat::ParseFromString("no_such_field: 1", &proto)); - errors = log.GetMessages(ERROR); } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ( - "Error parsing text-format protobuf_unittest.TestAllTypes: " - "1:14: Message type \"protobuf_unittest.TestAllTypes\" has no field " - "named \"no_such_field\".", - errors[0]); } TEST_F(TextFormatParserTest, FailsOnTokenizationError) { - std::vector errors; - { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, + Log(absl::LogSeverity::kError, testing::_, + "Error parsing text-format protobuf_unittest.TestAllTypes: " + "1:1: Invalid control characters encountered in text.")) + .Times(1); + log.StartCapturingLogs(); unittest::TestAllTypes proto; EXPECT_FALSE(TextFormat::ParseFromString("\020", &proto)); - errors = log.GetMessages(ERROR); } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ( - "Error parsing text-format protobuf_unittest.TestAllTypes: " - "1:1: Invalid control characters encountered in text.", - errors[0]); } TEST_F(TextFormatParserTest, ParseDeprecatedField) { diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index 5f775664be8c..2fbf60d77703 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -34,7 +34,7 @@ #include "google/protobuf/unknown_field_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/cord.h" #include "absl/strings/internal/resize_uninitialized.h" #include "google/protobuf/extension_set.h" @@ -61,7 +61,7 @@ const UnknownFieldSet& UnknownFieldSet::default_instance() { } void UnknownFieldSet::ClearFallback() { - GOOGLE_ABSL_DCHECK(!fields_.empty()); + ABSL_DCHECK(!fields_.empty()); int n = fields_.size(); do { (fields_)[--n].Delete(); @@ -302,7 +302,7 @@ void UnknownField::DeepCopy(const UnknownField& other) { uint8_t* UnknownField::InternalSerializeLengthDelimitedNoTag( uint8_t* target, io::EpsCopyOutputStream* stream) const { - GOOGLE_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); + ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); const std::string& data = *data_.length_delimited_.string_value; target = io::CodedOutputStream::WriteVarint32ToArray(data.size(), target); target = stream->WriteRaw(data.data(), data.size(), target); diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index f8764ec06414..d49e79dd82f0 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -45,7 +45,7 @@ #include "google/protobuf/stubs/common.h" #include "google/protobuf/port.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h" #include "google/protobuf/message_lite.h" @@ -393,7 +393,7 @@ bool UnknownFieldSet::MergeFromMessage(const MessageType& message) { inline size_t UnknownField::GetLengthDelimitedSize() const { - GOOGLE_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); + ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); return data_.length_delimited_.string_value->size(); } diff --git a/src/google/protobuf/util/BUILD.bazel b/src/google/protobuf/util/BUILD.bazel index 1a4dcbad75eb..609a86a27bc3 100644 --- a/src/google/protobuf/util/BUILD.bazel +++ b/src/google/protobuf/util/BUILD.bazel @@ -52,6 +52,8 @@ cc_library( "//src/google/protobuf/stubs", "@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", ], ) @@ -100,6 +102,7 @@ cc_library( "//src/google/protobuf", "//src/google/protobuf/stubs", "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/log:die_if_null", "@com_google_absl//absl/memory", ], ) @@ -138,6 +141,7 @@ cc_library( deps = [ "//src/google/protobuf", "//src/google/protobuf/stubs", + "@com_google_absl//absl/log:absl_check", ], ) @@ -167,6 +171,7 @@ cc_library( "//src/google/protobuf", "//src/google/protobuf/io", "//src/google/protobuf/stubs", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", ], ) diff --git a/src/google/protobuf/util/field_comparator.cc b/src/google/protobuf/util/field_comparator.cc index 724c2997caad..441770a30991 100644 --- a/src/google/protobuf/util/field_comparator.cc +++ b/src/google/protobuf/util/field_comparator.cc @@ -40,8 +40,8 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/message.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "google/protobuf/util/message_differencer.h" namespace google { @@ -62,7 +62,7 @@ struct Epsilon { template bool WithinFractionOrMargin(const T x, const T y, const T fraction, const T margin) { - GOOGLE_ABSL_DCHECK(fraction >= T(0) && fraction < T(1) && margin >= T(0)); + ABSL_DCHECK(fraction >= T(0) && fraction < T(1) && margin >= T(0)); if (!std::isfinite(x) || !std::isfinite(y)) { return false; @@ -149,7 +149,7 @@ FieldComparator::ComparisonResult SimpleFieldComparator::SimpleCompare( return RECURSE; default: - GOOGLE_ABSL_LOG(FATAL) << "No comparison code for field " << field->full_name() + ABSL_LOG(FATAL) << "No comparison code for field " << field->full_name() << " of CppType = " << field->cpp_type(); return DIFFERENT; } @@ -171,7 +171,7 @@ void SimpleFieldComparator::SetDefaultFractionAndMargin(double fraction, void SimpleFieldComparator::SetFractionAndMargin(const FieldDescriptor* field, double fraction, double margin) { - GOOGLE_ABSL_CHECK(FieldDescriptor::CPPTYPE_FLOAT == field->cpp_type() || + ABSL_CHECK(FieldDescriptor::CPPTYPE_FLOAT == field->cpp_type() || FieldDescriptor::CPPTYPE_DOUBLE == field->cpp_type()) << "Field has to be float or double type. Field name is: " << field->full_name(); diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index 638a2790a443..eee14b1e9f65 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -36,8 +36,9 @@ #include #include "absl/container/btree_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" +#include "absl/log/die_if_null.h" #include "absl/memory/memory.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" @@ -449,7 +450,7 @@ void FieldMaskTree::MergeLeafNodesToTree(absl::string_view prefix, void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const FieldMaskUtil::MergeOptions& options, Message* destination) { - GOOGLE_ABSL_DCHECK(!node->children.empty()); + ABSL_DCHECK(!node->children.empty()); const Reflection* source_reflection = source.GetReflection(); const Reflection* destination_reflection = destination->GetReflection(); const Descriptor* descriptor = source.GetDescriptor(); @@ -458,7 +459,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const Node* child = kv.second.get(); const FieldDescriptor* field = descriptor->FindFieldByName(field_name); if (field == nullptr) { - GOOGLE_ABSL_LOG(ERROR) << "Cannot find field \"" << field_name + ABSL_LOG(ERROR) << "Cannot find field \"" << field_name << "\" in message " << descriptor->full_name(); continue; } @@ -466,7 +467,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, // Sub-paths are only allowed for singular message fields. if (field->is_repeated() || field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - GOOGLE_ABSL_LOG(ERROR) << "Field \"" << field_name << "\" in message " + ABSL_LOG(ERROR) << "Field \"" << field_name << "\" in message " << descriptor->full_name() << " is not a singular message field and cannot " << "have sub-fields."; @@ -583,7 +584,7 @@ void FieldMaskTree::AddRequiredFieldPath(Node* node, } bool FieldMaskTree::TrimMessage(const Node* node, Message* message) { - GOOGLE_ABSL_DCHECK(!node->children.empty()); + ABSL_DCHECK(!node->children.empty()); const Reflection* reflection = message->GetReflection(); const Descriptor* descriptor = message->GetDescriptor(); const int32_t field_count = descriptor->field_count(); @@ -682,7 +683,7 @@ bool FieldMaskUtil::IsPathInFieldMask(absl::string_view path, void FieldMaskUtil::MergeMessageTo(const Message& source, const FieldMask& mask, const MergeOptions& options, Message* destination) { - GOOGLE_ABSL_CHECK(source.GetDescriptor() == destination->GetDescriptor()); + ABSL_CHECK(source.GetDescriptor() == destination->GetDescriptor()); // Build a FieldMaskTree and walk through the tree to merge all specified // fields. FieldMaskTree tree; @@ -695,7 +696,7 @@ bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message) { // fields. FieldMaskTree tree; tree.MergeFromFieldMask(mask); - return tree.TrimMessage(GOOGLE_CHECK_NOTNULL(message)); + return tree.TrimMessage(ABSL_DIE_IF_NULL(message)); } bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message, @@ -707,9 +708,9 @@ bool FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* message, // If keep_required_fields is true, implicitly add required fields of // a message present in the tree to prevent from trimming. if (options.keep_required_fields()) { - tree.AddRequiredFieldPath(GOOGLE_CHECK_NOTNULL(message->GetDescriptor())); + tree.AddRequiredFieldPath(ABSL_DIE_IF_NULL(message->GetDescriptor())); } - return tree.TrimMessage(GOOGLE_CHECK_NOTNULL(message)); + return tree.TrimMessage(ABSL_DIE_IF_NULL(message)); } } // namespace util diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h index 6148f081f8e4..5b662e5bb086 100644 --- a/src/google/protobuf/util/field_mask_util.h +++ b/src/google/protobuf/util/field_mask_util.h @@ -38,7 +38,7 @@ #include #include "google/protobuf/field_mask.pb.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "google/protobuf/descriptor.h" @@ -66,7 +66,7 @@ class PROTOBUF_EXPORT FieldMaskUtil { for (const auto field_number : field_numbers) { const FieldDescriptor* field_desc = T::descriptor()->FindFieldByNumber(field_number); - GOOGLE_ABSL_CHECK(field_desc != nullptr) + ABSL_CHECK(field_desc != nullptr) << "Invalid field number for " << T::descriptor()->full_name() << ": " << field_number; AddPathToFieldMask(field_desc->lowercase_name(), out); @@ -109,7 +109,7 @@ class PROTOBUF_EXPORT FieldMaskUtil { // This method check-fails if the path is not a valid path for type T. template static void AddPathToFieldMask(absl::string_view path, FieldMask* mask) { - GOOGLE_ABSL_CHECK(IsValidPath(path)) << path; + ABSL_CHECK(IsValidPath(path)) << path; mask->add_paths(std::string(path)); } diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 2bc47626be76..c57f18286036 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -51,8 +51,8 @@ #include "google/protobuf/text_format.h" #include "absl/container/fixed_array.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -144,9 +144,9 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator const std::vector >& key_field_paths) : message_differencer_(message_differencer), key_field_paths_(key_field_paths) { - GOOGLE_ABSL_CHECK(!key_field_paths_.empty()); + ABSL_CHECK(!key_field_paths_.empty()); for (const auto& path : key_field_paths_) { - GOOGLE_ABSL_CHECK(!path.empty()); + ABSL_CHECK(!path.empty()); } } MultipleFieldsMapKeyComparator(MessageDifferencer* message_differencer, @@ -342,14 +342,14 @@ MessageDifferencer::~MessageDifferencer() { } void MessageDifferencer::set_field_comparator(FieldComparator* comparator) { - GOOGLE_ABSL_CHECK(comparator) << "Field comparator can't be NULL."; + ABSL_CHECK(comparator) << "Field comparator can't be NULL."; field_comparator_kind_ = kFCBase; field_comparator_.base = comparator; } void MessageDifferencer::set_field_comparator( DefaultFieldComparator* comparator) { - GOOGLE_ABSL_CHECK(comparator) << "Field comparator can't be NULL."; + ABSL_CHECK(comparator) << "Field comparator can't be NULL."; field_comparator_kind_ = kFCDefault; field_comparator_.default_impl = comparator; } @@ -387,10 +387,10 @@ MessageDifferencer::repeated_field_comparison() const { void MessageDifferencer::CheckRepeatedFieldComparisons( const FieldDescriptor* field, const RepeatedFieldComparison& new_comparison) { - GOOGLE_ABSL_CHECK(field->is_repeated()) + ABSL_CHECK(field->is_repeated()) << "Field must be repeated: " << field->full_name(); const MapKeyComparator* key_comparator = GetMapKeyComparator(field); - GOOGLE_ABSL_CHECK(key_comparator == NULL) + ABSL_CHECK(key_comparator == NULL) << "Cannot treat this repeated field as both MAP and " << new_comparison << " for comparison. Field name is: " << field->full_name(); } @@ -422,13 +422,13 @@ void MessageDifferencer::TreatAsSmartList(const FieldDescriptor* field) { void MessageDifferencer::TreatAsMap(const FieldDescriptor* field, const FieldDescriptor* key) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) + ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) << "Field has to be message type. Field name is: " << field->full_name(); - GOOGLE_ABSL_CHECK(key->containing_type() == field->message_type()) + ABSL_CHECK(key->containing_type() == field->message_type()) << key->full_name() << " must be a direct subfield within the repeated field " << field->full_name() << ", not " << key->containing_type()->full_name(); - GOOGLE_ABSL_CHECK(repeated_field_comparisons_.find(field) == + ABSL_CHECK(repeated_field_comparisons_.find(field) == repeated_field_comparisons_.end()) << "Cannot treat the same field as both " << repeated_field_comparisons_[field] @@ -454,29 +454,29 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey( void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey( const FieldDescriptor* field, const std::vector >& key_field_paths) { - GOOGLE_ABSL_CHECK(field->is_repeated()) + ABSL_CHECK(field->is_repeated()) << "Field must be repeated: " << field->full_name(); - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) + ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type()) << "Field has to be message type. Field name is: " << field->full_name(); for (const auto& key_field_path : key_field_paths) { for (size_t j = 0; j < key_field_path.size(); ++j) { const FieldDescriptor* parent_field = j == 0 ? field : key_field_path[j - 1]; const FieldDescriptor* child_field = key_field_path[j]; - GOOGLE_ABSL_CHECK(child_field->containing_type() == parent_field->message_type()) + ABSL_CHECK(child_field->containing_type() == parent_field->message_type()) << child_field->full_name() << " must be a direct subfield within the field: " << parent_field->full_name(); if (j != 0) { - GOOGLE_ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, + ABSL_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, parent_field->cpp_type()) << parent_field->full_name() << " has to be of type message."; - GOOGLE_ABSL_CHECK(!parent_field->is_repeated()) + ABSL_CHECK(!parent_field->is_repeated()) << parent_field->full_name() << " cannot be a repeated field."; } } } - GOOGLE_ABSL_CHECK(repeated_field_comparisons_.find(field) == + ABSL_CHECK(repeated_field_comparisons_.find(field) == repeated_field_comparisons_.end()) << "Cannot treat the same field as both " << repeated_field_comparisons_[field] @@ -489,9 +489,9 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey( void MessageDifferencer::TreatAsMapUsingKeyComparator( const FieldDescriptor* field, const MapKeyComparator* key_comparator) { - GOOGLE_ABSL_CHECK(field->is_repeated()) + ABSL_CHECK(field->is_repeated()) << "Field must be repeated: " << field->full_name(); - GOOGLE_ABSL_CHECK(repeated_field_comparisons_.find(field) == + ABSL_CHECK(repeated_field_comparisons_.find(field) == repeated_field_comparisons_.end()) << "Cannot treat the same field as both " << repeated_field_comparisons_[field] @@ -514,7 +514,7 @@ void MessageDifferencer::SetFractionAndMargin(const FieldDescriptor* field, } void MessageDifferencer::ReportDifferencesToString(std::string* output) { - GOOGLE_ABSL_DCHECK(output) << "Specified output string was NULL"; + ABSL_DCHECK(output) << "Specified output string was NULL"; output_string_ = output; output_string_->clear(); @@ -570,7 +570,7 @@ bool MessageDifferencer::CompareWithFields( const std::vector& message1_fields_arg, const std::vector& message2_fields_arg) { if (message1.GetDescriptor() != message2.GetDescriptor()) { - GOOGLE_ABSL_LOG(DFATAL) << "Comparison between two messages with different " + ABSL_DLOG(FATAL) << "Comparison between two messages with different " << "descriptors."; return false; } @@ -618,7 +618,7 @@ bool MessageDifferencer::Compare(const Message& message1, const Descriptor* descriptor1 = message1.GetDescriptor(); const Descriptor* descriptor2 = message2.GetDescriptor(); if (descriptor1 != descriptor2) { - GOOGLE_ABSL_LOG(DFATAL) << "Comparison between two messages with different " + ABSL_DLOG(FATAL) << "Comparison between two messages with different " << "descriptors. " << descriptor1->full_name() << " vs " << descriptor2->full_name(); return false; @@ -1020,11 +1020,11 @@ bool MessageDifferencer::CompareMapFieldByMapReflection( const Message& message1, const Message& message2, int unpacked_any, const FieldDescriptor* map_field, std::vector* parent_fields, DefaultFieldComparator* comparator) { - GOOGLE_ABSL_DCHECK_EQ(nullptr, reporter_); - GOOGLE_ABSL_DCHECK(map_field->is_map()); - GOOGLE_ABSL_DCHECK(map_field_key_comparator_.find(map_field) == + ABSL_DCHECK_EQ(nullptr, reporter_); + ABSL_DCHECK(map_field->is_map()); + ABSL_DCHECK(map_field_key_comparator_.find(map_field) == map_field_key_comparator_.end()); - GOOGLE_ABSL_DCHECK_EQ(repeated_field_comparison_, AS_LIST); + ABSL_DCHECK_EQ(repeated_field_comparison_, AS_LIST); const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); const int count1 = reflection1->MapSize(message1, map_field); @@ -1115,7 +1115,7 @@ bool MessageDifferencer::CompareMapField( const Message& message1, const Message& message2, int unpacked_any, const FieldDescriptor* repeated_field, std::vector* parent_fields) { - GOOGLE_ABSL_DCHECK(repeated_field->is_map()); + ABSL_DCHECK(repeated_field->is_map()); // the input FieldDescriptor is guaranteed to be repeated field. const Reflection* reflection1 = message1.GetReflection(); @@ -1159,7 +1159,7 @@ bool MessageDifferencer::CompareRepeatedField( const Message& message1, const Message& message2, int unpacked_any, const FieldDescriptor* repeated_field, std::vector* parent_fields) { - GOOGLE_ABSL_DCHECK(!repeated_field->is_map()); + ABSL_DCHECK(!repeated_field->is_map()); return CompareRepeatedRep(message1, message2, unpacked_any, repeated_field, parent_fields); } @@ -1169,7 +1169,7 @@ bool MessageDifferencer::CompareRepeatedRep( const FieldDescriptor* repeated_field, std::vector* parent_fields) { // the input FieldDescriptor is guaranteed to be repeated field. - GOOGLE_ABSL_DCHECK(repeated_field->is_repeated()); + ABSL_DCHECK(repeated_field->is_repeated()); const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); @@ -1241,7 +1241,7 @@ bool MessageDifferencer::CompareRepeatedRep( } if (smart_list) { for (int j = next_unmatched_index; j < match_list1[i]; ++j) { - GOOGLE_ABSL_CHECK_LE(0, j); + ABSL_CHECK_LE(0, j); if (reporter_ == nullptr) return false; specific_field.index = j; AddSpecificNewIndex(&specific_field, message2, repeated_field, j); @@ -1494,7 +1494,7 @@ bool MessageDifferencer::UnpackAnyField::UnpackAny( any.GetDescriptor()->file()->pool()->FindMessageTypeByName( full_type_name); if (desc == NULL) { - GOOGLE_ABSL_LOG(INFO) << "Proto type '" << full_type_name << "' not found"; + ABSL_LOG(INFO) << "Proto type '" << full_type_name << "' not found"; return false; } @@ -1504,7 +1504,7 @@ bool MessageDifferencer::UnpackAnyField::UnpackAny( data->reset(dynamic_message_factory_->GetPrototype(desc)->New()); std::string serialized_value = reflection->GetString(any, value_field); if (!(*data)->ParsePartialFromString(serialized_value)) { - GOOGLE_ABSL_DLOG(ERROR) << "Failed to parse value for " << full_type_name; + ABSL_DLOG(ERROR) << "Failed to parse value for " << full_type_name; return false; } return true; @@ -2122,7 +2122,7 @@ void MessageDifferencer::StreamReporter::PrintValue( void MessageDifferencer::StreamReporter::PrintUnknownFieldValue( const UnknownField* unknown_field) { - GOOGLE_ABSL_CHECK(unknown_field != NULL) << " Cannot print NULL unknown_field."; + ABSL_CHECK(unknown_field != NULL) << " Cannot print NULL unknown_field."; std::string output; switch (unknown_field->type()) { @@ -2158,7 +2158,7 @@ void MessageDifferencer::StreamReporter::Print(const std::string& str) { void MessageDifferencer::StreamReporter::PrintMapKey( bool left_side, const SpecificField& specific_field) { if (message1_ == nullptr || message2_ == nullptr) { - GOOGLE_ABSL_LOG(INFO) << "PrintPath cannot log map keys; " + ABSL_LOG(INFO) << "PrintPath cannot log map keys; " "use SetMessages to provide the messages " "being compared prior to any processing."; return; diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index 314873a1ab9f..d0e5c72bc524 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -55,7 +55,7 @@ #include "absl/container/fixed_array.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/util/field_comparator.h" // Always include as last one, otherwise it can break compilation @@ -342,7 +342,7 @@ class PROTOBUF_EXPORT MessageDifferencer { virtual bool IsMatch(const Message& message1, const Message& message2, int /* unmapped_any */, const std::vector& fields) const { - GOOGLE_ABSL_CHECK(false) << "IsMatch() is not implemented."; + ABSL_CHECK(false) << "IsMatch() is not implemented."; return false; } }; diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index bab9fd6fdcaf..aedbf2864218 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -46,7 +46,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/functional/bind_front.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc index 9ca17d3140de..d59ef608cfde 100644 --- a/src/google/protobuf/util/time_util.cc +++ b/src/google/protobuf/util/time_util.cc @@ -35,7 +35,7 @@ #include "google/protobuf/duration.pb.h" #include "google/protobuf/timestamp.pb.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "absl/numeric/int128.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -68,7 +68,7 @@ T CreateNormalized(int64_t seconds, int32_t nanos); template <> Timestamp CreateNormalized(int64_t seconds, int32_t nanos) { - GOOGLE_ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds && + ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds && seconds <= TimeUtil::kTimestampMaxSeconds) << "Timestamp seconds are outside of the valid range"; @@ -83,7 +83,7 @@ Timestamp CreateNormalized(int64_t seconds, int32_t nanos) { nanos += kNanosPerSecond; } - GOOGLE_ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds && + ABSL_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds && seconds <= TimeUtil::kTimestampMaxSeconds && nanos >= TimeUtil::kTimestampMinNanoseconds && nanos <= TimeUtil::kTimestampMaxNanoseconds) @@ -96,7 +96,7 @@ Timestamp CreateNormalized(int64_t seconds, int32_t nanos) { template <> Duration CreateNormalized(int64_t seconds, int32_t nanos) { - GOOGLE_ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds && + ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds && seconds <= TimeUtil::kDurationMaxSeconds) << "Duration seconds are outside of the valid range"; @@ -114,7 +114,7 @@ Duration CreateNormalized(int64_t seconds, int32_t nanos) { nanos += kNanosPerSecond; } - GOOGLE_ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds && + ABSL_DCHECK(seconds >= TimeUtil::kDurationMinSeconds && seconds <= TimeUtil::kDurationMaxSeconds && nanos >= TimeUtil::kDurationMinNanoseconds && nanos <= TimeUtil::kDurationMaxNanoseconds) @@ -314,21 +314,21 @@ Duration TimeUtil::SecondsToDuration(int64_t seconds) { } Duration TimeUtil::MinutesToDuration(int64_t minutes) { - GOOGLE_ABSL_DCHECK(minutes >= TimeUtil::kDurationMinSeconds / kSecondsPerMinute && + ABSL_DCHECK(minutes >= TimeUtil::kDurationMinSeconds / kSecondsPerMinute && minutes <= TimeUtil::kDurationMaxSeconds / kSecondsPerMinute) << "Duration minutes are outside of the valid range"; return SecondsToDuration(minutes * kSecondsPerMinute); } Duration TimeUtil::HoursToDuration(int64_t hours) { - GOOGLE_ABSL_DCHECK(hours >= TimeUtil::kDurationMinSeconds / kSecondsPerHour && + ABSL_DCHECK(hours >= TimeUtil::kDurationMinSeconds / kSecondsPerHour && hours <= TimeUtil::kDurationMaxSeconds / kSecondsPerHour) << "Duration hours are outside of the valid range"; return SecondsToDuration(hours * kSecondsPerHour); } int64_t TimeUtil::DurationToNanoseconds(const Duration& duration) { - GOOGLE_ABSL_DCHECK(IsDurationValid(duration)) + ABSL_DCHECK(IsDurationValid(duration)) << "Duration is outside of the valid range"; return duration.seconds() * kNanosPerSecond + duration.nanos(); } @@ -342,7 +342,7 @@ int64_t TimeUtil::DurationToMilliseconds(const Duration& duration) { } int64_t TimeUtil::DurationToSeconds(const Duration& duration) { - GOOGLE_ABSL_DCHECK(IsDurationValid(duration)) + ABSL_DCHECK(IsDurationValid(duration)) << "Duration is outside of the valid range"; return duration.seconds(); } @@ -377,27 +377,27 @@ Timestamp TimeUtil::SecondsToTimestamp(int64_t seconds) { } int64_t TimeUtil::TimestampToNanoseconds(const Timestamp& timestamp) { - GOOGLE_ABSL_DCHECK(IsTimestampValid(timestamp)) + ABSL_DCHECK(IsTimestampValid(timestamp)) << "Timestamp is outside of the valid range"; return timestamp.seconds() * kNanosPerSecond + timestamp.nanos(); } int64_t TimeUtil::TimestampToMicroseconds(const Timestamp& timestamp) { - GOOGLE_ABSL_DCHECK(IsTimestampValid(timestamp)) + ABSL_DCHECK(IsTimestampValid(timestamp)) << "Timestamp is outside of the valid range"; return timestamp.seconds() * kMicrosPerSecond + RoundTowardZero(timestamp.nanos(), kNanosPerMicrosecond); } int64_t TimeUtil::TimestampToMilliseconds(const Timestamp& timestamp) { - GOOGLE_ABSL_DCHECK(IsTimestampValid(timestamp)) + ABSL_DCHECK(IsTimestampValid(timestamp)) << "Timestamp is outside of the valid range"; return timestamp.seconds() * kMillisPerSecond + RoundTowardZero(timestamp.nanos(), kNanosPerMillisecond); } int64_t TimeUtil::TimestampToSeconds(const Timestamp& timestamp) { - GOOGLE_ABSL_DCHECK(IsTimestampValid(timestamp)) + ABSL_DCHECK(IsTimestampValid(timestamp)) << "Timestamp is outside of the valid range"; return timestamp.seconds(); } diff --git a/src/google/protobuf/util/time_util_test.cc b/src/google/protobuf/util/time_util_test.cc index c6554374c014..8d1a3d9719cf 100644 --- a/src/google/protobuf/util/time_util_test.cc +++ b/src/google/protobuf/util/time_util_test.cc @@ -428,7 +428,7 @@ TEST(TimeUtilTest, IsTimestampValid) { EXPECT_FALSE(TimeUtil::IsTimestampValid(underflow_nanos)); } -#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. +#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet. #ifndef NDEBUG TEST(TimeUtilTest, DurationBounds) { @@ -523,7 +523,7 @@ TEST(TimeUtilTest, TimestampBounds) { "outside of the valid range"); } #endif // !NDEBUG -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST } // namespace } // namespace util diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index 6dc0173c13dd..1537708986d7 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc @@ -34,7 +34,7 @@ #include "google/protobuf/wrappers.pb.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -353,7 +353,7 @@ class DescriptorPoolTypeResolver : public TypeResolver { return descriptor->default_value_enum()->name(); break; case FieldDescriptor::CPPTYPE_MESSAGE: - GOOGLE_ABSL_LOG(DFATAL) << "Messages can't have default values!"; + ABSL_DLOG(FATAL) << "Messages can't have default values!"; break; } return ""; diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index 2a66968d4def..f988a090c4c1 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -38,8 +38,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.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" @@ -402,7 +402,7 @@ bool WireFormat::ParseAndMergeMessageSetField(uint32_t field_number, field->type() != FieldDescriptor::TYPE_MESSAGE) { // This shouldn't happen as we only allow optional message extensions to // MessageSet. - GOOGLE_ABSL_LOG(ERROR) << "Extensions of MessageSets must be optional messages."; + ABSL_LOG(ERROR) << "Extensions of MessageSets must be optional messages."; return false; } else { Message* sub_message = message_reflection->MutableMessage( @@ -790,8 +790,8 @@ const char* WireFormat::_InternalParse(Message* msg, const char* ptr, internal::ParseContext* ctx) { const Descriptor* descriptor = msg->GetDescriptor(); const Reflection* reflection = msg->GetReflection(); - GOOGLE_ABSL_DCHECK(descriptor); - GOOGLE_ABSL_DCHECK(reflection); + ABSL_DCHECK(descriptor); + ABSL_DCHECK(reflection); if (descriptor->options().message_set_wire_format()) { MessageSetParser message_set{msg, descriptor, reflection}; return message_set.ParseMessageSet(ptr, ctx); @@ -890,7 +890,7 @@ const char* WireFormat::_InternalParseAndMergeField( case FieldDescriptor::TYPE_GROUP: case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_BYTES: - GOOGLE_ABSL_LOG(FATAL) << "Can't reach"; + ABSL_LOG(FATAL) << "Can't reach"; return nullptr; } } else { @@ -1081,7 +1081,7 @@ uint8_t* SerializeMapKeyWithCachedSizes(const FieldDescriptor* field, case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_BYTES: case FieldDescriptor::TYPE_ENUM: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; break; #define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \ case FieldDescriptor::TYPE_##FieldType: \ @@ -1170,7 +1170,7 @@ class MapKeySorter { class MapKeyComparator { public: bool operator()(const MapKey& a, const MapKey& b) const { - GOOGLE_ABSL_DCHECK(a.type() == b.type()); + ABSL_DCHECK(a.type() == b.type()); switch (a.type()) { #define CASE_TYPE(CppType, CamelCppType) \ case FieldDescriptor::CPPTYPE_##CppType: { \ @@ -1185,7 +1185,7 @@ class MapKeySorter { #undef CASE_TYPE default: - GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field."; + ABSL_DLOG(FATAL) << "Invalid key for map field."; return true; } } @@ -1327,7 +1327,7 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field, HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool) #undef HANDLE_PRIMITIVE_TYPE default: - GOOGLE_ABSL_LOG(FATAL) << "Invalid descriptor"; + ABSL_LOG(FATAL) << "Invalid descriptor"; } return target; } @@ -1543,7 +1543,7 @@ size_t WireFormat::FieldByteSize(const FieldDescriptor* field, size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field, const MapKey& value) { - GOOGLE_ABSL_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type()); + ABSL_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type()); switch (field->type()) { case FieldDescriptor::TYPE_DOUBLE: case FieldDescriptor::TYPE_FLOAT: @@ -1551,7 +1551,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field, case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_BYTES: case FieldDescriptor::TYPE_ENUM: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; return 0; #define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \ case FieldDescriptor::TYPE_##FieldType: \ @@ -1578,7 +1578,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field, #undef CASE_TYPE #undef FIXED_CASE_TYPE } - GOOGLE_ABSL_LOG(FATAL) << "Cannot get here"; + ABSL_LOG(FATAL) << "Cannot get here"; return 0; } @@ -1586,7 +1586,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field, const MapValueConstRef& value) { switch (field->type()) { case FieldDescriptor::TYPE_GROUP: - GOOGLE_ABSL_LOG(FATAL) << "Unsupported"; + ABSL_LOG(FATAL) << "Unsupported"; return 0; #define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \ case FieldDescriptor::TYPE_##FieldType: \ @@ -1618,7 +1618,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field, #undef CASE_TYPE #undef FIXED_CASE_TYPE } - GOOGLE_ABSL_LOG(FATAL) << "Cannot get here"; + ABSL_LOG(FATAL) << "Cannot get here"; return 0; } diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index ece429fcaf67..dec6774a3252 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT WireFormat { int expected_endpoint = output->ByteCount() + size; output->SetCur( _InternalSerialize(message, output->Cur(), output->EpsCopy())); - GOOGLE_ABSL_CHECK_EQ(output->ByteCount(), expected_endpoint) + ABSL_CHECK_EQ(output->ByteCount(), expected_endpoint) << ": Protocol message serialized to a size different from what was " "originally expected. Perhaps it was modified by another thread " "during serialization?"; diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 14371fa579b1..2a4adb1af505 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -39,8 +39,8 @@ #include #include -#include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/cord.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -491,7 +491,7 @@ void WireFormatLite::WriteString(int field_number, const std::string& value, io::CodedOutputStream* output) { // String is for UTF-8 text only WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize); + ABSL_CHECK_LE(value.size(), kInt32MaxSize); output->WriteVarint32(value.size()); output->WriteString(value); } @@ -500,14 +500,14 @@ void WireFormatLite::WriteStringMaybeAliased(int field_number, io::CodedOutputStream* output) { // String is for UTF-8 text only WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize); + ABSL_CHECK_LE(value.size(), kInt32MaxSize); output->WriteVarint32(value.size()); output->WriteRawMaybeAliased(value.data(), value.size()); } void WireFormatLite::WriteBytes(int field_number, const std::string& value, io::CodedOutputStream* output) { WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize); + ABSL_CHECK_LE(value.size(), kInt32MaxSize); output->WriteVarint32(value.size()); output->WriteString(value); } @@ -515,7 +515,7 @@ void WireFormatLite::WriteBytesMaybeAliased(int field_number, const std::string& value, io::CodedOutputStream* output) { WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize); + ABSL_CHECK_LE(value.size(), kInt32MaxSize); output->WriteVarint32(value.size()); output->WriteRawMaybeAliased(value.data(), value.size()); } @@ -623,7 +623,7 @@ void PrintUTF8ErrorLog(absl::string_view message_name, " a protocol buffer. Use the 'bytes' type if you intend to " "send raw bytes. ", stacktrace); - GOOGLE_ABSL_LOG(ERROR) << error_message; + ABSL_LOG(ERROR) << error_message; } bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index dd6e6c794ee6..0d35d3ab1fe7 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -46,7 +46,7 @@ #include "google/protobuf/stubs/common.h" #include "google/protobuf/port.h" #include "absl/base/casts.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" #include "google/protobuf/arenastring.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/message_lite.h" @@ -1084,7 +1084,7 @@ template inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( int tag_size, uint32_t tag, io::CodedInputStream* input, RepeatedField* values) { - GOOGLE_ABSL_DCHECK_EQ(UInt32Size(tag), static_cast(tag_size)); + ABSL_DCHECK_EQ(UInt32Size(tag), static_cast(tag_size)); CType value; if (!ReadPrimitive(input, &value)) return false; values->Add(value); @@ -1445,7 +1445,7 @@ inline uint8_t* WireFormatLite::WritePrimitiveNoTagToArray( const RepeatedField& value, uint8_t* (*Writer)(T, uint8_t*), uint8_t* target) { const int n = value.size(); - GOOGLE_ABSL_DCHECK_GT(n, 0); + ABSL_DCHECK_GT(n, 0); const T* ii = value.data(); int i = 0; @@ -1464,7 +1464,7 @@ inline uint8_t* WireFormatLite::WriteFixedNoTagToArray( (void)Writer; const int n = value.size(); - GOOGLE_ABSL_DCHECK_GT(n, 0); + ABSL_DCHECK_GT(n, 0); const T* ii = value.data(); const int bytes = n * static_cast(sizeof(ii[0])); diff --git a/src/google/protobuf/wire_format_unittest.inc b/src/google/protobuf/wire_format_unittest.inc index 7e1d7856f561..233fa92e71ab 100644 --- a/src/google/protobuf/wire_format_unittest.inc +++ b/src/google/protobuf/wire_format_unittest.inc @@ -36,7 +36,8 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/base/casts.h" -#include "google/protobuf/stubs/logging.h" +#include "absl/log/absl_check.h" +#include "absl/log/scoped_mock_log.h" #include "absl/strings/cord.h" #include "absl/strings/match.h" #include "google/protobuf/descriptor.h" @@ -1230,7 +1231,7 @@ class WireFormatInvalidInputTest : public testing::Test { const FieldDescriptor* field = UNITTEST::TestAllTypes::descriptor()->FindFieldByName( "optional_nested_message"); - GOOGLE_ABSL_CHECK(field != nullptr); + ABSL_CHECK(field != nullptr); std::string result; @@ -1252,7 +1253,7 @@ class WireFormatInvalidInputTest : public testing::Test { bool include_end_tag) { const FieldDescriptor* field = UNITTEST::TestAllTypes::descriptor()->FindFieldByName("optionalgroup"); - GOOGLE_ABSL_CHECK(field != nullptr); + ABSL_CHECK(field != nullptr); std::string result; @@ -1420,20 +1421,20 @@ TEST_F(Utf8ValidationTest, WriteInvalidUTF8String) { UNITTEST::OneString input; std::vector errors; { - ScopedMemoryLog log; - WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); - } + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - EXPECT_THAT(errors, testing::ElementsAre(absl::StrCat( + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, absl::StrCat( "String field '", UNITTEST_PACKAGE_NAME, ".OneString.data' " "contains invalid UTF-8 data when " "serializing a protocol buffer. Use the " "'bytes' type if you intend to send raw bytes. "))); #else - ASSERT_EQ(0, errors.size()); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + log.StartCapturingLogs(); + WriteMessage(kInvalidUTF8String, &input, &wire_buffer); + } } @@ -1444,34 +1445,32 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) { UNITTEST::OneString output; std::vector errors; { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - EXPECT_THAT(errors, testing::ElementsAre(absl::StrCat( + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, absl::StrCat( "String field '", UNITTEST_PACKAGE_NAME, ".OneString.data' " "contains invalid UTF-8 data when " "parsing a protocol buffer. Use the " "'bytes' type if you intend to send raw bytes. "))); - #else - ASSERT_EQ(0, errors.size()); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + log.StartCapturingLogs(); + ReadMessage(wire_buffer, &output); + } } TEST_F(Utf8ValidationTest, WriteValidUTF8String) { std::string wire_buffer; UNITTEST::OneString input; - std::vector errors; { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); + log.StartCapturingLogs(); WriteMessage(kValidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); } - ASSERT_EQ(0, errors.size()); } TEST_F(Utf8ValidationTest, ReadValidUTF8String) { @@ -1479,13 +1478,12 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { UNITTEST::OneString input; WriteMessage(kValidUTF8String, &input, &wire_buffer); UNITTEST::OneString output; - std::vector errors; { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); + log.StartCapturingLogs(); ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); } - ASSERT_EQ(0, errors.size()); EXPECT_EQ(input.data(), output.data()); } @@ -1493,13 +1491,12 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { TEST_F(Utf8ValidationTest, WriteArbitraryBytes) { std::string wire_buffer; UNITTEST::OneBytes input; - std::vector errors; { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); + log.StartCapturingLogs(); WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); } - ASSERT_EQ(0, errors.size()); } TEST_F(Utf8ValidationTest, ReadArbitraryBytes) { @@ -1507,13 +1504,12 @@ TEST_F(Utf8ValidationTest, ReadArbitraryBytes) { UNITTEST::OneBytes input; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); UNITTEST::OneBytes output; - std::vector errors; { - ScopedMemoryLog log; + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); + log.StartCapturingLogs(); ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); } - ASSERT_EQ(0, errors.size()); EXPECT_EQ(input.data(), output.data()); } @@ -1525,17 +1521,16 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { std::string wire_buffer = input.SerializeAsString(); UNITTEST::MoreString output; - std::vector errors; { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - ASSERT_EQ(2, errors.size()); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(2); #else - ASSERT_EQ(0, errors.size()); + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + log.StartCapturingLogs(); + ReadMessage(wire_buffer, &output); + } EXPECT_EQ(wire_buffer, output.SerializeAsString()); } @@ -1544,23 +1539,20 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { std::string data(kInvalidUTF8String); - std::vector errors; { - ScopedMemoryLog log; - WireFormat::VerifyUTF8String(data.data(), data.size(), - WireFormat::SERIALIZE); - errors = log.GetMessages(ERROR); - } + absl::ScopedMockLog log(absl::MockLogDefault::kDisallowUnexpected); #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - ASSERT_EQ(1, errors.size()); - EXPECT_TRUE( - absl::StartsWith(errors[0], + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::StartsWith( "String field contains invalid UTF-8 data when " "serializing a protocol buffer. Use the " - "'bytes' type if you intend to send raw bytes.")); + "'bytes' type if you intend to send raw bytes."))); #else - ASSERT_EQ(0, errors.size()); -#endif + EXPECT_CALL(log, Log(absl::LogSeverity::kError, testing::_, testing::_)).Times(0); +#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + log.StartCapturingLogs(); + WireFormat::VerifyUTF8String(data.data(), data.size(), + WireFormat::SERIALIZE); + } }