Internal changes

PiperOrigin-RevId: 494869411
pull/11212/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent ad746163bc
commit d7610a4a32
  1. 7
      src/google/protobuf/compiler/annotation_test_util.cc
  2. 6
      src/google/protobuf/compiler/code_generator.cc
  3. 25
      src/google/protobuf/compiler/command_line_interface.cc
  4. 39
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  5. 5
      src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
  6. 6
      src/google/protobuf/compiler/csharp/csharp_enum.cc
  7. 9
      src/google/protobuf/compiler/csharp/csharp_field_base.cc
  8. 7
      src/google/protobuf/compiler/csharp/csharp_helpers.cc
  9. 4
      src/google/protobuf/compiler/csharp/csharp_message.cc
  10. 11
      src/google/protobuf/compiler/importer_unittest.cc
  11. 13
      src/google/protobuf/compiler/mock_code_generator.cc
  12. 6
      src/google/protobuf/compiler/objectivec/field.cc
  13. 13
      src/google/protobuf/compiler/objectivec/helpers.cc
  14. 3
      src/google/protobuf/compiler/objectivec/import_writer.cc
  15. 3
      src/google/protobuf/compiler/objectivec/map_field.cc
  16. 3
      src/google/protobuf/compiler/objectivec/message.cc
  17. 5
      src/google/protobuf/compiler/objectivec/primitive_field.cc
  18. 25
      src/google/protobuf/compiler/parser.cc
  19. 5
      src/google/protobuf/compiler/parser_unittest.cc
  20. 5
      src/google/protobuf/compiler/php/php_generator.cc
  21. 1
      src/google/protobuf/compiler/plugin.cc
  22. 15
      src/google/protobuf/compiler/ruby/ruby_generator.cc
  23. 36
      src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
  24. 8
      src/google/protobuf/compiler/scc.h
  25. 57
      src/google/protobuf/compiler/subprocess.cc

