CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
/* A class that sets a boolean when an object of the class gets destroyed.
|
|
*/
|
|
struct S {
|
|
S(bool *freed) : freed(freed) {}
|
|
~S();
|
|
|
|
bool *freed;
|
|
};
|
|
|
|
/* S destructor.
|
|
*
|
|
* Set the boolean, a pointer to which was passed to the constructor.
|
|
*/
|
|
S::~S()
|
|
{
|
|
*freed = true;
|
|
}
|
|
|
|
/* Construct an isl::id with an S object attached that sets *freed
|
|
* when it gets destroyed.
|
|
*/
|
|
static isl::id construct_id(isl::ctx ctx, bool *freed)
|
|
{
|
|
auto s = std::make_shared<S>(freed);
|
|
isl::id id(ctx, "S", s);
|
|
return id;
|
|
}
|
|
|
|
/* Test id::try_user.
|
|
*
|
|
* In particular, check that the object attached to an identifier
|
|
* can be retrieved again, that trying to retrieve an object of the wrong type
|
|
* or trying to retrieve an object when no object was attached fails.
|
|
* Furthermore, check that the object attached to an identifier
|
|
* gets properly freed.
|
|
*/
|
|
static void test_try_user(isl::ctx ctx)
|
|
{
|
|
isl::id id(ctx, "test", 5);
|
|
isl::id id2(ctx, "test2");
|
|
|
|
auto maybe_int = id.try_user<int>();
|
|
auto maybe_s = id.try_user<std::shared_ptr<S>>();
|
|
auto maybe_int2 = id2.try_user<int>();
|
|
|
|
if (!maybe_int)
|
|
die("integer cannot be retrieved from isl::id");
|
|
if (*maybe_int != 5)
|
|
die("wrong integer retrieved from isl::id");
|
|
if (maybe_s)
|
|
die("structure unexpectedly retrieved from isl::id");
|
|
if (maybe_int2)
|
|
die("integer unexpectedly retrieved from isl::id");
|
|
|
|
bool freed = false;
|
|
{
|
|
isl::id id = construct_id(ctx, &freed);
|
|
if (freed)
|
|
die("data structure freed prematurely");
|
|
auto maybe_s = id.try_user<std::shared_ptr<S>>();
|
|
if (!maybe_s)
|
|
die("structure cannot be retrieved from isl::id");
|
|
if ((*maybe_s)->freed != &freed)
|
|
die("invalid structure retrieved from isl::id");
|
|
}
|
|
if (!freed)
|
|
die("data structure not freed");
|
|
}
|