summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/isl_ctx.h8
-rw-r--r--isl_affine_hull.c2
-rw-r--r--isl_convex_hull.c10
-rw-r--r--isl_dim.c2
-rw-r--r--isl_equalities.c10
-rw-r--r--isl_map.c12
-rw-r--r--isl_mat.c33
-rw-r--r--isl_tab_pip.c9
8 files changed, 49 insertions, 37 deletions
diff --git a/include/isl_ctx.h b/include/isl_ctx.h
index 874b1a88..fbf964c5 100644
--- a/include/isl_ctx.h
+++ b/include/isl_ctx.h
@@ -99,7 +99,13 @@ struct isl_ctx {
#define isl_realloc_array(ctx,ptr,type,n) \
isl_realloc(ctx,ptr,type,(n)*sizeof(type))
-#define isl_assert(ctx,test,code) assert(test)
+#define isl_assert(ctx,test,code) \
+ do { \
+ assert(test); \
+ if (0 && !ctx) { \
+ code; \
+ } \
+ } while(0)
#define isl_min(a,b) ((a < b) ? (a) : (b))
diff --git a/isl_affine_hull.c b/isl_affine_hull.c
index ce1b3073..68717a24 100644
--- a/isl_affine_hull.c
+++ b/isl_affine_hull.c
@@ -213,7 +213,7 @@ static struct isl_basic_set *affine_hull(
}
}
isl_basic_set_free(bset2);
- isl_assert(ctx, row == bset1->n_eq, goto error);
+ isl_assert(bset1->ctx, row == bset1->n_eq, goto error);
bset1 = isl_basic_set_normalize_constraints(bset1);
return bset1;
error:
diff --git a/isl_convex_hull.c b/isl_convex_hull.c
index 9869adf1..449aa833 100644
--- a/isl_convex_hull.c
+++ b/isl_convex_hull.c
@@ -288,8 +288,8 @@ static struct isl_basic_set *isl_basic_set_add_equality(
if (ISL_F_ISSET(bset, ISL_BASIC_SET_EMPTY))
return bset;
- isl_assert(ctx, isl_basic_set_n_param(bset) == 0, goto error);
- isl_assert(ctx, bset->n_div == 0, goto error);
+ isl_assert(bset->ctx, isl_basic_set_n_param(bset) == 0, goto error);
+ isl_assert(bset->ctx, bset->n_div == 0, goto error);
dim = isl_basic_set_n_dim(bset);
bset = isl_basic_set_cow(bset);
bset = isl_basic_set_extend(bset, 0, dim, 0, 1, 0);
@@ -523,8 +523,8 @@ static struct isl_mat *initial_facet_constraint(struct isl_set *set,
int i;
unsigned dim = isl_set_n_dim(set);
- isl_assert(ctx, set->n > 0, goto error);
- isl_assert(ctx, bounds->n_row == dim, goto error);
+ isl_assert(set->ctx, set->n > 0, goto error);
+ isl_assert(set->ctx, bounds->n_row == dim, goto error);
while (bounds->n_row > 1) {
slice = isl_set_copy(set);
@@ -554,7 +554,7 @@ static struct isl_mat *initial_facet_constraint(struct isl_set *set,
while (isl_seq_first_non_zero(bounds->row[bounds->n_row-1],
bounds->n_col) == -1) {
bounds->n_row--;
- isl_assert(ctx, bounds->n_row > 1, goto error);
+ isl_assert(set->ctx, bounds->n_row > 1, goto error);
}
if (!wrap_facet(set, bounds->row[0],
bounds->row[bounds->n_row-1]))
diff --git a/isl_dim.c b/isl_dim.c
index b6af7e20..e9e662a1 100644
--- a/isl_dim.c
+++ b/isl_dim.c
@@ -45,7 +45,7 @@ static unsigned global_pos(struct isl_dim *dim,
isl_assert(ctx, pos < dim->n_out, return isl_dim_total(dim));
return pos + dim->nparam + dim->n_in;
default:
- isl_assert(ctx, 0, goto error);
+ isl_assert(ctx, 0, return isl_dim_total(dim));
}
return isl_dim_total(dim);
}
diff --git a/isl_equalities.c b/isl_equalities.c
index cb16d172..811df6fc 100644
--- a/isl_equalities.c
+++ b/isl_equalities.c
@@ -183,7 +183,7 @@ static struct isl_mat *parameter_compression_multi(
T = isl_mat_lin_to_aff(T);
isl_int_set(T->row[0][0], D);
T = isl_mat_right_inverse(T);
- isl_assert(ctx, isl_int_is_one(T->row[0][0]), goto error);
+ isl_assert(T->ctx, isl_int_is_one(T->row[0][0]), goto error);
T = isl_mat_transpose(T);
isl_mat_free(A);
isl_mat_free(U);
@@ -301,7 +301,7 @@ struct isl_mat *isl_mat_parameter_compression(
if (!B || !d)
goto error;
- isl_assert(ctx, B->n_row == d->size, goto error);
+ isl_assert(B->ctx, B->n_row == d->size, goto error);
cst = particular_solution(B, d);
if (!cst)
goto error;
@@ -497,10 +497,10 @@ static struct isl_basic_set *compress_variables(
*T2 = NULL;
if (!bset)
goto error;
- isl_assert(ctx, isl_basic_set_n_param(bset) == 0, goto error);
- isl_assert(ctx, bset->n_div == 0, goto error);
+ isl_assert(bset->ctx, isl_basic_set_n_param(bset) == 0, goto error);
+ isl_assert(bset->ctx, bset->n_div == 0, goto error);
dim = isl_basic_set_n_dim(bset);
- isl_assert(ctx, bset->n_eq <= dim, goto error);
+ isl_assert(bset->ctx, bset->n_eq <= dim, goto error);
if (bset->n_eq == 0)
return bset;
diff --git a/isl_map.c b/isl_map.c
index d7c5d433..a497b5c6 100644
--- a/isl_map.c
+++ b/isl_map.c
@@ -1953,7 +1953,7 @@ struct isl_basic_set *isl_basic_set_apply(
if (!bset || !bmap)
goto error;
- isl_assert(set->ctx, isl_basic_map_compatible_domain(bmap, bset),
+ isl_assert(bset->ctx, isl_basic_map_compatible_domain(bmap, bset),
goto error);
return (struct isl_basic_set *)
@@ -1970,9 +1970,9 @@ struct isl_basic_map *isl_basic_map_apply_domain(
if (!bmap1 || !bmap2)
goto error;
- isl_assert(ctx,
+ isl_assert(bmap1->ctx,
isl_basic_map_n_in(bmap1) == isl_basic_map_n_in(bmap2), goto error);
- isl_assert(ctx,
+ isl_assert(bmap1->ctx,
isl_basic_map_n_param(bmap1) == isl_basic_map_n_param(bmap2),
goto error);
@@ -2960,7 +2960,7 @@ struct isl_map *isl_map_fix_si(struct isl_map *map,
if (!map)
return NULL;
- isl_assert(ctx, pos < isl_map_dim(map, type), goto error);
+ isl_assert(map->ctx, pos < isl_map_dim(map, type), goto error);
for (i = 0; i < map->n; ++i) {
map->p[i] = isl_basic_map_fix_si(map->p[i], type, pos, value);
if (!map->p[i])
@@ -4056,7 +4056,7 @@ struct isl_map *isl_basic_map_union(
if (!bmap1 || !bmap2)
return NULL;
- isl_assert(map1->ctx, isl_dim_equal(bmap1->dim, bmap2->dim), goto error);
+ isl_assert(bmap1->ctx, isl_dim_equal(bmap1->dim, bmap2->dim), goto error);
map = isl_map_alloc_dim(isl_dim_copy(bmap1->dim), 2, 0);
if (!map)
@@ -5013,7 +5013,7 @@ struct isl_basic_map *isl_basic_map_product(
if (!bmap1 || !bmap2)
goto error;
- isl_assert(map1->ctx, isl_dim_match(bmap1->dim, isl_dim_param,
+ isl_assert(bmap1->ctx, isl_dim_match(bmap1->dim, isl_dim_param,
bmap2->dim, isl_dim_param), goto error);
dim_result = isl_dim_product(isl_dim_copy(bmap1->dim),
isl_dim_copy(bmap2->dim));
diff --git a/isl_mat.c b/isl_mat.c
index 5cc25261..1479993d 100644
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -218,7 +218,7 @@ struct isl_vec *isl_mat_vec_product(struct isl_mat *mat, struct isl_vec *vec)
if (!mat || !vec)
goto error;
- isl_assert(ctx, mat->n_col == vec->size, goto error);
+ isl_assert(mat->ctx, mat->n_col == vec->size, goto error);
prod = isl_vec_alloc(mat->ctx, mat->n_row);
if (!prod)
@@ -244,7 +244,7 @@ struct isl_vec *isl_vec_mat_product(struct isl_vec *vec, struct isl_mat *mat)
if (!mat || !vec)
goto error;
- isl_assert(ctx, mat->n_row == vec->size, goto error);
+ isl_assert(mat->ctx, mat->n_row == vec->size, goto error);
prod = isl_vec_alloc(mat->ctx, mat->n_col);
if (!prod)
@@ -273,14 +273,14 @@ struct isl_mat *isl_mat_aff_direct_sum(struct isl_mat *left,
if (!left || !right)
goto error;
- isl_assert(ctx, left->n_row == right->n_row, goto error);
- isl_assert(ctx, left->n_row >= 1, goto error);
- isl_assert(ctx, left->n_col >= 1, goto error);
- isl_assert(ctx, right->n_col >= 1, goto error);
- isl_assert(ctx,
+ isl_assert(left->ctx, left->n_row == right->n_row, goto error);
+ isl_assert(left->ctx, left->n_row >= 1, goto error);
+ isl_assert(left->ctx, left->n_col >= 1, goto error);
+ isl_assert(left->ctx, right->n_col >= 1, goto error);
+ isl_assert(left->ctx,
isl_seq_first_non_zero(left->row[0]+1, left->n_col-1) == -1,
goto error);
- isl_assert(ctx,
+ isl_assert(left->ctx,
isl_seq_first_non_zero(right->row[0]+1, right->n_col-1) == -1,
goto error);
@@ -578,7 +578,7 @@ struct isl_mat *isl_mat_inverse_product(struct isl_mat *left,
if (pivot < 0) {
isl_int_clear(a);
isl_int_clear(b);
- isl_assert(ctx, pivot >= 0, goto error);
+ isl_assert(left->ctx, pivot >= 0, goto error);
}
pivot += row;
if (pivot != row)
@@ -619,7 +619,7 @@ struct isl_mat *isl_mat_inverse_product(struct isl_mat *left,
isl_int_lcm(a, a, left->row[row][row]);
if (isl_int_is_zero(a)){
isl_int_clear(a);
- isl_assert(ctx, 0, goto error);
+ isl_assert(left->ctx, 0, goto error);
}
for (row = 0; row < left->n_row; ++row) {
isl_int_divexact(left->row[row][row], a, left->row[row][row]);
@@ -773,8 +773,8 @@ struct isl_mat *isl_mat_swap_cols(struct isl_mat *mat, unsigned i, unsigned j)
mat = isl_mat_cow(mat);
if (!mat)
return NULL;
- isl_assert(ctx, i < mat->n_col, goto error);
- isl_assert(ctx, j < mat->n_col, goto error);
+ isl_assert(mat->ctx, i < mat->n_col, goto error);
+ isl_assert(mat->ctx, j < mat->n_col, goto error);
for (r = 0; r < mat->n_row; ++r)
isl_int_swap(mat->row[r][i], mat->row[r][j]);
@@ -806,7 +806,7 @@ struct isl_mat *isl_mat_product(struct isl_mat *left, struct isl_mat *right)
if (!left || !right)
goto error;
- isl_assert(ctx, left->n_col == right->n_row, goto error);
+ isl_assert(left->ctx, left->n_col == right->n_row, goto error);
prod = isl_mat_alloc(left->ctx, left->n_row, right->n_col);
if (!prod)
goto error;
@@ -1051,14 +1051,17 @@ struct isl_mat *isl_mat_unimodular_complete(struct isl_mat *M, int row)
int r;
struct isl_mat *H = NULL, *Q = NULL;
- isl_assert(ctx, M->n_row == M->n_col, goto error);
+ if (!M)
+ return NULL;
+
+ isl_assert(M->ctx, M->n_row == M->n_col, goto error);
M->n_row = row;
H = isl_mat_left_hermite(isl_mat_copy(M), 0, NULL, &Q);
M->n_row = M->n_col;
if (!H)
goto error;
for (r = 0; r < row; ++r)
- isl_assert(ctx, isl_int_is_one(H->row[r][r]), goto error);
+ isl_assert(M->ctx, isl_int_is_one(H->row[r][r]), goto error);
for (r = row; r < M->n_row; ++r)
isl_seq_cpy(M->row[r], Q->row[r], M->n_col);
isl_mat_free(H);
diff --git a/isl_tab_pip.c b/isl_tab_pip.c
index f284d25f..96fc3e01 100644
--- a/isl_tab_pip.c
+++ b/isl_tab_pip.c
@@ -1214,6 +1214,9 @@ static struct isl_tab *check_samples(struct isl_tab *tab, isl_int *ineq, int eq)
isl_int_clear(v);
return tab;
+error:
+ isl_tab_free(tab);
+ return NULL;
}
/* Check whether the sample value of the tableau is finite,
@@ -1307,9 +1310,9 @@ static int context_valid_sample_or_feasible(struct isl_sol *sol,
return -1;
tab = sol->context_tab;
- isl_assert(tab->mat->ctx, tab->bset, goto error);
- isl_assert(tab->mat->ctx, tab->samples, goto error);
- isl_assert(tab->mat->ctx, tab->samples->n_col == 1 + tab->n_var, goto error);
+ isl_assert(tab->mat->ctx, tab->bset, return -1);
+ isl_assert(tab->mat->ctx, tab->samples, return -1);
+ isl_assert(tab->mat->ctx, tab->samples->n_col == 1 + tab->n_var, return -1);
isl_int_init(v);
for (i = tab->n_outside; i < tab->n_sample; ++i) {