@ -40,6 +40,7 @@
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/testing/googletest.h" #include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h" #include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h"
@ -70,8 +71,8 @@ class DescriptorCapturingGenerator : public CodeGenerator {
} // namespace } // namespace
void AddFile(const std::string& filename, const std::string& data) { void AddFile(const std::string& filename, const std::string& data) {
GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/" + filename, data, GOOGLE_ABSL_CHECK_OK(File::SetContents(TestTempDir() + "/" + filename, data,
true)); true));
} }
bool RunProtoCompiler(const std::string& filename, bool RunProtoCompiler(const std::string& filename,
@ -94,7 +95,7 @@ bool RunProtoCompiler(const std::string& filename,
bool DecodeMetadata(const std::string& path, GeneratedCodeInfo* info) { bool DecodeMetadata(const std::string& path, GeneratedCodeInfo* info) {
std::string data; std::string data;
GOOGLE_CHECK_OK(File::GetContents(path, &data, true)); GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &data, true));
io::ArrayInputStream input(data.data(), data.size()); io::ArrayInputStream input(data.data(), data.size());
return info->ParseFromZeroCopyStream(&input); return info->ParseFromZeroCopyStream(&input);
} }

@ -34,9 +34,9 @@
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
#include "absl/strings/strip.h" #include "absl/strings/strip.h"
@ -81,7 +81,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend(
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
const std::string& filename, const std::string& insertion_point) { const std::string& filename, const std::string& insertion_point) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion."; GOOGLE_ABSL_LOG(FATAL) << "This GeneratorContext does not support insertion.";
return nullptr; // make compiler happy return nullptr; // make compiler happy
} }
@ -93,7 +93,7 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo(
void GeneratorContext::ListParsedFiles( void GeneratorContext::ListParsedFiles(
std::vector<const FileDescriptor*>* output) { std::vector<const FileDescriptor*>* output) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; GOOGLE_ABSL_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
} }
void GeneratorContext::GetCompilerVersion(Version* version) const { void GeneratorContext::GetCompilerVersion(Version* version) const {

@ -74,6 +74,7 @@
#include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/compiler/subprocess.h" #include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/compiler/plugin.pb.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
@ -141,7 +142,7 @@ void SetFdToTextMode(int fd) {
#ifdef _WIN32 #ifdef _WIN32
if (setmode(fd, _O_TEXT) == -1) { if (setmode(fd, _O_TEXT) == -1) {
// This should never happen, I think. // This should never happen, I think.
GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); GOOGLE_ABSL_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno);
} }
#endif #endif
// (Text and binary are the same on non-Windows platforms.) // (Text and binary are the same on non-Windows platforms.)
@ -151,7 +152,8 @@ void SetFdToBinaryMode(int fd) {
#ifdef _WIN32 #ifdef _WIN32
if (setmode(fd, _O_BINARY) == -1) { if (setmode(fd, _O_BINARY) == -1) {
// This should never happen, I think. // This should never happen, I think.
GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno); GOOGLE_ABSL_LOG(WARNING) << "setmode(" << fd
<< ", _O_BINARY): " << strerror(errno);
} }
#endif #endif
// (Text and binary are the same on non-Windows platforms.) // (Text and binary are the same on non-Windows platforms.)
@ -892,7 +894,7 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
data_pos += line_length; data_pos += line_length;
} }
GOOGLE_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size); GOOGLE_ABSL_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size);
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size()); UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
} }
@ -1106,7 +1108,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
} }
if (!dependency_out_name_.empty()) { if (!dependency_out_name_.empty()) {
GOOGLE_DCHECK(disk_source_tree.get()); GOOGLE_ABSL_DCHECK(disk_source_tree.get());
if (!GenerateDependencyManifestFile(parsed_files, output_directories, if (!GenerateDependencyManifestFile(parsed_files, output_directories,
disk_source_tree.get())) { disk_source_tree.get())) {
return 1; return 1;
@ -1126,7 +1128,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
FileDescriptorProto file; FileDescriptorProto file;
file.set_name("empty_message.proto"); file.set_name("empty_message.proto");
file.add_message_type()->set_name("EmptyMessage"); file.add_message_type()->set_name("EmptyMessage");
GOOGLE_CHECK(pool.BuildFile(file) != nullptr); GOOGLE_ABSL_CHECK(pool.BuildFile(file) != nullptr);
codec_type_ = "EmptyMessage"; codec_type_ = "EmptyMessage";
if (!EncodeOrDecode(&pool)) { if (!EncodeOrDecode(&pool)) {
return 1; return 1;
@ -1154,8 +1156,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
} }
break; break;
case PRINT_NONE: case PRINT_NONE:
GOOGLE_LOG(ERROR) << "If the code reaches here, it usually means a bug of " GOOGLE_ABSL_LOG(ERROR)
"flag parsing in the CommandLineInterface."; << "If the code reaches here, it usually means a bug of "
"flag parsing in the CommandLineInterface.";
return 1; return 1;
// Do not add a default case. // Do not add a default case.
@ -1558,7 +1561,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
input_files_.empty() && descriptor_set_in_names_.empty(); input_files_.empty() && descriptor_set_in_names_.empty();
break; break;
default: default:
GOOGLE_LOG(FATAL) << "Unexpected mode: " << mode_; GOOGLE_ABSL_LOG(FATAL) << "Unexpected mode: " << mode_;
} }
if (missing_proto_definitions) { if (missing_proto_definitions) {
std::cerr << "Missing input file." << std::endl; std::cerr << "Missing input file." << std::endl;
@ -1763,7 +1766,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
direct_dependencies_explicitly_set_ = true; direct_dependencies_explicitly_set_ = true;
std::vector<std::string> direct = std::vector<std::string> direct =
absl::StrSplit(value, ":", absl::SkipEmpty()); absl::StrSplit(value, ":", absl::SkipEmpty());
GOOGLE_DCHECK(direct_dependencies_.empty()); GOOGLE_ABSL_DCHECK(direct_dependencies_.empty());
direct_dependencies_.insert(direct.begin(), direct.end()); direct_dependencies_.insert(direct.begin(), direct.end());
} else if (name == "--direct_dependencies_violation_msg") { } else if (name == "--direct_dependencies_violation_msg") {
@ -2163,8 +2166,8 @@ bool CommandLineInterface::GenerateOutput(
std::string error; std::string error;
if (output_directive.generator == nullptr) { if (output_directive.generator == nullptr) {
// This is a plugin. // This is a plugin.
GOOGLE_CHECK(absl::StartsWith(output_directive.name, "--") && GOOGLE_ABSL_CHECK(absl::StartsWith(output_directive.name, "--") &&
absl::EndsWith(output_directive.name, "_out")) absl::EndsWith(output_directive.name, "_out"))
<< "Bad name for plugin generator: " << output_directive.name; << "Bad name for plugin generator: " << output_directive.name;
std::string plugin_name = PluginName(plugin_prefix_, output_directive.name); std::string plugin_name = PluginName(plugin_prefix_, output_directive.name);

@ -38,6 +38,7 @@
#include <cstdint> #include <cstdint>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#ifndef _MSC_VER #ifndef _MSC_VER
@ -288,7 +289,7 @@ void CommandLineInterfaceTest::SetUp() {
} }
// Create the temp directory. // Create the temp directory.
GOOGLE_CHECK_OK(File::CreateDir(temp_directory_, 0777)); GOOGLE_ABSL_CHECK_OK(File::CreateDir(temp_directory_, 0777));
// Register generators. // Register generators.
CodeGenerator* generator = new MockCodeGenerator("test_generator"); CodeGenerator* generator = new MockCodeGenerator("test_generator");
@ -361,7 +362,7 @@ void CommandLineInterfaceTest::RunWithArgs(std::vector<std::string> args) {
#endif #endif
if (plugin_path.empty() || !FileExists(plugin_path)) { if (plugin_path.empty() || !FileExists(plugin_path)) {
GOOGLE_LOG(ERROR) GOOGLE_ABSL_LOG(ERROR)
<< "Plugin executable not found. Plugin tests are likely to fail." << "Plugin executable not found. Plugin tests are likely to fail."
<< plugin_path; << plugin_path;
} else { } else {
@ -401,21 +402,21 @@ void CommandLineInterfaceTest::CreateTempFile(const std::string& name,
if (slash_pos != std::string::npos) { if (slash_pos != std::string::npos) {
std::string dir = name.substr(0, slash_pos); std::string dir = name.substr(0, slash_pos);
if (!FileExists(temp_directory_ + "/" + dir)) { if (!FileExists(temp_directory_ + "/" + dir)) {
GOOGLE_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + "/" + dir, GOOGLE_ABSL_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + "/" + dir,
0777)); 0777));
} }
} }
// Write file. // Write file.
std::string full_name = temp_directory_ + "/" + name; std::string full_name = temp_directory_ + "/" + name;
GOOGLE_CHECK_OK(File::SetContents( GOOGLE_ABSL_CHECK_OK(File::SetContents(
full_name, absl::StrReplaceAll(contents, {{"$tmpdir", temp_directory_}}), full_name, absl::StrReplaceAll(contents, {{"$tmpdir", temp_directory_}}),
true)); true));
} }
void CommandLineInterfaceTest::CreateTempDir(const std::string& name) { void CommandLineInterfaceTest::CreateTempDir(const std::string& name) {
GOOGLE_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + "/" + name, GOOGLE_ABSL_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + "/" + name,
0777)); 0777));
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -503,7 +504,7 @@ void CommandLineInterfaceTest::ReadDescriptorSet(
const std::string& filename, FileDescriptorSet* descriptor_set) { const std::string& filename, FileDescriptorSet* descriptor_set) {
std::string path = temp_directory_ + "/" + filename; std::string path = temp_directory_ + "/" + filename;
std::string file_contents; std::string file_contents;
GOOGLE_CHECK_OK(File::GetContents(path, &file_contents, true)); GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &file_contents, true));
if (!descriptor_set->ParseFromString(file_contents)) { if (!descriptor_set->ParseFromString(file_contents)) {
FAIL() << "Could not parse file contents: " << path; FAIL() << "Could not parse file contents: " << path;
@ -513,7 +514,7 @@ void CommandLineInterfaceTest::ReadDescriptorSet(
void CommandLineInterfaceTest::WriteDescriptorSet( void CommandLineInterfaceTest::WriteDescriptorSet(
const std::string& filename, const FileDescriptorSet* descriptor_set) { const std::string& filename, const FileDescriptorSet* descriptor_set) {
std::string binary_proto; std::string binary_proto;
GOOGLE_CHECK(descriptor_set->SerializeToString(&binary_proto)); GOOGLE_ABSL_CHECK(descriptor_set->SerializeToString(&binary_proto));
CreateTempFile(filename, binary_proto); CreateTempFile(filename, binary_proto);
} }
@ -539,7 +540,7 @@ void CommandLineInterfaceTest::ExpectFileContent(const std::string& filename,
const std::string& content) { const std::string& content) {
std::string path = temp_directory_ + "/" + filename; std::string path = temp_directory_ + "/" + filename;
std::string file_contents; std::string file_contents;
GOOGLE_CHECK_OK(File::GetContents(path, &file_contents, true)); GOOGLE_ABSL_CHECK_OK(File::GetContents(path, &file_contents, true));
EXPECT_EQ(absl::StrReplaceAll(content, {{"$tmpdir", temp_directory_}}), EXPECT_EQ(absl::StrReplaceAll(content, {{"$tmpdir", temp_directory_}}),
file_contents); file_contents);
@ -2560,8 +2561,8 @@ class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> {
void RedirectStdinFromText(const std::string& input) { void RedirectStdinFromText(const std::string& input) {
std::string filename = TestTempDir() + "/test_stdin"; std::string filename = TestTempDir() + "/test_stdin";
GOOGLE_CHECK_OK(File::SetContents(filename, input, true)); GOOGLE_ABSL_CHECK_OK(File::SetContents(filename, input, true));
GOOGLE_CHECK(RedirectStdinFromFile(filename)); GOOGLE_ABSL_CHECK(RedirectStdinFromFile(filename));
} }
bool RedirectStdinFromFile(const std::string& filename) { bool RedirectStdinFromFile(const std::string& filename) {
@ -2629,7 +2630,8 @@ class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> {
void ExpectStdoutMatchesBinaryFile(const std::string& filename) { void ExpectStdoutMatchesBinaryFile(const std::string& filename) {
std::string expected_output; std::string expected_output;
GOOGLE_CHECK_OK(File::GetContents(filename, &expected_output, true)); GOOGLE_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 // Don't use EXPECT_EQ because we don't want to print raw binary data to
// stdout on failure. // stdout on failure.
@ -2638,7 +2640,8 @@ class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> {
void ExpectStdoutMatchesTextFile(const std::string& filename) { void ExpectStdoutMatchesTextFile(const std::string& filename) {
std::string expected_output; std::string expected_output;
GOOGLE_CHECK_OK(File::GetContents(filename, &expected_output, true)); GOOGLE_ABSL_CHECK_OK(
File::GetContents(filename, &expected_output, true));
ExpectStdoutMatchesText(expected_output); ExpectStdoutMatchesText(expected_output);
} }
@ -2670,12 +2673,12 @@ class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> {
protobuf_unittest_import::PublicImportMessage public_import_message; protobuf_unittest_import::PublicImportMessage public_import_message;
public_import_message.descriptor()->file()->CopyTo( public_import_message.descriptor()->file()->CopyTo(
file_descriptor_set.add_file()); file_descriptor_set.add_file());
GOOGLE_DCHECK(file_descriptor_set.IsInitialized()); GOOGLE_ABSL_DCHECK(file_descriptor_set.IsInitialized());
std::string binary_proto; std::string binary_proto;
GOOGLE_CHECK(file_descriptor_set.SerializeToString(&binary_proto)); GOOGLE_ABSL_CHECK(file_descriptor_set.SerializeToString(&binary_proto));
GOOGLE_CHECK_OK(File::SetContents(unittest_proto_descriptor_set_filename_, GOOGLE_ABSL_CHECK_OK(File::SetContents(unittest_proto_descriptor_set_filename_,
binary_proto, true)); binary_proto, true));
} }
int duped_stdin_; int duped_stdin_;

@ -83,9 +83,8 @@ class MockGeneratorContext : public GeneratorContext {
std::string expected_contents = *it->second; std::string expected_contents = *it->second;
std::string actual_contents; std::string actual_contents;
GOOGLE_CHECK_OK( GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText(
File::GetContentsAsText(TestSourceDir() + "/" + physical_filename, TestSourceDir() + "/" + physical_filename, &actual_contents, true))
&actual_contents, true))
<< "Unable to get " << physical_filename; << "Unable to get " << physical_filename;
EXPECT_TRUE(actual_contents == expected_contents) EXPECT_TRUE(actual_contents == expected_contents)
<< physical_filename << " needs to be regenerated. Please run " << physical_filename << " needs to be regenerated. Please run "

@ -35,6 +35,7 @@
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h"
@ -78,8 +79,9 @@ void EnumGenerator::Generate(io::Printer* printer) {
// Make sure we don't get any duplicate names due to prefix removal. // Make sure we don't get any duplicate names due to prefix removal.
while (!used_names.insert(name).second) { 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. // It's possible we'll end up giving this warning multiple times, but that's better than not at all.
GOOGLE_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name GOOGLE_ABSL_LOG(WARNING) << "Duplicate enum value " << name << " (originally "
<< ") in " << descriptor_->name() << "; adding underscore to distinguish"; << original_name << ") in " << descriptor_->name()
<< "; adding underscore to distinguish";
name += "_"; name += "_";
} }
int number = descriptor_->value(i)->number(); int number = descriptor_->value(i)->number();

@ -36,6 +36,7 @@
#include <string> #include <string>
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/names.h" #include "google/protobuf/compiler/csharp/names.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
@ -278,7 +279,7 @@ std::string FieldGeneratorBase::type_name(const FieldDescriptor* descriptor) {
case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_SINT64:
return "long"; return "long";
default: default:
GOOGLE_LOG(FATAL)<< "Unknown field type."; GOOGLE_ABSL_LOG(FATAL) << "Unknown field type.";
return ""; return "";
} }
} }
@ -320,7 +321,7 @@ bool FieldGeneratorBase::has_default_value() {
case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_SINT64:
return descriptor_->default_value_int64() != 0L; return descriptor_->default_value_int64() != 0L;
default: default:
GOOGLE_LOG(FATAL)<< "Unknown field type."; GOOGLE_ABSL_LOG(FATAL) << "Unknown field type.";
return true; return true;
} }
} }
@ -420,7 +421,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor)
case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_SINT64:
return absl::StrCat(descriptor->default_value_int64()) + "L"; return absl::StrCat(descriptor->default_value_int64()) + "L";
default: default:
GOOGLE_LOG(FATAL)<< "Unknown field type."; GOOGLE_ABSL_LOG(FATAL) << "Unknown field type.";
return ""; return "";
} }
} }
@ -468,7 +469,7 @@ std::string FieldGeneratorBase::capitalized_type_name() {
case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_SINT64:
return "SInt64"; return "SInt64";
default: default:
GOOGLE_LOG(FATAL)<< "Unknown field type."; GOOGLE_ABSL_LOG(FATAL) << "Unknown field type.";
return ""; return "";
} }
} }

