-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CIR] Add support for derived class declarations #142823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,19 @@ | |
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s | ||
|
||
// CIR: !rec_IncompleteC = !cir.record<class "IncompleteC" incomplete> | ||
// CIR: !rec_Base = !cir.record<class "Base" {!s32i}> | ||
// CIR: !rec_CompleteC = !cir.record<class "CompleteC" {!s32i, !s8i}> | ||
// CIR: !rec_Derived = !cir.record<class "Derived" {!rec_Base, !s32i}> | ||
|
||
// Note: LLVM and OGCG do not emit the type for incomplete classes. | ||
|
||
// LLVM: %class.CompleteC = type { i32, i8 } | ||
// LLVM: %class.Derived = type { %class.Base, i32 } | ||
// LLVM: %class.Base = type { i32 } | ||
|
||
// OGCG: %class.CompleteC = type { i32, i8 } | ||
// OGCG: %class.Derived = type { %class.Base, i32 } | ||
// OGCG: %class.Base = type { i32 } | ||
|
||
class IncompleteC; | ||
IncompleteC *p; | ||
|
@@ -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; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get a CRTP test as well? Something like:
I suspect it'll work fine, but its awkward enough with this sorta thing that it might be demonstrative. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't handle this yet because it requires an implicit DerivedToBase cast, which will be in an upcoming patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, hrmph. Well, file this one away then :) |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some asserts here for this condition?