checked C++ bindings: abort on unchecked stat error
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 25 Jun 2018 05:44:36 +0000 (25 07:44 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 30 Jul 2018 21:10:34 +0000 (30 23:10 +0200)
That is, require a call to is_ok()/is_error() on every
isl::checked::stat object.
This is similar to the way isl::checked::boolean is handled,
but slightly stricter because calling one of these methods
is always sufficient for determining if an error state has occurred.
When the isl_stat value is released, it is assumed to be sent
to isl, which will also check the error state.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
cpp/cpp-checked.h.pre

index 05c6920..43911e5 100644 (file)
@@ -78,6 +78,7 @@ public:
  */
 class stat {
 private:
+       mutable bool checked = false;
        isl_stat val;
 
        friend stat manage(isl_stat val);
@@ -90,15 +91,21 @@ public:
                return stat(isl_stat_error);
        }
        stat() : val(isl_stat_error) {}
+       ~stat() {
+               ISLPP_ASSERT(checked, "IMPLEMENTATION ERROR: Unchecked state");
+       }
 
        isl_stat release() {
+               checked = true;
                return val;
        }
 
        bool is_error() const {
+               checked = true;
                return val == isl_stat_error;
        }
        bool is_ok() const {
+               checked = true;
                return val == isl_stat_ok;
        }
 };