Skip to content

Commit f347557

Browse files
CEL Dev Teamkyessenov
authored andcommitted
Apply clang-tidy suggestions
PiperOrigin-RevId: 352452757
1 parent 39616cd commit f347557

23 files changed

Lines changed: 164 additions & 172 deletions

common/value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class Container : public SharedValue {
330330
}
331331
template <Value::Kind ValueKind, typename V>
332332
static Value GetValue(V&& value) {
333-
return Value::From<ValueKind>(std::move(value));
333+
return Value::From<ValueKind>(std::forward<V>(value));
334334
}
335335

336336
private:

eval/eval/attribute_trail.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AttributeTrail {
3232
AttributeTrail() : attribute_(nullptr) {}
3333
AttributeTrail(google::api::expr::v1alpha1::Expr root, google::protobuf::Arena* arena)
3434
: AttributeTrail(google::protobuf::Arena::Create<CelAttribute>(
35-
arena, root, std::vector<CelAttributeQualifier>())) {}
35+
arena, std::move(root), std::vector<CelAttributeQualifier>())) {}
3636

3737
// Creates AttributeTrail with attribute path incremented by "qualifier".
3838
AttributeTrail Step(CelAttributeQualifier qualifier,
@@ -52,7 +52,8 @@ class AttributeTrail {
5252
bool empty() const { return !attribute_; }
5353

5454
private:
55-
AttributeTrail(const CelAttribute* attribute) : attribute_(attribute) {}
55+
explicit AttributeTrail(const CelAttribute* attribute)
56+
: attribute_(attribute) {}
5657
const CelAttribute* attribute_;
5758
};
5859
} // namespace runtime

eval/eval/const_value_step.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,14 @@ absl::optional<CelValue> ConvertConstant(const Constant* const_expr) {
7575

7676
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateConstValueStep(
7777
CelValue value, int64_t expr_id, bool comes_from_ast) {
78-
std::unique_ptr<ExpressionStep> step =
79-
absl::make_unique<ConstValueStep>(value, expr_id, comes_from_ast);
80-
return std::move(step);
78+
return absl::make_unique<ConstValueStep>(value, expr_id, comes_from_ast);
8179
}
8280

8381
// Factory method for Constant(Enum value) - based Execution step
8482
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateConstValueStep(
8583
const google::protobuf::EnumValueDescriptor* value_descriptor, int64_t expr_id) {
86-
CelValue value = CelValue::CreateInt64(value_descriptor->number());
87-
88-
std::unique_ptr<ExpressionStep> step =
89-
absl::make_unique<ConstValueStep>(value, expr_id, false);
90-
return std::move(step);
84+
return absl::make_unique<ConstValueStep>(
85+
CelValue::CreateInt64(value_descriptor->number()), expr_id, false);
9186
}
9287

9388
} // namespace runtime

eval/eval/container_access_step.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ absl::Status ContainerAccessStep::Evaluate(ExecutionFrame* frame) const {
156156
// Factory method for Select - based Execution step
157157
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateContainerAccessStep(
158158
const google::api::expr::v1alpha1::Expr::Call*, int64_t expr_id) {
159-
std::unique_ptr<ExpressionStep> step =
160-
absl::make_unique<ContainerAccessStep>(expr_id);
161-
return std::move(step);
159+
return absl::make_unique<ContainerAccessStep>(expr_id);
162160
}
163161

164162
} // namespace runtime

eval/eval/create_list_step.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ absl::Status CreateListStep::Evaluate(ExecutionFrame* frame) const {
6565
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateCreateListStep(
6666
const google::api::expr::v1alpha1::Expr::CreateList* create_list_expr,
6767
int64_t expr_id) {
68-
std::unique_ptr<ExpressionStep> step = absl::make_unique<CreateListStep>(
69-
expr_id, create_list_expr->elements_size());
70-
return std::move(step);
68+
return absl::make_unique<CreateListStep>(expr_id,
69+
create_list_expr->elements_size());
7170
}
7271

7372
} // namespace runtime

eval/eval/create_struct_step.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "eval/eval/create_struct_step.h"
22

3+
#include <memory>
4+
35
#include "google/api/expr/v1alpha1/syntax.pb.h"
46
#include "absl/status/status.h"
57
#include "absl/status/statusor.h"
@@ -303,12 +305,12 @@ absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateCreateStructStep(
303305
entries.push_back({field_desc});
304306
}
305307

306-
return absl::WrapUnique<ExpressionStep>(
307-
new CreateStructStepForMessage(expr_id, desc, std::move(entries)));
308+
return std::make_unique<CreateStructStepForMessage>(expr_id, desc,
309+
std::move(entries));
308310
} else {
309311
// Make map-creating step.
310-
return absl::WrapUnique<ExpressionStep>(new CreateStructStepForMap(
311-
expr_id, create_struct_expr->entries_size()));
312+
return std::make_unique<CreateStructStepForMap>(
313+
expr_id, create_struct_expr->entries_size());
312314
}
313315
}
314316

