From 42f39acdf941b16920ad31de3110663904c87e36 Mon Sep 17 00:00:00 2001 From: kuat Date: Thu, 18 May 2023 19:39:53 +0000 Subject: [PATCH] Fix the remaining usages of LOG macro. Add "unused" attribute to public headers. PiperOrigin-RevId: 533217495 --- eval/compiler/constant_folding.cc | 2 +- eval/eval/evaluator_core.cc | 6 +++--- eval/eval/evaluator_stack.h | 16 ++++++++-------- eval/eval/select_step.cc | 2 +- eval/public/cel_expr_builder_factory.cc | 8 ++++---- eval/public/portable_cel_expr_builder_factory.cc | 4 ++-- eval/public/structs/field_access_impl.cc | 2 +- eval/public/structs/legacy_type_provider.h | 5 +++-- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/eval/compiler/constant_folding.cc b/eval/compiler/constant_folding.cc index 6ddf660b7..db7b6f7e0 100644 --- a/eval/compiler/constant_folding.cc +++ b/eval/compiler/constant_folding.cc @@ -359,7 +359,7 @@ class ConstantFoldingTransform { } bool operator()(absl::monostate) { - LOG(ERROR) << "Unsupported Expr kind"; + ABSL_LOG(ERROR) << "Unsupported Expr kind"; return false; } diff --git a/eval/eval/evaluator_core.cc b/eval/eval/evaluator_core.cc index a35986c3c..9e0683b5e 100644 --- a/eval/eval/evaluator_core.cc +++ b/eval/eval/evaluator_core.cc @@ -51,7 +51,7 @@ const ExpressionStep* ExecutionFrame::Next() { if (pc_ < end_pos) return execution_path_[pc_++].get(); if (pc_ > end_pos) { - LOG(ERROR) << "Attempting to step beyond the end of execution path."; + ABSL_LOG(ERROR) << "Attempting to step beyond the end of execution path."; } return nullptr; } @@ -167,8 +167,8 @@ absl::StatusOr> ExecutionFrame::Evaluate( } if (value_stack().empty()) { - LOG(ERROR) << "Stack is empty after a ExpressionStep.Evaluate. " - "Try to disable short-circuiting."; + ABSL_LOG(ERROR) << "Stack is empty after a ExpressionStep.Evaluate. " + "Try to disable short-circuiting."; continue; } CEL_RETURN_IF_ERROR( diff --git a/eval/eval/evaluator_stack.h b/eval/eval/evaluator_stack.h index 63ace19fb..b7f8f5420 100644 --- a/eval/eval/evaluator_stack.h +++ b/eval/eval/evaluator_stack.h @@ -46,8 +46,8 @@ class EvaluatorStack { // Please note that calls to Push may invalidate returned Span object. absl::Span> GetSpan(size_t size) const { if (!HasEnough(size)) { - LOG(ERROR) << "Requested span size (" << size - << ") exceeds current stack size: " << current_size_; + ABSL_LOG(ERROR) << "Requested span size (" << size + << ") exceeds current stack size: " << current_size_; } return absl::Span>( stack_.data() + current_size_ - size, size); @@ -65,7 +65,7 @@ class EvaluatorStack { // Checking that stack is not empty is caller's responsibility. const cel::Handle& Peek() const { if (empty()) { - LOG(ERROR) << "Peeking on empty EvaluatorStack"; + ABSL_LOG(ERROR) << "Peeking on empty EvaluatorStack"; } return stack_[current_size_ - 1]; } @@ -74,7 +74,7 @@ class EvaluatorStack { // Checking that stack is not empty is caller's responsibility. const AttributeTrail& PeekAttribute() const { if (empty()) { - LOG(ERROR) << "Peeking on empty EvaluatorStack"; + ABSL_LOG(ERROR) << "Peeking on empty EvaluatorStack"; } return attribute_stack_[current_size_ - 1]; } @@ -83,8 +83,8 @@ class EvaluatorStack { // Checking that stack has enough elements is caller's responsibility. void Pop(size_t size) { if (!HasEnough(size)) { - LOG(ERROR) << "Trying to pop more elements (" << size - << ") than the current stack size: " << current_size_; + ABSL_LOG(ERROR) << "Trying to pop more elements (" << size + << ") than the current stack size: " << current_size_; } while (size > 0) { stack_.pop_back(); @@ -101,7 +101,7 @@ class EvaluatorStack { void Push(cel::Handle value, AttributeTrail attribute) { if (current_size_ >= max_size()) { - LOG(ERROR) << "No room to push more elements on to EvaluatorStack"; + ABSL_LOG(ERROR) << "No room to push more elements on to EvaluatorStack"; } stack_.push_back(std::move(value)); attribute_stack_.push_back(std::move(attribute)); @@ -118,7 +118,7 @@ class EvaluatorStack { // Checking that stack is not empty is caller's responsibility. void PopAndPush(cel::Handle value, AttributeTrail attribute) { if (empty()) { - LOG(ERROR) << "Cannot PopAndPush on empty stack."; + ABSL_LOG(ERROR) << "Cannot PopAndPush on empty stack."; } stack_[current_size_ - 1] = std::move(value); attribute_stack_[current_size_ - 1] = std::move(attribute); diff --git a/eval/eval/select_step.cc b/eval/eval/select_step.cc index 08635e8a4..07c0b93e5 100644 --- a/eval/eval/select_step.cc +++ b/eval/eval/select_step.cc @@ -116,7 +116,7 @@ absl::optional> CheckForMarkedAttributes( } // Invariant broken (an invalid CEL Attribute shouldn't match anything). // Log and return a CelError. - LOG(ERROR) + ABSL_LOG(ERROR) << "Invalid attribute pattern matched select path: " << attribute_string.status().ToString(); // NOLINT: OSS compatibility return CreateErrorValueFromView(Arena::Create( diff --git a/eval/public/cel_expr_builder_factory.cc b/eval/public/cel_expr_builder_factory.cc index 679d60e38..b0eda9a55 100644 --- a/eval/public/cel_expr_builder_factory.cc +++ b/eval/public/cel_expr_builder_factory.cc @@ -39,13 +39,13 @@ std::unique_ptr CreateCelExpressionBuilder( google::protobuf::MessageFactory* message_factory, const InterpreterOptions& options) { if (descriptor_pool == nullptr) { - LOG(ERROR) << "Cannot pass nullptr as descriptor pool to " - "CreateCelExpressionBuilder"; + ABSL_LOG(ERROR) << "Cannot pass nullptr as descriptor pool to " + "CreateCelExpressionBuilder"; return nullptr; } if (auto s = ValidateStandardMessageTypes(*descriptor_pool); !s.ok()) { - LOG(WARNING) << "Failed to validate standard message types: " - << s.ToString(); // NOLINT: OSS compatibility + ABSL_LOG(WARNING) << "Failed to validate standard message types: " + << s.ToString(); // NOLINT: OSS compatibility return nullptr; } diff --git a/eval/public/portable_cel_expr_builder_factory.cc b/eval/public/portable_cel_expr_builder_factory.cc index f22298ea1..d920a2125 100644 --- a/eval/public/portable_cel_expr_builder_factory.cc +++ b/eval/public/portable_cel_expr_builder_factory.cc @@ -34,8 +34,8 @@ std::unique_ptr CreatePortableExprBuilder( std::unique_ptr type_provider, const InterpreterOptions& options) { if (type_provider == nullptr) { - LOG(ERROR) << "Cannot pass nullptr as type_provider to " - "CreatePortableExprBuilder"; + ABSL_LOG(ERROR) << "Cannot pass nullptr as type_provider to " + "CreatePortableExprBuilder"; return nullptr; } cel::RuntimeOptions runtime_options = ConvertToRuntimeOptions(options); diff --git a/eval/public/structs/field_access_impl.cc b/eval/public/structs/field_access_impl.cc index 16233c545..7cc64fadb 100644 --- a/eval/public/structs/field_access_impl.cc +++ b/eval/public/structs/field_access_impl.cc @@ -599,7 +599,7 @@ class ScalarFieldSetter : public FieldSetter { bool SetMessage(const Message* value) const { if (!value) { - LOG(ERROR) << "Message is NULL"; + ABSL_LOG(ERROR) << "Message is NULL"; return true; } if (value->GetDescriptor()->full_name() == diff --git a/eval/public/structs/legacy_type_provider.h b/eval/public/structs/legacy_type_provider.h index 3bb22e443..a563c73a0 100644 --- a/eval/public/structs/legacy_type_provider.h +++ b/eval/public/structs/legacy_type_provider.h @@ -46,7 +46,7 @@ class LegacyTypeProvider : public cel::TypeProvider { // created ones, the TypeInfoApis returned from this method should be the same // as the ones used in value creation. virtual absl::optional ProvideLegacyTypeInfo( - absl::string_view name) const { + ABSL_ATTRIBUTE_UNUSED absl::string_view name) const { return absl::nullopt; } @@ -61,7 +61,8 @@ class LegacyTypeProvider : public cel::TypeProvider { // TODO(issues/5): Move protobuf-Any API from top level // [Legacy]TypeProviders. virtual absl::optional - ProvideLegacyAnyPackingApis(absl::string_view name) const { + ProvideLegacyAnyPackingApis( + ABSL_ATTRIBUTE_UNUSED absl::string_view name) const { return absl::nullopt; } };