\brief Simplify an expression given a guarantee, if the guarantee is is_valid().
| 1405 | /// \brief Simplify an expression given a guarantee, if the guarantee |
| 1406 | /// is is_valid(). |
| 1407 | Result<Expression> SimplifyIsValidGuarantee(Expression expr, |
| 1408 | const Expression::Call& guarantee) { |
| 1409 | if (guarantee.function_name != "is_valid") return expr; |
| 1410 | |
| 1411 | return ModifyExpression( |
| 1412 | std::move(expr), [](Expression expr) { return expr; }, |
| 1413 | [&](Expression expr, ...) -> Result<Expression> { |
| 1414 | auto call = expr.call(); |
| 1415 | if (!call) return expr; |
| 1416 | |
| 1417 | if (call->arguments[0] != guarantee.arguments[0]) return expr; |
| 1418 | |
| 1419 | if (call->function_name == "is_valid") return literal(true); |
| 1420 | |
| 1421 | if (call->function_name == "true_unless_null") return literal(true); |
| 1422 | |
| 1423 | if (call->function_name == "is_null") return literal(false); |
| 1424 | |
| 1425 | return expr; |
| 1426 | }); |
| 1427 | } |
| 1428 | |
| 1429 | } // namespace |
| 1430 |
nothing calls this directly
no test coverage detected