[clang] [CIR] Add support for derived class declarations (PR #142823)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 4 13:44:35 PDT 2025
================
@@ -32,3 +38,16 @@ CompleteC cc;
// CIR: cir.global external @cc = #cir.zero : !rec_CompleteC
// LLVM: @cc = global %class.CompleteC zeroinitializer
// OGCG: @cc = global %class.CompleteC zeroinitializer
+
+class Base {
+public:
+ int a;
+};
+
+class Derived : public Base {
+public:
+ int b;
+};
+
+int use(Derived *d) { return d->b; }
----------------
erichkeane wrote:
Can we get a CRTP test as well? Something like:
```
template<typename Derived>
struct CRTP {
Derived *otherDerived /* initializer left out, but add something to make sure this isn't ub */;
void callThing() {
static_cast<Derived>(*this)->thing();
otherDerived->thing();
}
};
struct D : CRTP<D> {
void thing(){}
};
void use( D&d) {
d.callThing();
}
```
I suspect it'll work fine, but its awkward enough with this sorta thing that it might be demonstrative.
https://github.com/llvm/llvm-project/pull/142823
More information about the cfe-commits
mailing list