@@ -1578,6 +1578,55 @@ RValue CIRGenFunction::emitCXXDestructorCall(GlobalDecl Dtor,
1578
1578
: getLoc (Dtor.getDecl ()->getSourceRange ()));
1579
1579
}
1580
1580
1581
+ RValue CIRGenFunction::emitCXXPseudoDestructorExpr (
1582
+ const CXXPseudoDestructorExpr *expr) {
1583
+ QualType destroyedType = expr->getDestroyedType ();
1584
+ if (destroyedType.hasStrongOrWeakObjCLifetime ()) {
1585
+ // Automatic Reference Counting:
1586
+ // If the pseudo-expression names a retainable object with weak or
1587
+ // strong lifetime, the object shall be released.
1588
+ Expr *baseExpr = expr->getBase ();
1589
+ Address baseValue = Address::invalid ();
1590
+ Qualifiers baseQuals;
1591
+
1592
+ // If this is s.x, emit s as an lvalue. If it is s->x, emit s as a scalar.
1593
+ if (expr->isArrow ()) {
1594
+ baseValue = emitPointerWithAlignment (baseExpr);
1595
+ const auto *ptrTy = baseExpr->getType ()->castAs <PointerType>();
1596
+ baseQuals = ptrTy->getPointeeType ().getQualifiers ();
1597
+ } else {
1598
+ LValue baseLV = emitLValue (baseExpr);
1599
+ baseValue = baseLV.getAddress ();
1600
+ QualType baseTy = baseExpr->getType ();
1601
+ baseQuals = baseTy.getQualifiers ();
1602
+ }
1603
+
1604
+ switch (destroyedType.getObjCLifetime ()) {
1605
+ case Qualifiers::OCL_None:
1606
+ case Qualifiers::OCL_ExplicitNone:
1607
+ case Qualifiers::OCL_Autoreleasing:
1608
+ break ;
1609
+
1610
+ case Qualifiers::OCL_Strong:
1611
+ llvm_unreachable (" NYI, emitArcRelease" );
1612
+ break ;
1613
+
1614
+ case Qualifiers::OCL_Weak:
1615
+ llvm_unreachable (" NYI, emitARCDestroyWeak" );
1616
+ break ;
1617
+ }
1618
+ } else {
1619
+ // C++ [expr.pseudo]p1:
1620
+ // The result shall only be used as the operand for the function call
1621
+ // operator (), and the result of such a call has type void. The only
1622
+ // effect is the evaluation of the postfix-expression before the dot or
1623
+ // arrow.
1624
+ emitIgnoredExpr (expr->getBase ());
1625
+ }
1626
+
1627
+ return RValue::get (nullptr );
1628
+ }
1629
+
1581
1630
// / Emit a call to an operator new or operator delete function, as implicitly
1582
1631
// / created by new-expressions and delete-expressions.
1583
1632
static RValue emitNewDeleteCall (CIRGenFunction &CGF,
0 commit comments