@ -40,6 +40,7 @@
#include <vector> #include <vector>
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/str_replace.h" #include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -106,7 +107,7 @@ CSharpType GetCSharpType(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new // No default because we want the compiler to complain if any new
// types are added. // types are added.
} }
GOOGLE_LOG(FATAL)<< "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return (CSharpType) -1; return (CSharpType) -1;
} }
@ -336,7 +337,7 @@ int GetFixedSize(FieldDescriptor::Type type) {
// No default because we want the compiler to complain if any new // No default because we want the compiler to complain if any new
// types are added. // types are added.
} }
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return -1; return -1;
} }
@ -461,7 +462,7 @@ bool IsNullable(const FieldDescriptor* descriptor) {
return true; return true;
default: default:
GOOGLE_LOG(FATAL) << "Unknown field type."; GOOGLE_ABSL_LOG(FATAL) << "Unknown field type.";
return true; return true;
} }
} }

@ -35,6 +35,7 @@
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_enum.h" #include "google/protobuf/compiler/csharp/csharp_enum.h"
@ -764,7 +765,8 @@ int MessageGenerator::GetPresenceIndex(const FieldDescriptor* descriptor) {
index++; index++;
} }
} }
GOOGLE_LOG(DFATAL)<< "Could not find presence index for field " << descriptor->name(); GOOGLE_ABSL_LOG(DFATAL) << "Could not find presence index for field "
<< descriptor->name();
return -1; return -1;
} }

