@@ -1813,6 +1813,25 @@ at_scope_exitt<functiont> at_scope_exit(functiont exit_function)
1813
1813
}
1814
1814
#endif
1815
1815
1816
+ exprt lower_address_of_array_index (exprt expr)
1817
+ {
1818
+ expr.visit_pre ([](exprt &expr) {
1819
+ const auto address_of_expr = expr_try_dynamic_cast<address_of_exprt>(expr);
1820
+ if (!address_of_expr)
1821
+ return ;
1822
+ const auto array_index_expr =
1823
+ expr_try_dynamic_cast<index_exprt>(address_of_expr->object ());
1824
+ if (!array_index_expr)
1825
+ return ;
1826
+ expr = plus_exprt{
1827
+ address_of_exprt{
1828
+ array_index_expr->array (),
1829
+ type_checked_cast<pointer_typet>(address_of_expr->type ())},
1830
+ array_index_expr->index ()};
1831
+ });
1832
+ return expr;
1833
+ }
1834
+
1816
1835
smt_termt convert_expr_to_smt (
1817
1836
const exprt &expr,
1818
1837
const smt_object_mapt &object_map,
@@ -1830,13 +1849,14 @@ smt_termt convert_expr_to_smt(
1830
1849
const auto end_conversion = at_scope_exit ([&]() { in_conversion = false ; });
1831
1850
#endif
1832
1851
sub_expression_mapt sub_expression_map;
1833
- expr.visit_post ([&](const exprt &expr) {
1852
+ const auto lowered_expr = lower_address_of_array_index (expr);
1853
+ lowered_expr.visit_post ([&](const exprt &expr) {
1834
1854
const auto find_result = sub_expression_map.find (expr);
1835
1855
if (find_result != sub_expression_map.cend ())
1836
1856
return ;
1837
1857
smt_termt term = dispatch_expr_to_smt_conversion (
1838
1858
expr, sub_expression_map, object_map, pointer_sizes, object_size);
1839
1859
sub_expression_map.emplace_hint (find_result, expr, std::move (term));
1840
1860
});
1841
- return std::move (sub_expression_map.at (expr ));
1861
+ return std::move (sub_expression_map.at (lowered_expr ));
1842
1862
}
0 commit comments