[clang] [CIR] Upstream TypeInfo attribute (PR #159426)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 22:17:30 PDT 2025
================
@@ -779,4 +779,54 @@ def CIR_AddressPointAttr : CIR_Attr<"AddressPoint", "address_point"> {
}];
}
+//===----------------------------------------------------------------------===//
+// TypeInfoAttr
+//===----------------------------------------------------------------------===//
+
+def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {
+ let summary = "Represents a typeinfo used for RTTI";
+ let description = [{
+ The typeinfo data for a given class is stored into an ArrayAttr. The
+ layout is determined by the C++ ABI used (clang only implements
+ itanium on CIRGen).
+
+ The verifier enforces that the output type is always a `!cir.record`,
+ and that the ArrayAttr element types match the equivalent member type
+ for the resulting record, i.e, a GlobalViewAttr for symbol reference or
+ an IntAttr for flags.
+
+ Example:
+
+ ```
+ cir.global "private" external @_ZTVN10__cxxabiv120__si_class_type_infoE
+ : !cir.ptr<i32>
+
+ !rec_anon_struct = !cir.record<struct {!cir.ptr<!u8i>, !cir.ptr<!u8i>,
+ !cir.ptr<!u8i>}>
+
+ cir.global constant external @type_info = #cir.typeinfo<{
+ #cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2 : i32]>
+ : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1B> : !cir.ptr<!u8i>,
+ #cir.global_view<@_ZTI1A> : !cir.ptr<!u8i>}> : !rec_anon_struct
+ ```
+ }];
+
+ let parameters = (ins AttributeSelfTypeParameter<"">:$type,
+ CIR_IntOrGlobalViewArrayAttr:$data);
----------------
xlauko wrote:
```suggestion
let parameters = (ins
AttributeSelfTypeParameter<"">:$type,
CIR_IntOrGlobalViewArrayAttr:$data
);
```
https://github.com/llvm/llvm-project/pull/159426
More information about the cfe-commits
mailing list