[clang] [CIR] Add CIR vtable attribute (PR #154415)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 20 11:02:04 PDT 2025
================
@@ -496,6 +496,46 @@ def CIR_GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [
}];
}
+//===----------------------------------------------------------------------===//
+// VTableAttr
+//===----------------------------------------------------------------------===//
+
+def VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> {
+ let summary = "Represents a C++ vtable";
+ let description = [{
+ Wraps a #cir.const_record containing vtable data.
+
+ Example:
+ ```
+ cir.global linkonce_odr @_ZTV1B = #cir.vtable<<
+ {#cir.const_array<[#cir.null : !cir.ptr<i8>,
+ #cir.global_view<@_ZTI1B> : !cir.ptr<i8>,
+ #cir.global_view<@_ZN1BD1Ev> : !cir.ptr<i8>,
+ #cir.global_view<@_ZN1BD0Ev> : !cir.ptr<i8>,
+ #cir.global_view<@_ZNK1A5quackEv> : !cir.ptr<i8>]>
+ : !cir.array<!cir.ptr<i8> x 5>}>>
+ : !cir.record<"", !cir.array<!cir.ptr<i8> x 5>>
+ ```
+ }];
+
+ // `vtable_data` is a const record with one element, containing an array of
----------------
andykaylor wrote:
As mentioned above, there can be multiple arrays. I'll update this comment to reflect that and add an example with two arrays.
https://github.com/llvm/llvm-project/pull/154415
More information about the cfe-commits
mailing list