@ -36,7 +36,6 @@
#include <memory> #include <memory>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h"
@ -44,6 +43,7 @@
#include "google/protobuf/testing/googletest.h" #include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/io/zero_copy_stream_impl.h"
@ -266,7 +266,7 @@ class DiskSourceTreeTest : public testing::Test {
if (FileExists(dirnames_[i])) { if (FileExists(dirnames_[i])) {
File::DeleteRecursively(dirnames_[i], NULL, NULL); File::DeleteRecursively(dirnames_[i], NULL, NULL);
} }
GOOGLE_CHECK_OK(File::CreateDir(dirnames_[i], 0777)); GOOGLE_ABSL_CHECK_OK(File::CreateDir(dirnames_[i], 0777));
} }
} }
@ -279,11 +279,11 @@ class DiskSourceTreeTest : public testing::Test {
} }
void AddFile(const std::string& filename, const char* contents) { void AddFile(const std::string& filename, const char* contents) {
GOOGLE_CHECK_OK(File::SetContents(filename, contents, true)); GOOGLE_ABSL_CHECK_OK(File::SetContents(filename, contents, true));
} }
void AddSubdir(const std::string& dirname) { void AddSubdir(const std::string& dirname) {
GOOGLE_CHECK_OK(File::CreateDir(dirname, 0777)); GOOGLE_ABSL_CHECK_OK(File::CreateDir(dirname, 0777));
} }
void ExpectFileContents(const std::string& filename, void ExpectFileContents(const std::string& filename,
@ -397,7 +397,8 @@ TEST_F(DiskSourceTreeTest, OrderingTrumpsSpecificity) {
// directory is more-specific than a former one. // directory is more-specific than a former one.
// Create the "bar" directory so we can put a file in it. // Create the "bar" directory so we can put a file in it.
GOOGLE_CHECK_OK(File::CreateDir(dirnames_[0] + "/bar", 0777)); GOOGLE_ABSL_CHECK_OK(
File::CreateDir(dirnames_[0] + "/bar", 0777));
// Add files and map paths. // Add files and map paths.
AddFile(dirnames_[0] + "/bar/foo", "Hello World!"); AddFile(dirnames_[0] + "/bar/foo", "Hello World!");

@ -39,12 +39,13 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h"
#include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/strings/str_replace.h" #include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
@ -105,7 +106,7 @@ void MockCodeGenerator::ExpectGenerated(
const std::string& first_parsed_file_name, const std::string& first_parsed_file_name,
const std::string& output_directory) { const std::string& output_directory) {
std::string content; std::string content;
GOOGLE_CHECK_OK( GOOGLE_ABSL_CHECK_OK(
File::GetContents(output_directory + "/" + GetOutputFileName(name, file), File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
&content, true)); &content, true));
@ -163,15 +164,15 @@ void MockCodeGenerator::CheckGeneratedAnnotations(
const std::string& name, const std::string& file, const std::string& name, const std::string& file,
const std::string& output_directory) { const std::string& output_directory) {
std::string file_content; std::string file_content;
GOOGLE_CHECK_OK( GOOGLE_ABSL_CHECK_OK(
File::GetContents(output_directory + "/" + GetOutputFileName(name, file), File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
&file_content, true)); &file_content, true));
std::string meta_content; std::string meta_content;
GOOGLE_CHECK_OK(File::GetContents( GOOGLE_ABSL_CHECK_OK(File::GetContents(
output_directory + "/" + GetOutputFileName(name, file) + ".pb.meta", output_directory + "/" + GetOutputFileName(name, file) + ".pb.meta",
&meta_content, true)); &meta_content, true));
GeneratedCodeInfo annotations; GeneratedCodeInfo annotations;
GOOGLE_CHECK(TextFormat::ParseFromString(meta_content, &annotations)); GOOGLE_ABSL_CHECK(TextFormat::ParseFromString(meta_content, &annotations));
ASSERT_EQ(7, annotations.annotation_size()); ASSERT_EQ(7, annotations.annotation_size());
CheckSingleAnnotation("first_annotation", "first", file_content, CheckSingleAnnotation("first_annotation", "first", file_content,
@ -245,7 +246,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
<< " " << compiler_version.suffix() << std::endl; << " " << compiler_version.suffix() << std::endl;
abort(); abort();
} else { } else {
GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; GOOGLE_ABSL_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command;
} }
} }
} }

