aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
diff options
context:
space:
mode:
authorAndy Kaylor <akaylor@nvidia.com>2025-06-12 09:24:26 -0700
committerGitHub <noreply@github.com>2025-06-12 09:24:26 -0700
commit77834a40cf350d2fe63fac26222c3918f5f348fd (patch)
tree55dff8e127a38bda8efa47ee82c28365eee3ece9 /clang/lib/CIR/CodeGen/CIRGenModule.cpp
parent4039fdb7ba5a0d9ead5bdc0404f036063a4ca95d (diff)
downloadllvm-77834a40cf350d2fe63fac26222c3918f5f348fd.zip
llvm-77834a40cf350d2fe63fac26222c3918f5f348fd.tar.gz
llvm-77834a40cf350d2fe63fac26222c3918f5f348fd.tar.bz2
[CIR] Upstream support for emitting constructors (#143639)
This change upstreams the code to emit simple constructor defintions.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenModule.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 8407f8f..434dd37 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -226,11 +226,9 @@ mlir::Operation *
CIRGenModule::getAddrOfGlobal(GlobalDecl gd, ForDefinition_t isForDefinition) {
const Decl *d = gd.getDecl();
- if (isa<CXXConstructorDecl>(d) || isa<CXXDestructorDecl>(d)) {
- errorNYI(d->getSourceRange(),
- "getAddrOfGlobal: C++ constructor/destructor");
- return nullptr;
- }
+ if (isa<CXXConstructorDecl>(d) || isa<CXXDestructorDecl>(d))
+ return getAddrOfCXXStructor(gd, /*FnInfo=*/nullptr, /*FnType=*/nullptr,
+ /*DontDefer=*/false, isForDefinition);
if (isa<CXXMethodDecl>(d)) {
const CIRGenFunctionInfo &fi =
@@ -411,6 +409,7 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
cgf.generateCode(gd, funcOp, funcType);
}
curCGF = nullptr;
+ assert(!cir::MissingFeatures::opFuncAttributesForDefinition());
}
mlir::Operation *CIRGenModule::getGlobalValue(StringRef name) {
@@ -771,7 +770,7 @@ void CIRGenModule::emitGlobalDefinition(clang::GlobalDecl gd,
// Make sure to emit the definition(s) before we emit the thunks. This is
// necessary for the generation of certain thunks.
if (isa<CXXConstructorDecl>(method) || isa<CXXDestructorDecl>(method))
- errorNYI(method->getSourceRange(), "C++ ctor/dtor");
+ abi->emitCXXStructor(gd);
else if (fd->isMultiVersion())
errorNYI(method->getSourceRange(), "multiversion functions");
else
@@ -1173,6 +1172,10 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
case Decl::Empty:
break;
+ case Decl::CXXConstructor:
+ getCXXABI().emitCXXConstructors(cast<CXXConstructorDecl>(decl));
+ break;
+
// C++ Decls
case Decl::LinkageSpec:
case Decl::Namespace: