diff options
author | Andy Kaylor <akaylor@nvidia.com> | 2025-05-19 14:42:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-19 14:42:50 -0700 |
commit | a0c515a9ef3be780e2dfd64d86de9e401b137b28 (patch) | |
tree | be738d9a2fccfd8a68b8b3d227b1458a24ca9c04 /clang/lib/CIR/CodeGen/CIRGenModule.cpp | |
parent | 0b4cfd19f237fbbffb6e49b82dd91ee65e1e43a2 (diff) | |
download | llvm-a0c515a9ef3be780e2dfd64d86de9e401b137b28.zip llvm-a0c515a9ef3be780e2dfd64d86de9e401b137b28.tar.gz llvm-a0c515a9ef3be780e2dfd64d86de9e401b137b28.tar.bz2 |
[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.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenModule.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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<cir::FuncOp>(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<CXXMethodDecl>(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<CXXConstructorDecl>(method) || isa<CXXDestructorDecl>(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<FunctionDecl>(decl); // Consteval functions shouldn't be emitted. |