From d96d7ae28faf51ba63a6f95c549761c9fb4bd2ec Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Sat, 13 May 2017 11:02:44 +0200 Subject: [PATCH] cpp: explicitly manage isl_bool return values Use isl::mangage(res) when returning isl_bool values, instead of relying on implicit conversion. Before this change the following code was generated: isl::boolean set::is_empty() const { auto res = isl_set_is_empty(get()); return res; } For this code, the return value of the function was implicitly constructed from the value res of type isl_bool. As no implicit constructor isl::boolean(isl_bool) was available, the constructor isl::boolean(bool) was invoked and isl_bool was implicitly converted to bool. As part of this conversion, isl_bool_error was converted to true, which is incorrect. This issue is resolved by explicitly calling "return isl::manage(res)". Signed-off-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- interface/cpp.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/cpp.cc b/interface/cpp.cc index e9d54b38..cab1d9a0 100644 --- a/interface/cpp.cc +++ b/interface/cpp.cc @@ -651,9 +651,9 @@ void cpp_generator::print_method_param_use(ostream &os, ParmVarDecl *param, * Member methods call "method" by passing to the underlying isl function the * isl object belonging to "this" as first argument and the remaining arguments * as subsequent arguments. The result of the isl function is returned as a new - * object if the underlying isl function returns an isl_* ptr, as std::string - * if the isl function returns 'const char *', and as unmodified return value - * otherwise. + * object if the underlying isl function returns an isl_* ptr or an isl_bool + * value, as std::string if the isl function returns 'const char *', and as + * unmodified return value otherwise. * * Static methods call "method" by passing all arguments to the underlying isl * function, as no this-pointer is available. The result is a newly managed @@ -707,7 +707,7 @@ void cpp_generator::print_method_impl(ostream &os, const isl_class &clazz, if (kind == function_kind_constructor) { osprintf(os, " ptr = res;\n"); - } else if (is_isl_type(return_type)) { + } else if (is_isl_type(return_type) || is_isl_bool(return_type)) { osprintf(os, " return manage(res);\n"); } else if (has_callback) { osprintf(os, " return %s(res);\n", rettype_str.c_str()); -- 2.11.4.GIT