[clang] [CIR] Split RecordType into StructType/UnionType view classes; move union padding to dedicated field (PR #199790)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 27 08:53:38 PDT 2026
================
@@ -78,4 +78,48 @@ namespace cir {
#define GET_TYPEDEF_CLASSES
#include "clang/CIR/Dialect/IR/CIROpsTypes.h.inc"
+namespace cir {
+
+/// C++ view class for CIR struct/class record types.
+///
+/// Provides a type-safe handle for records with `RecordKind::Struct` or
+/// `RecordKind::Class`. Use `mlir::dyn_cast<StructType>` or
+/// `mlir::isa<StructType>` in place of `recordTy.isStruct()` checks.
+class StructType : public RecordType {
----------------
adams381 wrote:
injects content into `RecordType` itself and can't define a separate C++ class that inherits from it — the subclass + `classof` pattern has to live in a `.h` file.
If the right approach is to split `RecordType` into three independent tablegen types (`StructType`, `ClassType`, `UnionType`) each with its own grammar, storage, and printer, I can do that here. It's a larger change since the mutable-storage mechanism for incomplete types and the custom assembly format would need to be replicated across all three, but I can take it on in this PR if that's the direction.
https://github.com/llvm/llvm-project/pull/199790
More information about the cfe-commits
mailing list