[clang] [CIR] Add CXX special member attribute to cir::FuncOp (PR #167975)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 16 01:24:16 PST 2025
================
@@ -822,6 +822,104 @@ def CIR_GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> {
}];
}
+//===----------------------------------------------------------------------===//
+// CXX SpecialMemberAttr
+//===----------------------------------------------------------------------===//
+
+def CIR_CtorKind : CIR_I32EnumAttr<"CtorKind", "CXX Constructor Kind", [
+ I32EnumAttrCase<"Custom", 0, "custom">,
+ I32EnumAttrCase<"Default", 1, "default">,
+ I32EnumAttrCase<"Copy", 2, "copy">,
+ I32EnumAttrCase<"Move", 3, "move">,
+]> {
+ let genSpecializedAttr = 0;
+}
+
+def CIR_CXXCtorAttr : CIR_Attr<"CXXCtor", "cxx_ctor"> {
+ let summary = "Marks a function as a CXX constructor";
+ let description = [{
+ Functions with this attribute are CXX constructors.
+ The `custom` kind is used if the constructor is a custom constructor.
+ The `default` kind is used if the constructor is a default constructor.
+ The `copy` kind is used if the constructor is a copy constructor.
+ The `move` kind is used if the constructor is a move constructor.
+ }];
+ let parameters = (ins "mlir::Type":$type,
+ EnumParameter<CIR_CtorKind>:$ctorKind,
+ "bool":$is_trivial);
+
+ let assemblyFormat = [{
+ `<` $type `,` $ctorKind `,` $is_trivial `>`
----------------
xlauko wrote:
Only `#cir.cxx_ctor<!rec_Something, kind, trivial>` but yes :) It creates a prefix using dialect name and attribute mnemonic (`cir.cxx_ctor`) and concatenates it with assembly format.
https://github.com/llvm/llvm-project/pull/167975
More information about the cfe-commits
mailing list