void shapes_free(shapes_v* shapes) { for(uint32_t i=0; i< kv_size(*shapes); i++) { shape_free(kv_A(*shapes, i)); } kv_destroy(*shapes); free(shapes); }
/** * Checks the entailment sh_pos => sh_neg * using the sound procedure of shad. */ int sh_check (void) { #ifndef NDEBUG1 fprintf (stdout, "Sh_check: sh_pos = \n"); sh_fprint (stdout, sh_pos); fflush (stdout); fprintf (stdout, "Sh_check: sh_neg = \n"); sh_fprint (stdout, sh_neg); fflush (stdout); #endif // Step 1: deal with the trivial cases if (!sh_pos) { // consider sh_pos as true fprintf (stdout, "Sh_check: trivial entailment true => phi returns false.\n"); return 0; } if (!sh_neg) { // consider sh_neg as true fprintf (stdout, "Sh_check: trivial entailment phi => true returns true.\n"); return 1; } // Step 2: collect informations about the dataword domains // PENDING: generate files cinv.txt and, for guards, cinv-ucons.txt // Step 3: build the abstract values // create a manager for shape, parameters are read from cinv files above ap_manager_t* shm = shape_manager_alloc (); if (!shm) return 0; shape_t * top = shape_top (shm, 1, 1); for (int i = 0; i < AP_EXC_SIZE; i++) { shm->option.abort_if_exception[i] = true; } int max_anon = (sh_guards >= (4 << 8)) ? 1 : 0; int segm_anon = (sh_guards >= (2 << 8)) ? 2 : 1; shape_approximate (shm, top, max_anon | (segm_anon << 4) | sh_guards); shape_free (shm, top); // build abstract values from shad formula shape_t *shp = shape_of_formula (shm, sh_pos); // assigns shp_crt shape_t *shn = shape_of_formula (shm, sh_neg); // Step 4: do the inclusion test // The inclusion test call saturation if the test does not follow from // the shape form bool r = shape_is_leq (shm, shp, shn); return (r == true) ? 1 : -1; ; }