[clang] [CIR] Preserve annotate attributes on record declarations (PR #207551)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 17 01:05:05 PDT 2026
================
@@ -3263,6 +3263,34 @@ def CIR_GetGlobalOp : CIR_Op<"get_global", [
}];
}
+//===----------------------------------------------------------------------===//
+// RecordAnnotationOp
+//===----------------------------------------------------------------------===//
+
+def CIR_RecordAnnotationOp : CIR_Op<"record_annotation"> {
+ let summary = "Declares the source-level annotations on a record type";
+ let description = [{
+ The `cir.record_annotation` operation records the
+ `__attribute__((annotate(...)))` attributes attached to a
+ `clang::RecordDecl` (struct/class/union). It is emitted once per annotated
+ record, since `cir::RecordType` is uniqued by name/body and does not carry
+ an op-level attribute slot the way `cir.global`/`cir.func` do.
----------------
RedNicStone wrote:
I would be probably be better to handle this as an attribute. Using the name has a few drawbacks of course (anonymous types namely).
Because I'm using this feature in my own compiler, I was intending to keep the change a bit more minimal. Adding `#cir.annotate` has more surface area and would require some changes to storage uniquing (for anonymous types) and parsing.
I'm happy to change it over to attributes of course.
https://github.com/llvm/llvm-project/pull/207551
More information about the cfe-commits
mailing list