@ -36,6 +36,8 @@
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/enum_field.h" #include "google/protobuf/compiler/objectivec/enum_field.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
@ -167,7 +169,7 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return false; return false;
} }
@ -476,7 +478,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
const FieldGenerator& FieldGeneratorMap::get( const FieldGenerator& FieldGeneratorMap::get(
const FieldDescriptor* field) const { const FieldDescriptor* field) const {
GOOGLE_CHECK_EQ(field->containing_type(), descriptor_); GOOGLE_ABSL_CHECK_EQ(field->containing_type(), descriptor_);
return *field_generators_[field->index()]; return *field_generators_[field->index()];
} }

@ -34,6 +34,7 @@
#include <vector> #include <vector>
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -66,7 +67,7 @@ std::string GetZeroEnumNameForFlagType(const FlagType flag_type) {
case FLAGTYPE_FIELD: case FLAGTYPE_FIELD:
return "GPBFieldNone"; return "GPBFieldNone";
default: default:
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return "0"; return "0";
} }
} }
@ -80,7 +81,7 @@ std::string GetEnumNameForFlagType(const FlagType flag_type) {
case FLAGTYPE_FIELD: case FLAGTYPE_FIELD:
return "GPBFieldFlags"; return "GPBFieldFlags";
default: default:
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return std::string(); return std::string();
} }
} }
@ -147,7 +148,7 @@ std::string GetCapitalizedType(const FieldDescriptor* field) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return std::string(); return std::string();
} }
@ -196,7 +197,7 @@ ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return OBJECTIVECTYPE_INT32; return OBJECTIVECTYPE_INT32;
} }
@ -235,7 +236,7 @@ std::string GPBGenericValueFieldName(const FieldDescriptor* field) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return std::string(); return std::string();
} }
@ -306,7 +307,7 @@ std::string DefaultValue(const FieldDescriptor* field) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return std::string(); return std::string();
} }

@ -36,6 +36,7 @@
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "google/protobuf/compiler/objectivec/line_consumer.h" #include "google/protobuf/compiler/objectivec/line_consumer.h"
@ -197,7 +198,7 @@ void ImportWriter::PrintRuntimeImports(io::Printer* p,
// If bundled, no need to do the framework support below. // If bundled, no need to do the framework support below.
if (for_bundled_proto_) { if (for_bundled_proto_) {
GOOGLE_DCHECK(!default_cpp_symbol); GOOGLE_ABSL_DCHECK(!default_cpp_symbol);
for (const auto& header : protobuf_imports_) { for (const auto& header : protobuf_imports_) {
p->Print("#import \"$header$\"\n", "header", header); p->Print("#import \"$header$\"\n", "header", header);
} }

@ -34,6 +34,7 @@
#include <vector> #include <vector>
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
#include "google/protobuf/compiler/objectivec/names.h" #include "google/protobuf/compiler/objectivec/names.h"
@ -78,7 +79,7 @@ const char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return nullptr; return nullptr;
} }

@ -38,6 +38,7 @@
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/extension.h" #include "google/protobuf/compiler/objectivec/extension.h"
@ -127,7 +128,7 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return 0; return 0;
} }

@ -33,6 +33,7 @@
#include <string> #include <string>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -73,7 +74,7 @@ const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return nullptr; return nullptr;
} }
@ -107,7 +108,7 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) {
// Some compilers report reaching end of function even though all cases of // Some compilers report reaching end of function even though all cases of
// the enum are handed in the switch. // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return nullptr; return nullptr;
} }

