From 42f8dfdba029c5fee2068d36d85fd38bfd02de35 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 20 Aug 2018 14:30:27 +0200 Subject: [PATCH] extract out shared isl_pw_multi_aff_check_range Signed-off-by: Sven Verdoolaege --- isl_aff.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/isl_aff.c b/isl_aff.c index 29a2efc3..dc1921da 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -5755,6 +5755,10 @@ error: return isl_multi_aff_free(maff); } +#undef TYPE +#define TYPE isl_pw_multi_aff +static +#include "check_type_range_templ.c" /* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma". */ @@ -5766,13 +5770,10 @@ __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff( isl_space *space; isl_pw_aff *pa; - if (!pma) + if (isl_pw_multi_aff_check_range(pma, isl_dim_out, pos, 1) < 0) return NULL; n_out = isl_pw_multi_aff_dim(pma, isl_dim_out); - if (pos < 0 || pos >= n_out) - isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_invalid, - "index out of bounds", return NULL); space = isl_pw_multi_aff_get_space(pma); space = isl_space_drop_dims(space, isl_dim_out, @@ -6009,9 +6010,8 @@ static __isl_give isl_pw_multi_aff *pw_multi_aff_set_pw_aff( pa->dim, isl_dim_in)) isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_invalid, "domains don't match", goto error); - if (pos >= isl_pw_multi_aff_dim(pma, isl_dim_out)) - isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_invalid, - "index out of bounds", goto error); + if (isl_pw_multi_aff_check_range(pma, isl_dim_out, pos, 1) < 0) + goto error; n = pma->n * pa->n; res = isl_pw_multi_aff_alloc_size(isl_pw_multi_aff_get_space(pma), n); -- 2.11.4.GIT