Add stronger checking

- Add assertions to enforce that objects are of the correct kind and
  have been allocated.

- Make destructors check if objects have been allocated before
  deleting.

- Operations that require a non-NullDevice return failure if given a
  NullDevice.

- Use static_cast rather than reinterpret_cast when cohersing from a
  base class to a derived class.

Change-Id: I02ee0ea9d7982fd7ca29d49c9b02cfae111b7127
This commit is contained in:
Tony Tye
2021-01-10 02:09:00 +00:00
والد 001fd66cac
کامیت e5431676d4
11فایلهای تغییر یافته به همراه96 افزوده شده و 13 حذف شده
@@ -349,6 +349,7 @@ class Program : public NullProgram {
//! Return a typecasted GPU device
gpu::Device& gpuDevice() {
assert(!isNull());
return const_cast<gpu::Device&>(static_cast<const gpu::Device&>(device()));
}
@@ -476,6 +477,7 @@ class HSAILProgram : public device::Program {
//! Return a typecasted GPU device. The device must not be the NullDevice.
gpu::Device& gpuDevice() {
assert(!isNull());
return const_cast<gpu::Device&>(static_cast<const gpu::Device&>(device()));
}