From a0c515a9ef3be780e2dfd64d86de9e401b137b28 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 19 May 2025 14:42:50 -0700 Subject: [CIR] Upstream support for C++ member function calls (#140290) This change adds the support needed to handle a C++ member function call, including arranging the function type with an argument added for the 'this' parameter. It was necessary to introduce the class to handle the CXXABI, but at this time no target-specific subclasses have been added. --- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp') diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index bd3aa37..e170498 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -61,7 +61,6 @@ CIRGenCXXABI *CreateCIRGenItaniumCXXABI(CIRGenModule &cgm) { return new CIRGenCXXABI(cgm); } } // namespace clang::CIRGen -CIRGenCXXABI::~CIRGenCXXABI() {} CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext, clang::ASTContext &astContext, @@ -251,7 +250,6 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd, const CIRGenFunctionInfo &fi = getTypes().arrangeGlobalDeclaration(gd); cir::FuncType funcType = getTypes().getFunctionType(fi); - cir::FuncOp funcOp = dyn_cast_if_present(op); if (!funcOp || funcOp.getFunctionType() != funcType) { funcOp = getAddrOfFunction(gd, funcType, /*ForVTable=*/false, @@ -539,8 +537,16 @@ void CIRGenModule::emitGlobalDefinition(clang::GlobalDecl gd, if (const auto *method = dyn_cast(decl)) { // Make sure to emit the definition(s) before we emit the thunks. This is // necessary for the generation of certain thunks. - (void)method; - errorNYI(method->getSourceRange(), "member function"); + if (isa(method) || isa(method)) + errorNYI(method->getSourceRange(), "C++ ctor/dtor"); + else if (fd->isMultiVersion()) + errorNYI(method->getSourceRange(), "multiversion functions"); + else + emitGlobalFunctionDefinition(gd, op); + + if (method->isVirtual()) + errorNYI(method->getSourceRange(), "virtual member function"); + return; } @@ -770,6 +776,7 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) { decl->getDeclKindName()); break; + case Decl::CXXMethod: case Decl::Function: { auto *fd = cast(decl); // Consteval functions shouldn't be emitted. -- cgit v1.1