Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenCXXABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ class CIRGenCXXABI {
/// (in the C++ sense) with an LLVM zeroinitializer.
virtual bool isZeroInitializable(const MemberPointerType *MPT);

/// Return whether or not a member pointers type is convertible to an IR type.
virtual bool isMemberPointerConvertible(const MemberPointerType *MPT) const {
return true;
}

/// Gets the offsets of all the virtual base pointers in a given class.
virtual std::vector<CharUnits> getVBPtrOffsets(const CXXRecordDecl *RD);

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType QFT) {
bool CIRGenTypes::isFuncParamTypeConvertible(clang::QualType Ty) {
// Some ABIs cannot have their member pointers represented in LLVM IR unless
// certain circumstances have been reached.
assert(!Ty->getAs<MemberPointerType>() && "NYI");
if (const auto *mpt = Ty->getAs<MemberPointerType>())
return getCXXABI().isMemberPointerConvertible(mpt);

// If this isn't a tagged type, we can convert it!
const TagType *TT = Ty->getAs<TagType>();
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CIR/CodeGen/pointer-to-member-func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,11 @@ Base2MemFunc derived_to_base(DerivedMemFunc ptr) {
// LLVM-NEXT: %[[#adj:]] = extractvalue { i64, i64 } %[[#arg]], 1
// LLVM-NEXT: %[[#adj_adj:]] = sub i64 %[[#adj]], 16
// LLVM-NEXT: %{{.+}} = insertvalue { i64, i64 } %[[#arg]], i64 %[[#adj_adj]], 1

struct HasVTable {
virtual void test(void (Foo::*)());
};

// Ensure that the vfunc pointer to the function involving a pointer-to-member-
// func could be emitted.
void HasVTable::test(void (Foo::*)()) {}
Loading