Index: lib/Exchange/JSONExporter.cpp =================================================================== --- lib/Exchange/JSONExporter.cpp +++ lib/Exchange/JSONExporter.cpp @@ -274,9 +274,23 @@ bool JSONImporter::importContext(Scop &S, Json::Value &JScop) { isl_set *OldContext = S.getContext(); + + if (!JScop.isMember("context")) { + errs() << "JScop file has no key named 'context'.\n"; + isl_set_free(OldContext); + return false; + } + isl_set *NewContext = isl_set_read_from_str(S.getIslCtx(), JScop["context"].asCString()); + if (!isl_set_is_params(NewContext)) { + errs() << "The isl_set is not a parameter set.\n"; + isl_set_free(NewContext); + isl_set_free(OldContext); + return false; + } + for (unsigned i = 0; i < isl_set_dim(OldContext, isl_dim_param); i++) { isl_id *Id = isl_set_get_dim_id(OldContext, isl_dim_param, i); NewContext = isl_set_set_dim_id(NewContext, isl_dim_param, i, Id);