[PATCH] D104392: [HIP] Add support functions for C++ polymorphic types

Siu Chi Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 16 08:42:06 PDT 2021


scchan created this revision.
scchan added a reviewer: yaxunl.
scchan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add runtime functions to detect invalid calls to pure or deleted virtual
functions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104392

Files:
  clang/lib/Headers/__clang_hip_runtime_wrapper.h


Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===================================================================
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -51,6 +51,23 @@
   #define nullptr NULL;
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+  __attribute__((__visibility__("default")))
+  __attribute__((weak))
+  __attribute__((noreturn))
+  __device__ void __cxa_pure_virtual(void) {
+    __builtin_trap();
+  }
+  __attribute__((__visibility__("default")))
+  __attribute__((weak))
+  __attribute__((noreturn))
+  __device__ void __cxa_deleted_virtual(void) {
+    __builtin_trap();
+  } 
+}
+#endif //__cplusplus
+
 #if __HIP_ENABLE_DEVICE_MALLOC__
 extern "C" __device__ void *__hip_malloc(size_t __size);
 extern "C" __device__ void *__hip_free(void *__ptr);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104392.352455.patch
Type: text/x-patch
Size: 840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210616/fec039cb/attachment-0001.bin>


More information about the cfe-commits mailing list