For this translation we introduce two functions, valFromAPInt and APIntFromVal,
to convert between isl::Val and APInt. For now these are just proxies, but in
the future they will replace the current isl_val* based conversion functions.
The isl unit test cases benefit most from the new isl::Bool (from Michael
Kruse), which can be explicitly casted to bool and which -- as part of this cast
- emits a check that no error condition has been triggered so far. This allows
us to simplify
EXPECT_EQ(isl_bool_true, isl_val_is_zero(IslZero));
to
EXPECT_TRUE(IslZero.is_zero());
This simplification also becomes very clear in operator==, which changes from
auto IsEqual = isl_set_is_equal(LHS.keep(), RHS.keep()); EXPECT_NE(isl_bool_error, IsEqual); return IsEqual;
to just
return bool(LHS.is_equal(RHS));
Some background for non-isl users. The isl C interface has an isl_bool type,
which can be either true, false, or error. Hence, whenever a function returns
a value of type isl_bool, an explicit error check should be considered. By
using isl::Bool, we can just cast the isl::Bool to 'bool' or simply use the
isl::Bool in a context where it will automatically be casted to bool (e.g., in
an if-condition). When doing so, the C++ bindings automatically add code that
verifies that the return value is not an error code. If it is, the program will
warn about this and abort. For cases where errors are expected, isl::Bool
provides checks such as Bool::isTrueOrError() or Bool::isTrueNoError() to
explicitly control program behavior in case of error conditions.
Thanks to the new automatic memory management, we also can avoid many calls to
isl_*_free. For code that had previously been managed by IslPtr<>, many calls
to give/take/copy are eliminated.