[clang] [CIR] Upstream support for calling constructors (PR #143579)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 14:10:32 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())) {
----------------
AmrDeveloper wrote:
NIT: `arrayType` variable will be unused
I think it can be
```
if (getContext().getAsArrayType(e->getType()))
```
https://github.com/llvm/llvm-project/pull/143579
More information about the cfe-commits
mailing list