MCPcopy Create free account
hub / github.com/csmith-project/csmith / find_expr_key_var

Function find_expr_key_var

src/ArrayVariable.cpp:101–122  ·  view source on GitHub ↗

* find the "key" variable of an expression. * return NULL if expression is a function call, constant, or a binary * operation involves at least two variables */

Source from the content-addressed store, hash-verified

99 * operation involves at least two variables
100 */
101static const Variable* find_expr_key_var(const Expression* e)
102{
103 if (e->term_type == eVariable) {
104 return ((const ExpressionVariable*)e)->get_var();
105 }
106 else if (e->term_type == eFunction) {
107 const ExpressionFuncall* ef = dynamic_cast<const ExpressionFuncall*>(e);
108 assert(ef);
109 const FunctionInvocation& fi = *(ef->get_invoke());
110 if (fi.invoke_type == eBinaryPrim || fi.invoke_type == eUnaryPrim) {
111 if (fi.param_value.size()==1) {
112 return find_expr_key_var(fi.param_value[0]);
113 }
114 assert(fi.param_value.size() == 2);
115 const Variable* v0 = find_expr_key_var(fi.param_value[0]);
116 const Variable* v1 = find_expr_key_var(fi.param_value[1]);
117 if (v0 == NULL && v1 != NULL) return v1;
118 if (v0 != NULL && v1 == NULL) return v0;
119 }
120 }
121 return NULL;
122}
123
124//=======================================================================================
125ArrayVariable *

Callers 1

is_variantMethod · 0.85

Calls 3

sizeMethod · 0.80
get_varMethod · 0.45
get_invokeMethod · 0.45

Tested by

no test coverage detected