Convert CHECK macro to ABSL_CHECK.

Chrome can't use Absl's CHECK because of collisions with its own version.

PiperOrigin-RevId: 561740965
This commit is contained in:
MediaPipe Team
2023-08-31 13:20:29 -07:00
committed by Copybara-Service
parent 30802b80cd
commit 7c2d654d67
262 changed files with 1881 additions and 1474 deletions
+11 -3
View File
@@ -142,6 +142,7 @@ cc_library(
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/port:map_util",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
@@ -167,6 +168,7 @@ cc_test(
":executor_util",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
"@com_google_absl//absl/log:absl_check",
],
)
@@ -283,6 +285,7 @@ cc_binary(
"//mediapipe/framework/port:logging",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
],
)
@@ -366,6 +369,7 @@ cc_library(
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:statusor",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
],
)
@@ -405,8 +409,8 @@ cc_library(
"//mediapipe/framework/port:source_location",
"//mediapipe/framework/port:status",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
@@ -460,6 +464,7 @@ cc_library(
deps = [
"//mediapipe/framework/port:status",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
],
)
@@ -512,8 +517,8 @@ cc_library(
"//mediapipe/framework/port:numbers",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
],
)
@@ -539,6 +544,7 @@ cc_library(
"//mediapipe/framework/port:status",
"@com_google_absl//absl/base:core_headers",
"@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/memory",
"@com_google_absl//absl/strings",
@@ -674,6 +680,7 @@ cc_library(
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:threadpool",
"//mediapipe/util:cpu_util",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
],
@@ -797,8 +804,8 @@ cc_library(
"//mediapipe/framework/port:status",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
@@ -932,6 +939,7 @@ cc_library(
"//mediapipe/framework/port:core_proto",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
],
alwayslink = 1,
@@ -4,6 +4,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/absl_check.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
@@ -118,14 +119,14 @@ class DescriptorReader {
static FileDescriptorSet ReadFileDescriptorSet(const std::string& path) {
std::string contents;
CHECK_OK(file::GetContents(path, &contents));
ABSL_CHECK_OK(file::GetContents(path, &contents));
proto_ns::FileDescriptorSet result;
result.ParseFromString(contents);
return result;
}
static void WriteFile(const std::string& path, const std::string& contents) {
CHECK_OK(file::SetContents(path, contents));
ABSL_CHECK_OK(file::SetContents(path, contents));
}
static void WriteMessageTypeName(const std::string& path,
+2 -1
View File
@@ -16,6 +16,7 @@
#include <tuple>
#include "absl/log/absl_check.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
@@ -411,7 +412,7 @@ static absl::Status DeserializeValue(const FieldValue& bytes,
}
case W::TYPE_GROUP:
case W::TYPE_MESSAGE:
CHECK(false) << "DeserializeValue cannot deserialize a Message.";
ABSL_CHECK(false) << "DeserializeValue cannot deserialize a Message.";
case W::TYPE_UINT32:
return ReadPrimitive<uint32_t, W::TYPE_UINT32>(&input, result);
case W::TYPE_ENUM:
+16 -16
View File
@@ -27,8 +27,8 @@
#include <utility>
#include <vector>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
@@ -75,8 +75,8 @@ REGISTER_CALCULATOR(MediaPipeInternalSidePacketToPacketStreamCalculator);
void AddVectorSink(const std::string& stream_name, //
CalculatorGraphConfig* config, //
std::vector<Packet>* dumped_data) {
CHECK(config);
CHECK(dumped_data);
ABSL_CHECK(config);
ABSL_CHECK(dumped_data);
std::string input_side_packet_name;
tool::AddCallbackCalculator(stream_name, config, &input_side_packet_name,
@@ -95,15 +95,15 @@ void AddVectorSink(const std::string& stream_name, //
// Up to 64-bit pointer in hex (16 characters) and an optional "0x" prepended.
char address[19];
int written = snprintf(address, sizeof(address), "%p", dumped_data);
CHECK(written > 0 && written < sizeof(address));
ABSL_CHECK(written > 0 && written < sizeof(address));
options->set_pointer(address);
}
void AddPostStreamPacketSink(const std::string& stream_name,
CalculatorGraphConfig* config,
Packet* post_stream_packet) {
CHECK(config);
CHECK(post_stream_packet);
ABSL_CHECK(config);
ABSL_CHECK(post_stream_packet);
std::string input_side_packet_name;
tool::AddCallbackCalculator(stream_name, config, &input_side_packet_name,
@@ -121,14 +121,14 @@ void AddPostStreamPacketSink(const std::string& stream_name,
// Up to 64-bit pointer in hex (16 characters) and an optional "0x" prepended.
char address[19];
int written = snprintf(address, sizeof(address), "%p", post_stream_packet);
CHECK(written > 0 && written < sizeof(address));
ABSL_CHECK(written > 0 && written < sizeof(address));
options->set_pointer(address);
}
void AddSidePacketSink(const std::string& side_packet_name,
CalculatorGraphConfig* config, Packet* dumped_packet) {
CHECK(config);
CHECK(dumped_packet);
ABSL_CHECK(config);
ABSL_CHECK(dumped_packet);
CalculatorGraphConfig::Node* conversion_node = config->add_node();
const std::string node_name = GetUnusedNodeName(
@@ -150,8 +150,8 @@ void AddCallbackCalculator(const std::string& stream_name,
CalculatorGraphConfig* config,
std::string* callback_side_packet_name,
bool use_std_function) {
CHECK(config);
CHECK(callback_side_packet_name);
ABSL_CHECK(config);
ABSL_CHECK(callback_side_packet_name);
CalculatorGraphConfig::Node* sink_node = config->add_node();
sink_node->set_name(GetUnusedNodeName(
*config,
@@ -187,8 +187,8 @@ void AddMultiStreamCallback(
std::function<void(const std::vector<Packet>&)> callback,
CalculatorGraphConfig* config, std::map<std::string, Packet>* side_packets,
bool observe_timestamp_bounds) {
CHECK(config);
CHECK(side_packets);
ABSL_CHECK(config);
ABSL_CHECK(side_packets);
CalculatorGraphConfig::Node* sink_node = config->add_node();
const std::string name = GetUnusedNodeName(
*config, absl::StrCat("multi_callback_", absl::StrJoin(streams, "_")));
@@ -222,8 +222,8 @@ void AddCallbackWithHeaderCalculator(const std::string& stream_name,
CalculatorGraphConfig* config,
std::string* callback_side_packet_name,
bool use_std_function) {
CHECK(config);
CHECK(callback_side_packet_name);
ABSL_CHECK(config);
ABSL_CHECK(callback_side_packet_name);
CalculatorGraphConfig::Node* sink_node = config->add_node();
sink_node->set_name(GetUnusedNodeName(
*config,
@@ -331,7 +331,7 @@ absl::Status CallbackWithHeaderCalculator::GetContract(CalculatorContract* cc) {
cc->Inputs().Tag("HEADER").SetAny();
if (cc->InputSidePackets().UsesTags()) {
CHECK(cc->InputSidePackets().HasTag("CALLBACK"));
ABSL_CHECK(cc->InputSidePackets().HasTag("CALLBACK"));
cc->InputSidePackets()
.Tag("CALLBACK")
.Set<std::function<void(const Packet&, const Packet&)>>();
+3 -3
View File
@@ -68,9 +68,9 @@ namespace tool {
// // Call tool::AddVectorSink() more times if you wish. Note that each stream
// // needs to get its own packet vector.
// CalculatorGraph graph;
// CHECK_OK(graph.Initialize(config));
// ABSL_CHECK_OK(graph.Initialize(config));
// // Set other input side packets.
// CHECK_OK(graph.Run());
// ABSL_CHECK_OK(graph.Run());
// for (const Packet& packet : packet_dump) {
// // Do something.
// }
@@ -160,7 +160,7 @@ void AddCallbackWithHeaderCalculator(const std::string& stream_name,
// tool::AddCallbackCalculator("the_output_stream", &config,
// &input_side_packet_name, true);
// CalculatorGraph graph(config);
// CHECK_OK(graph.Run(
// ABSL_CHECK_OK(graph.Run(
// {{input_side_packet_name,
// MakePacket<std::function<void(const Packet&)>>(
// std::bind(&MyClass::MyFunction, this, std::placeholders::_1))}}
+1
View File
@@ -16,6 +16,7 @@
#include <vector>
#include "absl/log/absl_check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
+6 -5
View File
@@ -20,6 +20,7 @@
#include <utility>
#include <vector>
#include "absl/log/absl_check.h"
#include "absl/strings/str_cat.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/calculator_framework.h"
@@ -148,7 +149,7 @@ void ClearContainerOptions(CalculatorGraphConfig::Node* dest) {
// Returns an unused name similar to a specified name.
std::string UniqueName(std::string name, std::set<std::string>* names) {
CHECK(names != nullptr);
ABSL_CHECK(names != nullptr);
std::string result = name;
int suffix = 2;
while (names->count(result) > 0) {
@@ -161,7 +162,7 @@ std::string UniqueName(std::string name, std::set<std::string>* names) {
// Parses tag, index, and name from a list of stream identifiers.
void ParseTags(const proto_ns::RepeatedPtrField<std::string>& streams,
std::map<TagIndex, std::string>* result) {
CHECK(result != nullptr);
ABSL_CHECK(result != nullptr);
std::set<std::string> used_names;
int used_index = -1;
for (const std::string& stream : streams) {
@@ -177,14 +178,14 @@ void ParseTags(const proto_ns::RepeatedPtrField<std::string>& streams,
// Removes the entry for a tag and index from a map.
void EraseTag(const std::string& stream,
std::map<TagIndex, std::string>* streams) {
CHECK(streams != nullptr);
ABSL_CHECK(streams != nullptr);
streams->erase(ParseTagIndexFromStream(absl::StrCat(stream, ":u")));
}
// Removes the entry for a tag and index from a list.
void EraseTag(const std::string& stream,
proto_ns::RepeatedPtrField<std::string>* streams) {
CHECK(streams != nullptr);
ABSL_CHECK(streams != nullptr);
TagIndex stream_tag = ParseTagIndexFromStream(absl::StrCat(stream, ":u"));
for (int i = streams->size() - 1; i >= 0; --i) {
TagIndex tag = ParseTagIndexFromStream(streams->at(i));
@@ -197,7 +198,7 @@ void EraseTag(const std::string& stream,
// Returns the stream names for the container node.
void GetContainerNodeStreams(const CalculatorGraphConfig::Node& node,
CalculatorGraphConfig::Node* result) {
CHECK(result != nullptr);
ABSL_CHECK(result != nullptr);
*result->mutable_input_stream() = node.input_stream();
*result->mutable_output_stream() = node.output_stream();
*result->mutable_input_side_packet() = node.input_side_packet();
@@ -19,8 +19,8 @@
#include <string>
#include <vector>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/log/check.h"
#include "absl/strings/ascii.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
@@ -179,7 +179,8 @@ FieldType GetFieldType(const TemplateExpression& rule) {
int FieldCount(const FieldValue& base, ProtoPath field_path,
FieldType field_type) {
int result = 0;
CHECK_OK(ProtoUtilLite::GetFieldCount(base, field_path, field_type, &result));
ABSL_CHECK_OK(
ProtoUtilLite::GetFieldCount(base, field_path, field_type, &result));
return result;
}
@@ -642,7 +643,7 @@ class TemplateExpanderImpl {
for (int i = 0; i < args.size(); ++i) {
if (args[i].has_dict()) {
FieldValue dict_bytes;
CHECK(args[i].dict().SerializePartialToString(&dict_bytes));
ABSL_CHECK(args[i].dict().SerializePartialToString(&dict_bytes));
result->push_back(dict_bytes);
} else if (args[i].has_num() || args[i].has_str()) {
std::string text_value = args[i].has_num()
+6 -4
View File
@@ -21,6 +21,7 @@
#include <vector>
#include "absl/container/flat_hash_set.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/memory/memory.h"
#include "absl/strings/ascii.h"
@@ -565,7 +566,8 @@ class TemplateParser::Parser::ParserImpl {
// Skips unknown or reserved fields.
if (field == NULL) {
CHECK(allow_unknown_field_ || allow_unknown_extension_ || reserved_field);
ABSL_CHECK(allow_unknown_field_ || allow_unknown_extension_ ||
reserved_field);
// Try to guess the type of this field.
// If this field is not a message, there should be a ":" between the
@@ -1397,7 +1399,7 @@ bool DeterministicallySerialize(const Message& proto, std::string* result) {
void SerializeField(const Message* message, const FieldDescriptor* field,
std::vector<ProtoUtilLite::FieldValue>* result) {
ProtoUtilLite::FieldValue message_bytes;
CHECK(DeterministicallySerialize(*message, &message_bytes));
ABSL_CHECK(DeterministicallySerialize(*message, &message_bytes));
ProtoUtilLite::FieldAccess access(
field->number(), static_cast<ProtoUtilLite::FieldType>(field->type()));
MEDIAPIPE_CHECK_OK(access.SetMessage(message_bytes));
@@ -1702,13 +1704,13 @@ class TemplateParser::Parser::MediaPipeParserImpl
const std::vector<ProtoUtilLite::FieldValue>& args) {
auto field_type = static_cast<ProtoUtilLite::FieldType>(field->type());
ProtoUtilLite::FieldValue message_bytes;
CHECK(message->SerializePartialToString(&message_bytes));
ABSL_CHECK(message->SerializePartialToString(&message_bytes));
int count;
MEDIAPIPE_CHECK_OK(ProtoUtilLite::GetFieldCount(
message_bytes, {{field->number(), 0}}, field_type, &count));
MEDIAPIPE_CHECK_OK(ProtoUtilLite::ReplaceFieldRange(
&message_bytes, {{field->number(), count}}, 0, field_type, args));
CHECK(message->ParsePartialFromString(message_bytes));
ABSL_CHECK(message->ParsePartialFromString(message_bytes));
}
// Parse and record a template definition for the current field path.
+6 -6
View File
@@ -22,8 +22,8 @@
#include "absl/cleanup/cleanup.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "absl/log/check.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
@@ -60,8 +60,8 @@ absl::Status CompareDiff(const ImageFrame& image1, const ImageFrame& image2,
const float max_avg_diff,
std::unique_ptr<ImageFrame>& diff_image) {
// Verify image byte depth matches expected byte depth.
CHECK_EQ(sizeof(T), image1.ByteDepth());
CHECK_EQ(sizeof(T), image2.ByteDepth());
ABSL_CHECK_EQ(sizeof(T), image1.ByteDepth());
ABSL_CHECK_EQ(sizeof(T), image2.ByteDepth());
const int width = image1.Width();
const int height = image1.Height();
@@ -72,8 +72,8 @@ absl::Status CompareDiff(const ImageFrame& image1, const ImageFrame& image2,
const int num_channels = std::min(channels1, channels2);
// Verify the width steps are multiples of byte depth.
CHECK_EQ(image1.WidthStep() % image1.ByteDepth(), 0);
CHECK_EQ(image2.WidthStep() % image2.ByteDepth(), 0);
ABSL_CHECK_EQ(image1.WidthStep() % image1.ByteDepth(), 0);
ABSL_CHECK_EQ(image2.WidthStep() % image2.ByteDepth(), 0);
const int width_padding1 =
image1.WidthStep() / image1.ByteDepth() - width * channels1;
const int width_padding2 =
@@ -144,7 +144,7 @@ absl::Status CompareDiff(const ImageFrame& image1, const ImageFrame& image2,
std::string GetBinaryDirectory() {
char full_path[PATH_MAX + 1];
int length = readlink("/proc/self/exe", full_path, PATH_MAX + 1);
CHECK_GT(length, 0);
ABSL_CHECK_GT(length, 0);
return std::string(
::mediapipe::file::Dirname(absl::string_view(full_path, length)));
}
+2 -1
View File
@@ -18,6 +18,7 @@
#include <memory>
#include <vector>
#include "absl/log/absl_check.h"
#include "absl/strings/str_cat.h"
#include "mediapipe/framework/calculator_contract.h"
#include "mediapipe/framework/calculator_framework.h"
@@ -78,7 +79,7 @@ absl::Status RunGenerateAndValidateTypes(
const PacketGeneratorOptions& extendable_options,
const PacketSet& input_side_packets, PacketSet* output_side_packets,
const std::string& package) {
CHECK(output_side_packets);
ABSL_CHECK(output_side_packets);
// Get static access to functions.
ASSIGN_OR_RETURN(
auto static_access,