@ -44,10 +44,11 @@
#include <tuple> #include <tuple>
#include <utility> #include <utility>
#include "google/protobuf/stubs/logging.h"
#include "absl/base/casts.h" #include "absl/base/casts.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -516,8 +517,8 @@ int Parser::LocationRecorder::CurrentPathSize() const {
void Parser::LocationRecorder::AttachComments( void Parser::LocationRecorder::AttachComments(
std::string* leading, std::string* trailing, std::string* leading, std::string* trailing,
std::vector<std::string>* detached_comments) const { std::vector<std::string>* detached_comments) const {
GOOGLE_CHECK(!location_->has_leading_comments()); GOOGLE_ABSL_CHECK(!location_->has_leading_comments());
GOOGLE_CHECK(!location_->has_trailing_comments()); GOOGLE_ABSL_CHECK(!location_->has_trailing_comments());
if (!leading->empty()) { if (!leading->empty()) {
location_->mutable_leading_comments()->swap(*leading); location_->mutable_leading_comments()->swap(*leading);
@ -671,10 +672,11 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
file->set_syntax(syntax_identifier_); file->set_syntax(syntax_identifier_);
} }
} else if (!stop_after_syntax_identifier_) { } else if (!stop_after_syntax_identifier_) {
GOOGLE_LOG(WARNING) << "No syntax specified for the proto file: " << file->name() GOOGLE_ABSL_LOG(WARNING) << "No syntax specified for the proto file: "
<< ". Please use 'syntax = \"proto2\";' " << file->name()
<< "or 'syntax = \"proto3\";' to specify a syntax " << ". Please use 'syntax = \"proto2\";' "
<< "version. (Defaulted to proto2 syntax.)"; << "or 'syntax = \"proto3\";' to specify a syntax "
<< "version. (Defaulted to proto2 syntax.)";
syntax_identifier_ = "proto2"; syntax_identifier_ = "proto2";
} }
@ -1488,7 +1490,7 @@ bool Parser::ParseOption(Message* options,
// Create an entry in the uninterpreted_option field. // Create an entry in the uninterpreted_option field.
const FieldDescriptor* uninterpreted_option_field = const FieldDescriptor* uninterpreted_option_field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option"); options->GetDescriptor()->FindFieldByName("uninterpreted_option");
GOOGLE_CHECK(uninterpreted_option_field != nullptr) GOOGLE_ABSL_CHECK(uninterpreted_option_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto."; << "No field named \"uninterpreted_option\" in the Options proto.";
const Reflection* reflection = options->GetReflection(); const Reflection* reflection = options->GetReflection();
@ -1541,7 +1543,8 @@ bool Parser::ParseOption(Message* options,
switch (input_->current().type) { switch (input_->current().type) {
case io::Tokenizer::TYPE_START: case io::Tokenizer::TYPE_START:
GOOGLE_LOG(FATAL) << "Trying to read value before any tokens have been read."; GOOGLE_ABSL_LOG(FATAL)
<< "Trying to read value before any tokens have been read.";
return false; return false;
case io::Tokenizer::TYPE_END: case io::Tokenizer::TYPE_END:
@ -1550,9 +1553,9 @@ bool Parser::ParseOption(Message* options,
case io::Tokenizer::TYPE_WHITESPACE: case io::Tokenizer::TYPE_WHITESPACE:
case io::Tokenizer::TYPE_NEWLINE: case io::Tokenizer::TYPE_NEWLINE:
GOOGLE_CHECK(!input_->report_whitespace() && !input_->report_newlines()) GOOGLE_ABSL_CHECK(!input_->report_whitespace() && !input_->report_newlines())
<< "Whitespace tokens were not requested."; << "Whitespace tokens were not requested.";
GOOGLE_LOG(FATAL) << "Tokenizer reported whitespace."; GOOGLE_ABSL_LOG(FATAL) << "Tokenizer reported whitespace.";
return false; return false;
case io::Tokenizer::TYPE_IDENTIFIER: { case io::Tokenizer::TYPE_IDENTIFIER: {

@ -45,6 +45,7 @@
#include "google/protobuf/testing/googletest.h" #include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/test_util2.h" #include "google/protobuf/test_util2.h"
@ -2855,14 +2856,14 @@ class SourceInfoTest : public ParserTest {
while (*text != '\0') { while (*text != '\0') {
if (*text == '$') { if (*text == '$') {
++text; ++text;
GOOGLE_CHECK_NE('\0', *text); GOOGLE_ABSL_CHECK_NE('\0', *text);
if (*text == '$') { if (*text == '$') {
text_without_markers_ += '$'; text_without_markers_ += '$';
++column; ++column;
} else { } else {
markers_[*text] = std::make_pair(line, column); markers_[*text] = std::make_pair(line, column);
++text; ++text;
GOOGLE_CHECK_EQ('$', *text); GOOGLE_ABSL_CHECK_EQ('$', *text);
} }
} else if (*text == '\n') { } else if (*text == '\n') {
++line; ++line;

@ -36,6 +36,7 @@
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h" #include "absl/strings/str_replace.h"
@ -2309,14 +2310,14 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
options.aggregate_metadata = true; options.aggregate_metadata = true;
for (const auto& prefix : absl::StrSplit(option_pair[1], "#", absl::AllowEmpty())) { for (const auto& prefix : absl::StrSplit(option_pair[1], "#", absl::AllowEmpty())) {
options.aggregate_metadata_prefixes.emplace(prefix); options.aggregate_metadata_prefixes.emplace(prefix);
GOOGLE_LOG(INFO) << prefix; GOOGLE_ABSL_LOG(INFO) << prefix;
} }
} else if (option_pair[0] == "internal") { } else if (option_pair[0] == "internal") {
options.is_descriptor = true; options.is_descriptor = true;
} else if (option_pair[0] == "internal_generate_c_wkt") { } else if (option_pair[0] == "internal_generate_c_wkt") {
GenerateCWellKnownTypes(files, generator_context); GenerateCWellKnownTypes(files, generator_context);
} else { } else {
GOOGLE_LOG(FATAL) << "Unknown codegen option: " << option_pair[0]; GOOGLE_ABSL_LOG(FATAL) << "Unknown codegen option: " << option_pair[0];
} }
} }

@ -39,7 +39,6 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"

@ -34,6 +34,7 @@
#include <sstream> #include <sstream>
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/compiler/plugin.h" #include "google/protobuf/compiler/plugin.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
@ -121,8 +122,8 @@ std::string StringifySyntax(FileDescriptor::Syntax syntax) {
return "proto3"; return "proto3";
case FileDescriptor::SYNTAX_UNKNOWN: case FileDescriptor::SYNTAX_UNKNOWN:
default: default:
GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports " GOOGLE_ABSL_LOG(FATAL) << "Unsupported syntax; this generator only supports "
"proto2 and proto3 syntax."; "proto2 and proto3 syntax.";
return ""; return "";
} }
} }
@ -247,7 +248,8 @@ void GenerateOneof(const OneofDescriptor* oneof, io::Printer* printer) {
bool GenerateMessage(const Descriptor* message, io::Printer* printer, bool GenerateMessage(const Descriptor* message, io::Printer* printer,
std::string* error) { std::string* error) {
if (message->extension_range_count() > 0 || message->extension_count() > 0) { if (message->extension_range_count() > 0 || message->extension_count() > 0) {
GOOGLE_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files."; GOOGLE_ABSL_LOG(WARNING)
<< "Extensions are not yet supported for proto2 .proto files.";
} }
// Don't generate MapEntry messages -- we use the Ruby extension's native // Don't generate MapEntry messages -- we use the Ruby extension's native
@ -422,8 +424,8 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) {
if (package_name.find("::") != std::string::npos) { if (package_name.find("::") != std::string::npos) {
need_change_to_module = false; need_change_to_module = false;
} else if (package_name.find('.') != std::string::npos) { } else if (package_name.find('.') != std::string::npos) {
GOOGLE_LOG(WARNING) << "ruby_package option should be in the form of:" GOOGLE_ABSL_LOG(WARNING) << "ruby_package option should be in the form of:"
<< " 'A::B::C' and not 'A.B.C'"; << " 'A::B::C' and not 'A.B.C'";
} }
} else { } else {
package_name = file->package(); package_name = file->package();
@ -519,7 +521,8 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
// TODO: Remove this when ruby supports extensions for proto2 syntax. // TODO: Remove this when ruby supports extensions for proto2 syntax.
if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 && if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
file->extension_count() > 0) { file->extension_count() > 0) {
GOOGLE_LOG(WARNING) << "Extensions are not yet supported for proto2 .proto files."; GOOGLE_ABSL_LOG(WARNING)
<< "Extensions are not yet supported for proto2 .proto files.";
} }
bool use_raw_descriptor = file->name() == "google/protobuf/descriptor.proto"; bool use_raw_descriptor = file->name() == "google/protobuf/descriptor.proto";

@ -68,26 +68,18 @@ void RubyTest(std::string proto_file, std::string import_proto_file = "") {
// Copy generated_code.proto to the temporary test directory. // Copy generated_code.proto to the temporary test directory.
std::string test_input; std::string test_input;
GOOGLE_CHECK_OK(File::GetContents( GOOGLE_ABSL_CHECK_OK(
ruby_tests + proto_file + ".proto", File::GetContents(ruby_tests + proto_file + ".proto", &test_input, true));
&test_input, GOOGLE_ABSL_CHECK_OK(File::SetContents(TestTempDir() + proto_file + ".proto",
true)); test_input, true));
GOOGLE_CHECK_OK(File::SetContents(
TestTempDir() + proto_file + ".proto",
test_input,
true));
// Copy generated_code_import.proto to the temporary test directory. // Copy generated_code_import.proto to the temporary test directory.
std::string test_import; std::string test_import;
if (!import_proto_file.empty()) { if (!import_proto_file.empty()) {
GOOGLE_CHECK_OK(File::GetContents( GOOGLE_ABSL_CHECK_OK(File::GetContents(ruby_tests + import_proto_file + ".proto",
ruby_tests + import_proto_file + ".proto", &test_import, true));
&test_import, GOOGLE_ABSL_CHECK_OK(File::SetContents(
true)); TestTempDir() + import_proto_file + ".proto", test_import, true));
GOOGLE_CHECK_OK(File::SetContents(
TestTempDir() + import_proto_file + ".proto",
test_import,
true));
} }
// Invoke the proto compiler (we will be inside TestTempDir() at this point). // Invoke the proto compiler (we will be inside TestTempDir() at this point).
@ -106,15 +98,11 @@ void RubyTest(std::string proto_file, std::string import_proto_file = "") {
// Load the generated output and compare to the expected result. // Load the generated output and compare to the expected result.
std::string output; std::string output;
GOOGLE_CHECK_OK(File::GetContentsAsText( GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText(TestTempDir() + proto_file + "_pb.rb",
TestTempDir() + proto_file + "_pb.rb", &output, true));
&output,
true));
std::string expected_output; std::string expected_output;
GOOGLE_CHECK_OK(File::GetContentsAsText( GOOGLE_ABSL_CHECK_OK(File::GetContentsAsText(ruby_tests + proto_file + "_pb.rb",
ruby_tests + proto_file + "_pb.rb", &expected_output, true));
&expected_output,
true));
EXPECT_EQ(expected_output, output); EXPECT_EQ(expected_output, output);
} }

@ -33,9 +33,9 @@
#include <memory> #include <memory>
#include "google/protobuf/stubs/logging.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
@ -99,7 +99,7 @@ class PROTOC_EXPORT SCCAnalyzer {
// Mark visited by inserting in map. // Mark visited by inserting in map.
auto ins = cache_.try_emplace(descriptor, absl::make_unique<NodeData>()); auto ins = cache_.try_emplace(descriptor, absl::make_unique<NodeData>());
// Must not have visited already. // Must not have visited already.
GOOGLE_DCHECK(ins.second); GOOGLE_ABSL_DCHECK(ins.second);
NodeData& result = *ins.first->second; NodeData& result = *ins.first->second;
// Initialize data structures. // Initialize data structures.
result.index = result.lowlink = index_++; result.index = result.lowlink = index_++;
@ -107,7 +107,7 @@ class PROTOC_EXPORT SCCAnalyzer {
// Recurse the fields / nodes in graph // Recurse the fields / nodes in graph
for (const auto* dep : DepsGenerator()(descriptor)) { for (const auto* dep : DepsGenerator()(descriptor)) {
GOOGLE_CHECK(dep); GOOGLE_ABSL_CHECK(dep);
auto it = cache_.find(dep); auto it = cache_.find(dep);
if (it == cache_.end()) { if (it == cache_.end()) {
// unexplored node // unexplored node
@ -150,7 +150,7 @@ class PROTOC_EXPORT SCCAnalyzer {
absl::flat_hash_set<const SCC*> seen; absl::flat_hash_set<const SCC*> seen;
for (auto descriptor : scc->descriptors) { for (auto descriptor : scc->descriptors) {
for (auto child_msg : DepsGenerator()(descriptor)) { for (auto child_msg : DepsGenerator()(descriptor)) {
GOOGLE_CHECK(child_msg); GOOGLE_ABSL_CHECK(child_msg);
const SCC* child = GetSCC(child_msg); const SCC* child = GetSCC(child_msg);
if (child == scc) continue; if (child == scc) continue;
if (seen.insert(child).second) { if (seen.insert(child).second) {

@ -43,6 +43,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/logging.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
@ -57,8 +58,8 @@ namespace compiler {
static void CloseHandleOrDie(HANDLE handle) { static void CloseHandleOrDie(HANDLE handle) {
if (!CloseHandle(handle)) { if (!CloseHandle(handle)) {
GOOGLE_LOG(FATAL) << "CloseHandle: " GOOGLE_ABSL_LOG(FATAL) << "CloseHandle: "
<< Subprocess::Win32ErrorMessage(GetLastError()); << Subprocess::Win32ErrorMessage(GetLastError());
} }
} }
@ -85,22 +86,22 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
HANDLE stdout_pipe_write; HANDLE stdout_pipe_write;
if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) { if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); GOOGLE_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
} }
if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) { if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) {
GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); GOOGLE_ABSL_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
} }
// Make child side of the pipes inheritable. // Make child side of the pipes inheritable.
if (!SetHandleInformation(stdin_pipe_read, HANDLE_FLAG_INHERIT, if (!SetHandleInformation(stdin_pipe_read, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) { HANDLE_FLAG_INHERIT)) {
GOOGLE_LOG(FATAL) << "SetHandleInformation: " GOOGLE_ABSL_LOG(FATAL) << "SetHandleInformation: "
<< Win32ErrorMessage(GetLastError()); << Win32ErrorMessage(GetLastError());
} }
if (!SetHandleInformation(stdout_pipe_write, HANDLE_FLAG_INHERIT, if (!SetHandleInformation(stdout_pipe_write, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) { HANDLE_FLAG_INHERIT)) {
GOOGLE_LOG(FATAL) << "SetHandleInformation: " GOOGLE_ABSL_LOG(FATAL) << "SetHandleInformation: "
<< Win32ErrorMessage(GetLastError()); << Win32ErrorMessage(GetLastError());
} }
// Setup STARTUPINFO to redirect handles. // Setup STARTUPINFO to redirect handles.
@ -113,13 +114,13 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
if (startup_info.hStdError == INVALID_HANDLE_VALUE) { if (startup_info.hStdError == INVALID_HANDLE_VALUE) {
GOOGLE_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError()); GOOGLE_ABSL_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError());
} }
// get wide string version of program as the path may contain non-ascii characters // get wide string version of program as the path may contain non-ascii characters
std::wstring wprogram; std::wstring wprogram;
if (!io::win32::strings::utf8_to_wcs(program.c_str(), &wprogram)) { if (!io::win32::strings::utf8_to_wcs(program.c_str(), &wprogram)) {
GOOGLE_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); GOOGLE_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError());
} }
// Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'. // Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'.
@ -128,7 +129,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 // get wide string version of command line as the path may contain non-ascii characters
std::wstring wcommand_line; std::wstring wcommand_line;
if (!io::win32::strings::utf8_to_wcs(command_line.c_str(), &wcommand_line)) { if (!io::win32::strings::utf8_to_wcs(command_line.c_str(), &wcommand_line)) {
GOOGLE_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); GOOGLE_ABSL_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError());
} }
// Using a malloc'ed string because CreateProcess() can mutate its second // Using a malloc'ed string because CreateProcess() can mutate its second
@ -169,7 +170,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
return false; return false;
} }
GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first."; GOOGLE_ABSL_CHECK(child_handle_ != nullptr) << "Must call Start() first.";
std::string input_data; std::string input_data;
if (!input.SerializeToString(&input_data)) { if (!input.SerializeToString(&input_data)) {
@ -199,11 +200,11 @@ bool Subprocess::Communicate(const Message& input, Message* output,
wait_result < WAIT_OBJECT_0 + handle_count) { wait_result < WAIT_OBJECT_0 + handle_count) {
signaled_handle = handles[wait_result - WAIT_OBJECT_0]; signaled_handle = handles[wait_result - WAIT_OBJECT_0];
} else if (wait_result == WAIT_FAILED) { } else if (wait_result == WAIT_FAILED) {
GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: " GOOGLE_ABSL_LOG(FATAL) << "WaitForMultipleObjects: "
<< Win32ErrorMessage(GetLastError()); << Win32ErrorMessage(GetLastError());
} else { } else {
GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: " GOOGLE_ABSL_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: "
<< wait_result; << wait_result;
} }
if (signaled_handle == child_stdin_) { if (signaled_handle == child_stdin_) {
@ -246,17 +247,17 @@ bool Subprocess::Communicate(const Message& input, Message* output,
DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE); DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
if (wait_result == WAIT_FAILED) { if (wait_result == WAIT_FAILED) {
GOOGLE_LOG(FATAL) << "WaitForSingleObject: " GOOGLE_ABSL_LOG(FATAL) << "WaitForSingleObject: "
<< Win32ErrorMessage(GetLastError()); << Win32ErrorMessage(GetLastError());
} else if (wait_result != WAIT_OBJECT_0) { } else if (wait_result != WAIT_OBJECT_0) {
GOOGLE_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: " GOOGLE_ABSL_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: "
<< wait_result; << wait_result;
} }
DWORD exit_code; DWORD exit_code;
if (!GetExitCodeProcess(child_handle_, &exit_code)) { if (!GetExitCodeProcess(child_handle_, &exit_code)) {
GOOGLE_LOG(FATAL) << "GetExitCodeProcess: " GOOGLE_ABSL_LOG(FATAL) << "GetExitCodeProcess: "
<< Win32ErrorMessage(GetLastError()); << Win32ErrorMessage(GetLastError());
} }
CloseHandleOrDie(child_handle_); CloseHandleOrDie(child_handle_);
@ -325,14 +326,14 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
int stdin_pipe[2]; int stdin_pipe[2];
int stdout_pipe[2]; int stdout_pipe[2];
GOOGLE_CHECK(pipe(stdin_pipe) != -1); GOOGLE_ABSL_CHECK(pipe(stdin_pipe) != -1);
GOOGLE_CHECK(pipe(stdout_pipe) != -1); GOOGLE_ABSL_CHECK(pipe(stdout_pipe) != -1);
char* argv[2] = {portable_strdup(program.c_str()), nullptr}; char* argv[2] = {portable_strdup(program.c_str()), nullptr};
child_pid_ = fork(); child_pid_ = fork();
if (child_pid_ == -1) { if (child_pid_ == -1) {
GOOGLE_LOG(FATAL) << "fork: " << strerror(errno); GOOGLE_ABSL_LOG(FATAL) << "fork: " << strerror(errno);
} else if (child_pid_ == 0) { } else if (child_pid_ == 0) {
// We are the child. // We are the child.
dup2(stdin_pipe[0], STDIN_FILENO); dup2(stdin_pipe[0], STDIN_FILENO);
@ -379,7 +380,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) {
bool Subprocess::Communicate(const Message& input, Message* output, bool Subprocess::Communicate(const Message& input, Message* output,
std::string* error) { std::string* error) {
GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first."; GOOGLE_ABSL_CHECK_NE(child_stdin_, -1) << "Must call Start() first.";
// The "sighandler_t" typedef is GNU-specific, so define our own. // The "sighandler_t" typedef is GNU-specific, so define our own.
typedef void SignalHandler(int); typedef void SignalHandler(int);
@ -414,7 +415,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
// Interrupted by signal. Try again. // Interrupted by signal. Try again.
continue; continue;
} else { } else {
GOOGLE_LOG(FATAL) << "select: " << strerror(errno); GOOGLE_ABSL_LOG(FATAL) << "select: " << strerror(errno);
} }
} }
@ -460,7 +461,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
int status; int status;
while (waitpid(child_pid_, &status, 0) == -1) { while (waitpid(child_pid_, &status, 0) == -1) {
if (errno != EINTR) { if (errno != EINTR) {
GOOGLE_LOG(FATAL) << "waitpid: " << strerror(errno); GOOGLE_ABSL_LOG(FATAL) << "waitpid: " << strerror(errno);
} }
} }

Loading…
Cancel
Save