eval/eval/function_step.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,8 @@ absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateFunctionStep(
293293
function_registry.FindLazyOverloads(name, receiver_style, args);
294294

295295
if (!lazy_overloads.empty()) {
296-
std::unique_ptr<ExpressionStep> step = absl::make_unique<LazyFunctionStep>(
297-
name, num_args, receiver_style, lazy_overloads, expr_id);
298-
return std::move(step);
296+
return absl::make_unique<LazyFunctionStep>(name, num_args, receiver_style,
297+
lazy_overloads, expr_id);
299298
}
300299

301300
auto overloads = function_registry.FindOverloads(name, receiver_style, args);
@@ -307,9 +306,8 @@ absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateFunctionStep(
307306
"No overloads provided for FunctionStep creation")));
308307
}
309308

310-
std::unique_ptr<ExpressionStep> step = absl::make_unique<EagerFunctionStep>(
311-
std::move(overloads), name, num_args, expr_id);
312-
return std::move(step);
309+
return absl::make_unique<EagerFunctionStep>(std::move(overloads), name,
310+
num_args, expr_id);
313311
}
314312

315313
} // namespace runtime

eval/eval/ident_step.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void IdentStep::DoEvaluate(ExecutionFrame* frame, CelValue* result,
4646
if (frame->enable_missing_attribute_errors() || frame->enable_unknowns()) {
4747
google::api::expr::v1alpha1::Expr expr;
4848
expr.mutable_ident_expr()->set_name(name_);
49-
*trail = AttributeTrail(expr, frame->arena());
49+
*trail = AttributeTrail(std::move(expr), frame->arena());
5050
}
5151

5252
if (frame->enable_missing_attribute_errors() && !name_.empty() &&
@@ -102,9 +102,7 @@ absl::Status IdentStep::Evaluate(ExecutionFrame* frame) const {
102102

103103
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateIdentStep(
104104
const google::api::expr::v1alpha1::Expr::Ident* ident_expr, int64_t expr_id) {
105-
std::unique_ptr<ExpressionStep> step =
106-
absl::make_unique<IdentStep>(ident_expr->name(), expr_id);
107-
return std::move(step);
105+
return absl::make_unique<IdentStep>(ident_expr->name(), expr_id);
108106
}
109107

110108
} // namespace runtime

eval/eval/jump_step.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,22 @@ class BoolCheckJumpStep : public JumpStepBase {
100100
absl::StatusOr<std::unique_ptr<JumpStepBase>> CreateCondJumpStep(
101101
bool jump_condition, bool leave_on_stack, absl::optional<int> jump_offset,
102102
int64_t expr_id) {
103-
std::unique_ptr<JumpStepBase> step = absl::make_unique<CondJumpStep>(
104-
jump_condition, leave_on_stack, jump_offset, expr_id);
105-
106-
return std::move(step);
103+
return absl::make_unique<CondJumpStep>(jump_condition, leave_on_stack,
104+
jump_offset, expr_id);
107105
}
108106

109107
// Factory method for Jump step.
110108
absl::StatusOr<std::unique_ptr<JumpStepBase>> CreateJumpStep(
111109
absl::optional<int> jump_offset, int64_t expr_id) {
112-
std::unique_ptr<JumpStepBase> step =
113-
absl::make_unique<JumpStep>(jump_offset, expr_id);
114-
115-
return std::move(step);
110+
return absl::make_unique<JumpStep>(jump_offset, expr_id);
116111
}
117112

118113
// Factory method for Conditional Jump step.
119114
// Conditional Jump requires a value to sit on the stack.
120115
// If this value is an error or unknown, a jump is performed.
121116
absl::StatusOr<std::unique_ptr<JumpStepBase>> CreateBoolCheckJumpStep(
122117
absl::optional<int> jump_offset, int64_t expr_id) {
123-
std::unique_ptr<JumpStepBase> step =
124-
absl::make_unique<BoolCheckJumpStep>(jump_offset, expr_id);
125-
126-
return std::move(step);
118+
return absl::make_unique<BoolCheckJumpStep>(jump_offset, expr_id);
127119
}
128120

129121
// TODO(issues/41) Make sure Unknowns are properly supported by ternary

eval/eval/logic_step.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,14 @@ absl::Status LogicalOpStep::Evaluate(ExecutionFrame* frame) const {
111111

112112
} // namespace
113113

114-
115114
// Factory method for "And" Execution step
116115
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateAndStep(int64_t expr_id) {
117-
std::unique_ptr<ExpressionStep> step =
118-
absl::make_unique<LogicalOpStep>(LogicalOpStep::OpType::AND, expr_id);
119-
120-
return std::move(step);
116+
return absl::make_unique<LogicalOpStep>(LogicalOpStep::OpType::AND, expr_id);
121117
}
122118

123119
// Factory method for "Or" Execution step
124120
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateOrStep(int64_t expr_id) {
125-
std::unique_ptr<ExpressionStep> step =
126-
absl::make_unique<LogicalOpStep>(LogicalOpStep::OpType::OR, expr_id);
127-
128-
return std::move(step);
121+
return absl::make_unique<LogicalOpStep>(LogicalOpStep::OpType::OR, expr_id);
129122
}
130123

131124
} // namespace runtime

0 commit comments

Comments
 (0)