Skip to content

Commit b35780e

Browse files
committed
Use ABSL_LOG macros over LOG macros
LOG causes macro pollution and conflicts with ProxyWasm SDK (see proxy-wasm/proxy-wasm-cpp-sdk#154). PiperOrigin-RevId: 533164114
1 parent 51bbf36 commit b35780e

16 files changed

+39
-40
lines changed

eval/compiler/flat_expr_builder_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ TEST(FlatExprBuilderTest, CustomDescriptorPoolForSelect) {
19731973
std::pair<google::protobuf::Message*, const google::protobuf::Reflection*> CreateTestMessage(
19741974
const google::protobuf::DescriptorPool& descriptor_pool,
19751975
google::protobuf::MessageFactory& message_factory, absl::string_view name) {
1976-
const google::protobuf::Descriptor* desc = descriptor_pool.FindMessageTypeByName(std::string(name));
1976+
const google::protobuf::Descriptor* desc = descriptor_pool.FindMessageTypeByName(name);
19771977
const google::protobuf::Message* message_prototype = message_factory.GetPrototype(desc);
19781978
google::protobuf::Message* message = message_prototype->New();
19791979
const google::protobuf::Reflection* refl = message->GetReflection();

eval/internal/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ cc_library(
3535
"//internal:status_macros",
3636
"@com_google_absl//absl/base:core_headers",
3737
"@com_google_absl//absl/container:flat_hash_map",
38-
"@com_google_absl//absl/log",
3938
"@com_google_absl//absl/status",
4039
"@com_google_absl//absl/status:statusor",
4140
"@com_google_absl//absl/strings",

eval/internal/interop.cc

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "google/protobuf/arena.h"
2222
#include "absl/base/attributes.h"
2323
#include "absl/container/flat_hash_map.h"
24-
#include "absl/log/log.h"
2524
#include "absl/status/status.h"
2625
#include "absl/strings/str_cat.h"
2726
#include "absl/strings/string_view.h"

eval/public/BUILD

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ cc_library(
8383
"//internal:status_macros",
8484
"//internal:utf8",
8585
"@com_google_absl//absl/base:core_headers",
86-
"@com_google_absl//absl/log",
86+
"@com_google_absl//absl/log:absl_log",
8787
"@com_google_absl//absl/status",
8888
"@com_google_absl//absl/status:statusor",
8989
"@com_google_absl//absl/strings",
@@ -633,7 +633,7 @@ cc_library(
633633
deps = [
634634
":ast_visitor",
635635
":source_position",
636-
"@com_google_absl//absl/log",
636+
"@com_google_absl//absl/log:absl_log",
637637
"@com_google_absl//absl/types:variant",
638638
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_cc_proto",
639639
],
@@ -651,7 +651,7 @@ cc_library(
651651
":ast_visitor_native",
652652
":source_position_native",
653653
"//base:ast_internal",
654-
"@com_google_absl//absl/log",
654+
"@com_google_absl//absl/log:absl_log",
655655
"@com_google_absl//absl/types:variant",
656656
],
657657
)
@@ -835,7 +835,7 @@ cc_library(
835835
deps = [
836836
":ast_visitor",
837837
":source_position",
838-
"@com_google_absl//absl/log",
838+
"@com_google_absl//absl/log:absl_log",
839839
"@com_google_absl//absl/types:span",
840840
"@com_google_absl//absl/types:variant",
841841
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_cc_proto",
@@ -870,7 +870,7 @@ cc_library(
870870
deps = [
871871
":ast_visitor_native",
872872
":source_position_native",
873-
"@com_google_absl//absl/log",
873+
"@com_google_absl//absl/log:absl_log",
874874
"@com_google_absl//absl/types:span",
875875
"@com_google_absl//absl/types:variant",
876876
],

eval/public/ast_rewrite.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <vector>
1919

2020
#include "google/api/expr/v1alpha1/syntax.pb.h"
21-
#include "absl/log/log.h"
21+
#include "absl/log/absl_log.h"
2222
#include "absl/types/variant.h"
2323
#include "eval/public/ast_visitor.h"
2424
#include "eval/public/source_position.h"
@@ -196,7 +196,7 @@ struct PostVisitor {
196196
case Expr::EXPR_KIND_NOT_SET:
197197
break;
198198
default:
199-
LOG(ERROR) << "Unsupported Expr kind: " << expr->expr_kind_case();
199+
ABSL_LOG(ERROR) << "Unsupported Expr kind: " << expr->expr_kind_case();
200200
}
201201

202202
visitor->PostVisitExpr(expr, &position);

eval/public/ast_rewrite_native.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stack>
1818
#include <vector>
1919

20-
#include "absl/log/log.h"
20+
#include "absl/log/absl_log.h"
2121
#include "absl/types/variant.h"
2222
#include "eval/public/ast_visitor_native.h"
2323
#include "eval/public/source_position_native.h"
@@ -199,7 +199,7 @@ struct PostVisitor {
199199
visitor->PostVisitComprehension(&comprehension, expr, position);
200200
}
201201
void operator()(absl::monostate) {
202-
LOG(ERROR) << "Unsupported Expr kind";
202+
ABSL_LOG(ERROR) << "Unsupported Expr kind";
203203
}
204204
} handler{visitor, record.expr, &position};
205205
absl::visit(handler, record.expr->expr_kind());

eval/public/ast_traverse.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stack>
1818

1919
#include "google/api/expr/v1alpha1/syntax.pb.h"
20-
#include "absl/log/log.h"
20+
#include "absl/log/absl_log.h"
2121
#include "absl/types/variant.h"
2222
#include "eval/public/ast_visitor.h"
2323
#include "eval/public/source_position.h"
@@ -197,7 +197,7 @@ struct PostVisitor {
197197
&position);
198198
break;
199199
default:
200-
LOG(ERROR) << "Unsupported Expr kind: " << expr->expr_kind_case();
200+
ABSL_LOG(ERROR) << "Unsupported Expr kind: " << expr->expr_kind_case();
201201
}
202202

203203
visitor->PostVisitExpr(expr, &position);

eval/public/ast_traverse_native.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <stack>
1818

19-
#include "absl/log/log.h"
19+
#include "absl/log/absl_log.h"
2020
#include "absl/types/variant.h"
2121
#include "base/ast_internal.h"
2222
#include "eval/public/ast_visitor_native.h"
@@ -174,7 +174,7 @@ struct PostVisitor {
174174
&position);
175175
}
176176
void operator()(absl::monostate) {
177-
LOG(ERROR) << "Unsupported Expr kind";
177+
ABSL_LOG(ERROR) << "Unsupported Expr kind";
178178
}
179179
} handler{visitor, record.expr,
180180
SourcePosition(expr->id(), record.source_info)};

eval/public/builtin_func_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BuiltinsTest : public ::testing::Test {
6969
Expr expr;
7070
SourceInfo source_info;
7171
auto call = expr.mutable_call_expr();
72-
call->set_function(operation.data(), operation.size());
72+
call->set_function(operation);
7373

7474
if (target.has_value()) {
7575
std::string param_name = "target";

eval/public/cel_value.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "absl/base/attributes.h"
2626
#include "absl/base/macros.h"
2727
#include "absl/base/optimization.h"
28-
#include "absl/log/log.h"
28+
#include "absl/log/absl_log.h"
2929
#include "absl/status/status.h"
3030
#include "absl/status/statusor.h"
3131
#include "absl/strings/str_cat.h"
@@ -489,7 +489,8 @@ class CelValue {
489489

490490
// Crashes with a null pointer error.
491491
static void CrashNullPointer(Type type) ABSL_ATTRIBUTE_COLD {
492-
LOG(FATAL) << "Null pointer supplied for " << TypeName(type); // Crash ok
492+
ABSL_LOG(FATAL) << "Null pointer supplied for "
493+
<< TypeName(type); // Crash ok
493494
}
494495

495496
// Null pointer checker for pointer-based types.
@@ -502,9 +503,9 @@ class CelValue {
502503
// Crashes with a type mismatch error.
503504
static void CrashTypeMismatch(Type requested_type,
504505
Type actual_type) ABSL_ATTRIBUTE_COLD {
505-
LOG(FATAL) << "Type mismatch" // Crash ok
506-
<< ": expected " << TypeName(requested_type) // Crash ok
507-
<< ", encountered " << TypeName(actual_type); // Crash ok
506+
ABSL_LOG(FATAL) << "Type mismatch" // Crash ok
507+
<< ": expected " << TypeName(requested_type) // Crash ok
508+
<< ", encountered " << TypeName(actual_type); // Crash ok
508509
}
509510

510511
// Gets value of type specified

eval/public/structs/cel_proto_lite_wrap_util.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ absl::StatusOr<BytesValue*> CreateMessageFromValue(
698698
if (wrapper == nullptr) {
699699
wrapper = google::protobuf::Arena::CreateMessage<BytesValue>(arena);
700700
}
701-
wrapper->set_value(view_val.value().data(), view_val.value().size());
701+
wrapper->set_value(view_val.value());
702702
return wrapper;
703703
}
704704

@@ -782,7 +782,7 @@ absl::StatusOr<StringValue*> CreateMessageFromValue(
782782
if (wrapper == nullptr) {
783783
wrapper = google::protobuf::Arena::CreateMessage<StringValue>(arena);
784784
}
785-
wrapper->set_value(view_val.value().data(), view_val.value().size());
785+
wrapper->set_value(view_val.value());
786786
return wrapper;
787787
}
788788

@@ -950,7 +950,7 @@ absl::StatusOr<Value*> CreateMessageFromValue(
950950
case CelValue::Type::kString: {
951951
CelValue::StringHolder val;
952952
if (cel_value.GetValue(&val)) {
953-
wrapper->set_string_value(val.value().data(), val.value().size());
953+
wrapper->set_string_value(val.value());
954954
}
955955
} break;
956956
case CelValue::Type::kTimestamp: {

eval/public/structs/cel_proto_wrap_util.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ google::protobuf::Message* MessageFromValue(
468468
if (!value.GetValue(&view_val)) {
469469
return nullptr;
470470
}
471-
wrapper->set_value(view_val.value().data(), view_val.value().size());
471+
wrapper->set_value(view_val.value());
472472
return wrapper;
473473
}
474474

@@ -536,7 +536,7 @@ google::protobuf::Message* MessageFromValue(
536536
if (!value.GetValue(&view_val)) {
537537
return nullptr;
538538
}
539-
wrapper->set_value(view_val.value().data(), view_val.value().size());
539+
wrapper->set_value(view_val.value());
540540
return wrapper;
541541
}
542542

@@ -682,7 +682,7 @@ google::protobuf::Message* MessageFromValue(const CelValue& value, Value* json,
682682
case CelValue::Type::kString: {
683683
CelValue::StringHolder val;
684684
if (value.GetValue(&val)) {
685-
json->set_string_value(val.value().data(), val.value().size());
685+
json->set_string_value(val.value());
686686
return json;
687687
}
688688
} break;

eval/public/structs/field_access_impl_test.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ class SingleFieldTest : public testing::TestWithParam<AccessFieldTestParam> {
184184
TEST_P(SingleFieldTest, Getter) {
185185
TestAllTypes test_message;
186186
ASSERT_TRUE(
187-
google::protobuf::TextFormat::ParseFromString(std::string(message_textproto()), &test_message));
187+
google::protobuf::TextFormat::ParseFromString(message_textproto(), &test_message));
188188
google::protobuf::Arena arena;
189189

190190
ASSERT_OK_AND_ASSIGN(
191191
CelValue accessed_value,
192192
CreateValueFromSingleField(
193193
&test_message,
194-
test_message.GetDescriptor()->FindFieldByName(std::string(field_name())),
194+
test_message.GetDescriptor()->FindFieldByName(field_name()),
195195
ProtoWrapperTypeOptions::kUnsetProtoDefault,
196196
&CelProtoWrapper::InternalWrapMessage, &arena));
197197

@@ -204,7 +204,7 @@ TEST_P(SingleFieldTest, Setter) {
204204
google::protobuf::Arena arena;
205205

206206
ASSERT_OK(SetValueToSingleField(
207-
to_set, test_message.GetDescriptor()->FindFieldByName(std::string(field_name())),
207+
to_set, test_message.GetDescriptor()->FindFieldByName(field_name()),
208208
&test_message, &arena));
209209

210210
EXPECT_THAT(test_message, EqualsProto(message_textproto()));
@@ -361,14 +361,14 @@ class RepeatedFieldTest : public testing::TestWithParam<AccessFieldTestParam> {
361361
TEST_P(RepeatedFieldTest, GetFirstElem) {
362362
TestAllTypes test_message;
363363
ASSERT_TRUE(
364-
google::protobuf::TextFormat::ParseFromString(std::string(message_textproto()), &test_message));
364+
google::protobuf::TextFormat::ParseFromString(message_textproto(), &test_message));
365365
google::protobuf::Arena arena;
366366

367367
ASSERT_OK_AND_ASSIGN(
368368
CelValue accessed_value,
369369
CreateValueFromRepeatedField(
370370
&test_message,
371-
test_message.GetDescriptor()->FindFieldByName(std::string(field_name())), 0,
371+
test_message.GetDescriptor()->FindFieldByName(field_name()), 0,
372372
&CelProtoWrapper::InternalWrapMessage, &arena));
373373

374374
EXPECT_THAT(accessed_value, test::EqualsCelValue(cel_value()));
@@ -380,7 +380,7 @@ TEST_P(RepeatedFieldTest, AppendElem) {
380380
google::protobuf::Arena arena;
381381

382382
ASSERT_OK(AddValueToRepeatedField(
383-
to_add, test_message.GetDescriptor()->FindFieldByName(std::string(field_name())),
383+
to_add, test_message.GetDescriptor()->FindFieldByName(field_name()),
384384
&test_message, &arena));
385385

386386
EXPECT_THAT(test_message, EqualsProto(message_textproto()));

eval/public/structs/proto_message_type_adapter.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ absl::StatusOr<bool> HasFieldImpl(const google::protobuf::Message* message,
8686
absl::string_view field_name) {
8787
ABSL_ASSERT(descriptor == message->GetDescriptor());
8888
const Reflection* reflection = message->GetReflection();
89-
const FieldDescriptor* field_desc = descriptor->FindFieldByName(std::string(field_name));
89+
const FieldDescriptor* field_desc = descriptor->FindFieldByName(field_name);
9090
if (field_desc == nullptr && reflection != nullptr) {
9191
// Search to see whether the field name is referring to an extension.
9292
field_desc = reflection->FindKnownExtensionByName(field_name);
@@ -122,7 +122,7 @@ absl::StatusOr<CelValue> GetFieldImpl(const google::protobuf::Message* message,
122122
cel::MemoryManager& memory_manager) {
123123
ABSL_ASSERT(descriptor == message->GetDescriptor());
124124
const Reflection* reflection = message->GetReflection();
125-
const FieldDescriptor* field_desc = descriptor->FindFieldByName(std::string(field_name));
125+
const FieldDescriptor* field_desc = descriptor->FindFieldByName(field_name);
126126
if (field_desc == nullptr && reflection != nullptr) {
127127
std::string ext_name(field_name);
128128
field_desc = reflection->FindKnownExtensionByName(ext_name);
@@ -332,7 +332,7 @@ ProtoMessageTypeAdapter::NewInstance(cel::MemoryManager& memory_manager) const {
332332
}
333333

334334
bool ProtoMessageTypeAdapter::DefinesField(absl::string_view field_name) const {
335-
return descriptor_->FindFieldByName(std::string(field_name)) != nullptr;
335+
return descriptor_->FindFieldByName(field_name) != nullptr;
336336
}
337337

338338
absl::StatusOr<bool> ProtoMessageTypeAdapter::HasField(
@@ -365,7 +365,7 @@ absl::Status ProtoMessageTypeAdapter::SetField(
365365
UnwrapMessage(instance, "SetField"));
366366

367367
const google::protobuf::FieldDescriptor* field_descriptor =
368-
descriptor_->FindFieldByName(std::string(field_name));
368+
descriptor_->FindFieldByName(field_name);
369369
CEL_RETURN_IF_ERROR(
370370
ValidateSetFieldOp(field_descriptor != nullptr, field_name, "not found"));
371371

eval/public/structs/protobuf_descriptor_type_provider.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ProtobufDescriptorProvider::ProvideLegacyTypeInfo(
5353
std::unique_ptr<ProtoMessageTypeAdapter> ProtobufDescriptorProvider::GetType(
5454
absl::string_view name) const {
5555
const google::protobuf::Descriptor* descriptor =
56-
descriptor_pool_->FindMessageTypeByName(std::string(name));
56+
descriptor_pool_->FindMessageTypeByName(name);
5757
if (descriptor == nullptr) {
5858
return nullptr;
5959
}

extensions/protobuf/type_provider.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace cel::extensions {
2323
absl::StatusOr<absl::optional<Handle<Type>>> ProtoTypeProvider::ProvideType(
2424
TypeFactory& type_factory, absl::string_view name) const {
2525
{
26-
const auto* desc = pool_->FindMessageTypeByName(std::string(name));
26+
const auto* desc = pool_->FindMessageTypeByName(name);
2727
if (desc != nullptr) {
2828
return type_factory.CreateStructType<ProtoStructType>(desc, factory_);
2929
}

0 commit comments

Comments
 (0)