[clang] [CIR] Upstream support for calling constructors (PR #143579)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 15:01:42 PDT 2025
================
@@ -1393,6 +1393,57 @@ RValue CIRGenFunction::emitCXXMemberCallExpr(const CXXMemberCallExpr *ce,
ce, md, returnValue, hasQualifier, qualifier, isArrow, base);
}
+void CIRGenFunction::emitCXXConstructExpr(const CXXConstructExpr *e,
+ AggValueSlot dest) {
+ assert(!dest.isIgnored() && "Must have a destination!");
+ const CXXConstructorDecl *cd = e->getConstructor();
+
+ // If we require zero initialization before (or instead of) calling the
+ // constructor, as can be the case with a non-user-provided default
+ // constructor, emit the zero initialization now, unless destination is
+ // already zeroed.
+ if (e->requiresZeroInitialization() && !dest.isZeroed()) {
+ cgm.errorNYI(e->getSourceRange(),
+ "emitCXXConstructExpr: requires initialization");
+ return;
+ }
+
+ // If this is a call to a trivial default constructor:
+ // In LLVM: do nothing.
+ // In CIR: emit as a regular call, other later passes should lower the
+ // ctor call into trivial initialization.
+
+ // Elide the constructor if we're constructing from a temporary
+ if (getLangOpts().ElideConstructors && e->isElidable()) {
+ cgm.errorNYI(e->getSourceRange(),
+ "emitCXXConstructExpr: elidable constructor");
+ return;
+ }
+
+ if (const ArrayType *arrayType = getContext().getAsArrayType(e->getType())) {
+ cgm.errorNYI(e->getSourceRange(), "emitCXXConstructExpr: array type");
+ return;
+ } else {
+ clang::CXXCtorType type = Ctor_Complete;
----------------
andykaylor wrote:
That's just a clang-tidy warning, right?
I was going to say that I'd prefer not to restructure the code that way since the missing code represented by the errorNYI doesn't return in the incubator, but I just looked again, and there is no reason that it couldn't return and that would save a level of indenting on the rest of the code, so I'll go ahead with the suggested change.
https://github.com/llvm/llvm-project/pull/143579
More information about the cfe-commits
mailing list