MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / operator()

Method operator()

eval/compiler/comprehension_vulnerability_check.cc:100–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 absl::string_view var_name;
99
100 int operator()(const CallExpr& call) {
101 int references = 0;
102 absl::string_view function = call.function();
103 // Return the maximum reference count of each side of the ternary branch.
104 if (function == cel::builtin::kTernary && call.args().size() == 3) {
105 return std::max(
106 ComprehensionAccumulationReferences(call.args()[1], var_name),
107 ComprehensionAccumulationReferences(call.args()[2], var_name));
108 }
109 // Return the number of times the accumulator var_name appears in the add
110 // expression. There's no arg size check on the add as it may become a
111 // variadic add at a future date.
112 if (function == cel::builtin::kAdd) {
113 for (int i = 0; i < call.args().size(); i++) {
114 references +=
115 ComprehensionAccumulationReferences(call.args()[i], var_name);
116 }
117
118 return references;
119 }
120 // Return whether the accumulator var_name is used as the operand in an
121 // index expression or in the identity `dyn` function.
122 if ((function == cel::builtin::kIndex && call.args().size() == 2) ||
123 (function == cel::builtin::kDyn && call.args().size() == 1)) {
124 return ComprehensionAccumulationReferences(call.args()[0], var_name);
125 }
126 return 0;
127 }
128 int operator()(const ComprehensionExpr& comprehension) {
129 absl::string_view accu_var = comprehension.accu_var();
130 absl::string_view iter_var = comprehension.iter_var();

Callers

nothing calls this directly

Calls 8

argsMethod · 0.80
test_onlyMethod · 0.80
sizeMethod · 0.45
exprMethod · 0.45
has_valueMethod · 0.45
valueMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected